Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Eclipse (Juno) shows an error where there is none(Eclipse (Juno) shows an error where there is none)
Eclipse (Juno) shows an error where there is none [message #1236667] Mon, 27 January 2014 20:21 Go to next message
Kevin Meek is currently offline Kevin MeekFriend
Messages: 5
Registered: January 2014
Junior Member
I have some code:

import javax.ws.rs.core.Response;    //version 2.0
public class MarketPlace {
	
     public MarketPlaceResponse getParameters () {
		Response r;
		r.readEntity(MarketPlaceResponse.class);    //this shows as an error
     }
}

And the readEntity call shows an error "undefined for the type Response". But it compiles fine, it compiles in Maven fine and runs fine. Also the context sensitive help only shows some functions of the Response class not all of them.

Why is this happening?

I've included a small image of the issue and another of the quick fix bubble.

Thanks,
Kevin

Re: Eclipse (Juno) shows an error where there is none [message #1236672 is a reply to message #1236667] Mon, 27 January 2014 20:36 Go to previous messageGo to next message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 2406
Registered: July 2009
Senior Member
Check what version of the jaxrs library you have on the project's build path. The method Response.readEntity() was added in version 2.0 (JEE 7) but was absent in earlier versions (for example, JEE 6).
Re: Eclipse (Juno) shows an error where there is none [message #1236687 is a reply to message #1236672] Mon, 27 January 2014 21:32 Go to previous messageGo to next message
Kevin Meek is currently offline Kevin MeekFriend
Messages: 5
Registered: January 2014
Junior Member
Wow, didn't expect such a quick response - thanks

No - I've set up for Java 7 and jaxrs 2.0 as seen in the crop image attached

Also I can open the jar source files (in the maven .m2 directory) and see files there (attached) which has the readEntity there.

Kevin
Re: Eclipse (Juno) shows an error where there is none [message #1236689 is a reply to message #1236687] Mon, 27 January 2014 21:37 Go to previous messageGo to next message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 2406
Registered: July 2009
Senior Member
The screen shot of your build path looks correct. What do you get if you put the cursor on the Response class in your code and use F3 to "go into" that class?
Re: Eclipse (Juno) shows an error where there is none [message #1236693 is a reply to message #1236689] Mon, 27 January 2014 21:50 Go to previous messageGo to next message
Kevin Meek is currently offline Kevin MeekFriend
Messages: 5
Registered: January 2014
Junior Member
oohhh - that very interesting. It says it can't find it and is reverting to v1.6 (attached). I guess it's trying to be helpful, but is in effect masking an issue.

K
Re: Eclipse (Juno) shows an error where there is none [message #1236694 is a reply to message #1236693] Mon, 27 January 2014 21:52 Go to previous messageGo to next message
Kevin Meek is currently offline Kevin MeekFriend
Messages: 5
Registered: January 2014
Junior Member
It seems to be complaining about my jersey core 1.17. Let me work on changing that and get back to you.

K
Re: Eclipse (Juno) shows an error where there is none [message #1236696 is a reply to message #1236694] Mon, 27 January 2014 21:56 Go to previous messageGo to next message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 2406
Registered: July 2009
Senior Member
There's your problem: Jersey 1.17 includes an old version of the Response class. Look at http://grepcode.com/search/?query=javax.ws.rs.Response
So your build path (your Maven dependencies) includes multiple versions of the jaxrs library and Eclipse is picking up the Jersey version "first."
Re: Eclipse (Juno) shows an error where there is none [message #1236701 is a reply to message #1236694] Mon, 27 January 2014 22:10 Go to previous messageGo to next message
Kevin Meek is currently offline Kevin MeekFriend
Messages: 5
Registered: January 2014
Junior Member
OK - found the issue - thanks Eric for pointing me in the right direction.

Seems that maven can look at all the jar files and open all the classes to find which jar files. But once eclipse finds a Class with the same name (doesn't seem to matter that the class is in a different package or not) it stops looking. Even when I downloaded the latest jersey files eclipse didn't like it.

BUT, I then change the order of the maven dependencies so that the jax-rs libs were first and the jersey libs were last and everything is looking good.

Is there a way to tell eclipse to look at all the libs and check for the best file, or enforce the package check or something?

Thanks,
Kevin
Re: Eclipse (Juno) shows an error where there is none [message #1236704 is a reply to message #1236701] Mon, 27 January 2014 22:21 Go to previous message
David Wegener is currently offline David WegenerFriend
Messages: 1351
Registered: July 2009
Senior Member
Eclipse does enforce package names. Eclipse will only resolve to the fully qualified name which includes the package. Apparently the Jersey jar file includes the exact same fully qualified Response class as the one in Java EE. Classpaths don't provide a way to specify versions, so classpaths will resolve the first fully qualified class that matches. This generally means that the version in the first jar containing the class wins.
Previous Topic:Source Code for Eclipse 4.3.1
Next Topic:Plugin for inline expansion of method calls?
Goto Forum:
  


Current Time: Thu Dec 18 04:12:40 GMT 2014

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

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