Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Exposing packages from a jar inside a plug-in
Exposing packages from a jar inside a plug-in [message #667475] Thu, 28 April 2011 20:02 Go to next message
Raymond Mising name is currently offline Raymond Mising name
Messages: 59
Registered: July 2009
Member
Moved this topic from the PDE news group to here.

We have two plug-in A and B where B is the core plug-in which provide the main business logic. There are several library jars inside plugin B (B imported them). Let's say one jar has a package called a.b.c. In the plug-in.xml file of B we exposed the package a.b.c. Plugin A requires plug-in B and needs to refer to the classes in the package a.b.c. We tried two approaches:
1. In the plug-in.xml dependencies section of A, we added B. into the "Required Plug-ins". However, in a class in A, when we tried to import a class in package a.b.c, we got a java compiler error saying package a.b.c can not be solved.
2. In the plug-in.xml dependencies section of A, we added a.b.c into the "Imported Packages" (it showed up there). But still got the same error as the first approach.

Any idea what is wrong?

Thanks.
Re: Exposing packages from a jar inside a plug-in [message #667530 is a reply to message #667475] Fri, 29 April 2011 07:49 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 04/28/2011 08:02 PM, Raymond wrote:
> We have two plug-in A and B where B is the core plug-in which provide
> the main business logic. There are several library jars inside plugin B
> (B imported them). Let's say one jar has a package called a.b.c. In the
> plug-in.xml file of B we exposed the package a.b.c. Plugin A requires
> plug-in B and needs to refer to the classes in the package a.b.c.

What does the MANIFEST.MF of pluginB look like? What about the
MANIFEST.MF of pluginA, that requires the pluginB bundle?

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: Exposing packages from a jar inside a plug-in [message #668202 is a reply to message #667475] Wed, 04 May 2011 09:36 Go to previous messageGo to next message
Raymond Mising name is currently offline Raymond Mising name
Messages: 59
Registered: July 2009
Member
Sorry for later reply.
Manifest of A looks like:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: XXXXXX
Bundle-SymbolicName: A
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: XXXXXX
Require-Bundle: B,
......
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: Research In Motion Limited
Export-Package: net.rim.ajde.external
Bundle-ClassPath: apache-mime4j-0.6.jar,
httpclient-4.0.3.jar,
httpcore-4.0.1.jar,
httpmime-4.0.3.jar,
.

Manifest of B looks like:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: B
Bundle-SymbolicName: XXXXXXXX;singleton:=true
Bundle-Version: 11.0.0.qualifier
Bundle-Activator: XXXXXXXXXX
Bundle-Vendor: XXXXXXXXX
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
......
Bundle-ActivationPolicy: lazy
Export-Package: a.b.c,
......

Bundle-ClassPath: .,
libs/lib.jar,

Thanks.
Re: Exposing packages from a jar inside a plug-in [message #668215 is a reply to message #667475] Wed, 04 May 2011 10:19 Go to previous messageGo to next message
Martin Skorsky is currently offline Martin Skorsky
Messages: 112
Registered: July 2009
Senior Member
I remember that this was an issue with packed plug-ins. The compiler did not recognize the jars in bundle B unless this is deployed as a folder, not a jar.
Re: Exposing packages from a jar inside a plug-in [message #668234 is a reply to message #668202] Wed, 04 May 2011 11:31 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 05/04/2011 09:36 AM, Raymond wrote:
> Sorry for later reply.
> Manifest of A looks like:
> Require-Bundle: B,


> Manifest of B looks like:
> Manifest-Version: 1.0
> Bundle-ManifestVersion: 2
> Bundle-Name: B
> Bundle-SymbolicName: XXXXXXXX;singleton:=true
> Bundle-ActivationPolicy: lazy
> Export-Package: a.b.c,
> .....
> Bundle-ClassPath: .,
> libs/lib.jar,

I'll assume you matched your Require-Bundle: B to the real
Bundle-SymbolicName provided in B (your example, XXXXXXX :-)

That's all that is needed.

I created a plugin z.ex.jars.b with the following:
Bundle-ClassPath: libs/version_1.0.0.jar,
.
Export-Package: ex

Then a plugin z.ex.jars.a with:
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
z.ex.jars.b;bundle-version="1.0.0"

I was able to import ex.Version (from z.ex.jars.b) into
z.ex.jars.a.Activator with no problems.

Is your plugin B in your target platform (which might still be effected
by the problem Martin mentioned) or are they both in your workspace.

If they're both in your workspace, can you go to your plugin B project,
right click, and use PDE Tools>Update Classpath to make sure your
classpath is correct?

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: Exposing packages from a jar inside a plug-in [message #668387 is a reply to message #667475] Thu, 05 May 2011 10:03 Go to previous messageGo to next message
Raymond Mising name is currently offline Raymond Mising name
Messages: 59
Registered: July 2009
Member
I figured out the problem yesterday but not sure if it is an expected behavior or not. In the Bundle-ClassPath of plugin A actually looks like below ( I missed lib1.jar in my previous post):
Bundle-ClassPath: apache-mime4j-0.6.jar,
httpclient-4.0.3.jar,
httpcore-4.0.1.jar,
httpmime-4.0.3.jar,
lib1.jar

lib1.jar is a command line tool jar which requires those apache and http jars. So that in the manifest file of lib.jar, it claims:
Class-Path: ., apache-mime4j-0.6.jar,httpclient-4.0.3.jar,httpcore-4.0.1.ja r,httpmime-4.0.3.jar

This Class-Path definition seemed to ruin the classpath of plug-in A. I also noticed some resource folder of A was not shown in the package explore view. I manually remove this Class-Path element from the manifest of lib1.jar and refresh plug-in A, everything got back to normal. The classes in the exposed package from B can be seen in A and those disappeared resource folder were also back.

So, do you think this is an expected behavior?

Thanks.
Re: Exposing packages from a jar inside a plug-in [message #668391 is a reply to message #667475] Thu, 05 May 2011 10:06 Go to previous messageGo to next message
Raymond Mising name is currently offline Raymond Mising name
Messages: 59
Registered: July 2009
Member
Sorry some typo.

lib1.jar is a command line tool jar which requires those apache and http jars. So that in the manifest file of lib.jar, it claims:
Class-Path: ., apache-mime4j-0.6.jar,httpclient-4.0.3.jar,httpcore-4.0.1.ja r,httpmime-4.0.3.jar

The red part should be lib1.jar
Re: Exposing packages from a jar inside a plug-in [message #668475 is a reply to message #668387] Thu, 05 May 2011 15:06 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

It might be JDT reads Class-Path headers when jars are added to its
classpath (and that interferes with what PDE wants to set).

I'd open a bug at
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=PDE& component=UI

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: Exposing packages from a jar inside a plug-in [message #671336 is a reply to message #667475] Tue, 17 May 2011 10:52 Go to previous message
Raymond Mising name is currently offline Raymond Mising name
Messages: 59
Registered: July 2009
Member
Paul, the problem was not solved actually. Yes, the classpath entry in the manifest in the lib1.jar did ruined the classpath of the plug-in but that's not all. I got it work because I incidentally imported plug-in B into the same workspace as A. If I did not import B but installed B into the eclipse I was using, A still could not see the packages exposed by B. Also, in you test case
"I created a plugin z.ex.jars.b with the following:
Bundle-ClassPath: libs/version_1.0.0.jar,
.
Export-Package: ex"

Did you try to make z.ex.jars.b a jar; install it into eclipse and used it in A?

I think what Martin said "I remember that this was an issue with packed plug-ins. The compiler did not recognize the jars in bundle B unless this is deployed as a folder, not a jar." makes sense. Has this bug been fixed?

Thanks.
Previous Topic:(no subject)
Next Topic:Update Site manage Dependencies
Goto Forum:
  


Current Time: Mon Sep 01 19:46:51 EDT 2014

Powered by FUDForum. Page generated in 0.01877 seconds