Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Class cannot be resolved to a type
Class cannot be resolved to a type [message #461380] Wed, 10 January 2007 09:37 Go to next message
Gavin Bong is currently offline Gavin BongFriend
Messages: 23
Registered: July 2009
Junior Member
Context: Eclipse 3.2.1

In Bundle <b>A</b>, a class <b>Foo</b> extends an interface <b>IFace</b> exported by bundle <b>B</b>. However, eclipse is complaining within the editor of <b>Foo</b>, that <i>IFace cannot be resolved to a type</i>.

Strangely,

1) Bundle B explicitly exports <b>IFace</b>.
<i>IFace.class</i> resides in a jar file called commons.jar
in the package "commons".

e.g. a snippet of the MANIFEST.MF for bundle B.

Bundle-Classpath: .,lib/commons.jar
Export-Package: commons

2) Bundle A explicitly imports the "commons" package.

e.g. a snippet of the MANIFEST.MF for bundle A.

Import-Package: commons

e.g. Snippet of class Foo:

public class Foo implements IFace
{
...
}

If I do a CTRL+Shift+T, the PDE correctly resolves to the IFace.class file in <i>commons.jar</i>. So it's very strange that eclipse cannot resolve <b>IFace</b> in the plugin project for Bundle A. I have cleaned the projects, exited eclipse and restarted and the error is still there. Anybody can point me in the right direction.
Re: Class cannot be resolved to a type [message #461384 is a reply to message #461380] Wed, 10 January 2007 09:52 Go to previous messageGo to next message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
Check to see if the lib/commons.jar is exported from the A project. I seem to recall that in this scenario, you need to add lib/commons.jar as a Jar, and then ensure that it is exported, in order for it to be visible to dependent projects.

Alex.
Re: Class cannot be resolved to a type [message #461497 is a reply to message #461380] Wed, 10 January 2007 17:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wegener.cboenospam.com

Gavin Bong wrote:

> Context: Eclipse 3.2.1

> In Bundle <b>A</b>, a class <b>Foo</b> extends an interface <b>IFace</b>
exported by bundle <b>B</b>. However, eclipse is complaining within the editor
of <b>Foo</b>, that <i>IFace cannot be resolved to a type</i>.

> Strangely,

> 1) Bundle B explicitly exports <b>IFace</b>.
> <i>IFace.class</i> resides in a jar file called commons.jar
> in the package "commons".

> e.g. a snippet of the MANIFEST.MF for bundle B.

> Bundle-Classpath: .,lib/commons.jar
> Export-Package: commons

> 2) Bundle A explicitly imports the "commons" package.

> e.g. a snippet of the MANIFEST.MF for bundle A.

> Import-Package: commons

> e.g. Snippet of class Foo:

> public class Foo implements IFace
> {
> ...
> }

> If I do a CTRL+Shift+T, the PDE correctly resolves to the IFace.class file
in <i>commons.jar</i>. So it's very strange that eclipse cannot resolve
<b>IFace</b> in the plugin project for Bundle A. I have cleaned the projects,
exited eclipse and restarted and the error is still there. Anybody can point
me in the right direction.


Does bundle A explicitly depend on bundle B. This would be on
Require-Bundle line of bundle A's manifest.
Re: Class cannot be resolved to a type [message #461555 is a reply to message #461384] Fri, 12 January 2007 05:05 Go to previous messageGo to next message
Gavin Bong is currently offline Gavin BongFriend
Messages: 23
Registered: July 2009
Junior Member
There's a couple of mistakes in my problem description.

1) In my original post, I said that CTRL+Shift+T will resolve to <i>IFace</i>. I'm wrong, it does not. It is not even listed in the list of suggested classes.

In addition to the error <i>IFace cannot be resolved to a type</i>, I am getting <i>Package commons cannot be resolved</i>.

2) Bundle B which exports package <i>commons</i> does not exist as an opened project in the same workspace. In fact, it exists as an exported plugin jar inside my <b>target-platform</b> directory.

So, if the project for Bundle B is opened in the workspace, there are no errors. But when it is closed and I depend solely on the exported jar in the <b>target-platform</b> directory, the error appears.


I did a little experiment. I created a launch configuration:
workspace plugins := bundle A
target plugins := bundle B, osgi-framework

When I run it, it works fine. Everything is resolved!


Perhaps I do not understand the actual utility of the target-platform. The definition from the HELP file:

<i>Target Platform refers to the platform against which you are developing and testing your plug-ins</i>.

I expected that the PDE would read the MANIFEST.MF file from all plugins in the target platform & add IFace to my build path for Bundle A. Obviously it does not. So like you (Alex) said, I will have to add the commons.jar into Bundle A's project build path; which kinda sucks.

@Dave, a Require-Bundle is basically equivalent to multiple Import-Package as this blogpost http://www.osgi.org/blog/2006/04/misconceptions-about-osgi-h eaders.html suggests.
Re: Class cannot be resolved to a type [message #461601 is a reply to message #461555] Sat, 13 January 2007 05:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wegener.cboenospam.com

Gavin Bong wrote:
> There's a couple of mistakes in my problem description.
>
> 1) In my original post, I said that CTRL+Shift+T will resolve to <i>IFace</i>. I'm wrong, it does not. It is not even listed in the list of suggested classes.
>
> In addition to the error <i>IFace cannot be resolved to a type</i>, I am getting <i>Package commons cannot be resolved</i>.
>
> 2) Bundle B which exports package <i>commons</i> does not exist as an opened project in the same workspace. In fact, it exists as an exported plugin jar inside my <b>target-platform</b> directory.
>
> So, if the project for Bundle B is opened in the workspace, there are no errors. But when it is closed and I depend solely on the exported jar in the <b>target-platform</b> directory, the error appears.
>
>
> I did a little experiment. I created a launch configuration:
> workspace plugins := bundle A
> target plugins := bundle B, osgi-framework
>
> When I run it, it works fine. Everything is resolved!
>
>
> Perhaps I do not understand the actual utility of the target-platform. The definition from the HELP file:
>
> <i>Target Platform refers to the platform against which you are developing and testing your plug-ins</i>.
>
> I expected that the PDE would read the MANIFEST.MF file from all plugins in the target platform & add IFace to my build path for Bundle A. Obviously it does not. So like you (Alex) said, I will have to add the commons.jar into Bundle A's project build path; which kinda sucks.
>
> @Dave, a Require-Bundle is basically equivalent to multiple Import-Package as this blogpost http://www.osgi.org/blog/2006/04/misconceptions-about-osgi-h eaders.html suggests.

First, make sure that your plugin is checked in the Target Platform
properties. Then, open up the manifest file in the Plugin Manifest
Editor. Go to the Dependencies tab. Scroll down and open the Automated
Management of Dependencies section. Select the appropriate radio button
at the bottom and click the add dependencies text. This should insure
that your dependencies are correct.

Go to the General tab, Click the Update the classpath and the compiler
compliance settings. This should make sure that your build classpath is
up to date.
Re: Class cannot be resolved to a type [message #461630 is a reply to message #461601] Mon, 15 January 2007 03:37 Go to previous message
Gavin Bong is currently offline Gavin BongFriend
Messages: 23
Registered: July 2009
Junior Member
@Dave,

I followed your instructions. The plugin in the target is checked. When I clicked on "add dependencies" link, a dialog saying "No dependencies was found". Nothing was added.

To reiterate my situation, a launch configuration with the bundle (with compile errors) will run fine when launched. However, within the eclipse workspace, it flags a compile error. What gives?

Thanks

Gavin
Previous Topic:Executing an RCP application from a single JAR/ZIP file?
Next Topic:How to add additional CoolBar?
Goto Forum:
  


Current Time: Thu Apr 25 06:57:07 GMT 2024

Powered by FUDForum. Page generated in 0.03862 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top