Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » .classpath question: org.eclipse.jst.j2ee.internal.web.container(Behavior when overriding jar dependencies from required projects)
.classpath question: org.eclipse.jst.j2ee.internal.web.container [message #1059097] Thu, 16 May 2013 16:31 Go to next message
Craig Whynot is currently offline Craig WhynotFriend
Messages: 3
Registered: May 2013
Junior Member
Hello,

I need a specific version of two jars in order to run a driver (Selenium) from inside of Eclipse:

httpclient-4.2.1,
httpcore-4.2.1

I have required projects on my classpath which specify an older version of these jars (4.0). I can't modify these projects to reference the newer jars without refactoring / requiring regression testing, etc.

When I run my Selenium driver inside of Eclipse I get NoSuchMethodError because the older jar versions (4.0) are being selected by the classloader.

The only solution that I've stumbled upon is to move the .classpath entries for the desired jars ABOVE the org.eclipse.jst.j2ee.internal.web.container declaration like this:

<classpath>
...
<classpathentry kind="lib" path="ivy/lib/ide/httpclient-4.2.1.jar"/>
<classpathentry kind="lib" path="ivy/lib/ide/httpcore-4.2.1.jar"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
...
</classpath>

This appears to automagically allow eclipse to load the 4.2.1 versions, when otherwise the 4.0 versions would be loaded.
Can someone please explain exactly how and why this works?
To recap: when running an application inside of eclipse, specifying specific jars via a classpathentry above the internal.web.container entry appears to allow the specified version to trump other jar versions on the classpath.
Thanks very much in advance; I would love to be able to sell this solution to my team by explaining how the heck it works Smile
Re: .classpath question: org.eclipse.jst.j2ee.internal.web.container [message #1059801 is a reply to message #1059097] Tue, 21 May 2013 16:21 Go to previous messageGo to next message
Craig Whynot is currently offline Craig WhynotFriend
Messages: 3
Registered: May 2013
Junior Member
It would be greatly appreciated if I could get an explanation as to why my previously mentioned fix (moving classpath entries above <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/> works. Thanks in advance!
Re: .classpath question: org.eclipse.jst.j2ee.internal.web.container [message #1060463 is a reply to message #1059801] Fri, 24 May 2013 20:16 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4425
Registered: July 2009
Senior Member

Different projects for different applications can use different versions of libraries in Eclipse without issue. Are the other projects that require 4.0 at all related to your dynamic web project?

Your fix works simply because the order of entries in your Java Build Path affects their order in the runtime classpath.


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: .classpath question: org.eclipse.jst.j2ee.internal.web.container [message #1060826 is a reply to message #1060463] Tue, 28 May 2013 14:32 Go to previous message
Craig Whynot is currently offline Craig WhynotFriend
Messages: 3
Registered: May 2013
Junior Member
Nitin you've answered my question; I was hoping that this fix simply asserted the jar order in my project's classpath.

Basically I have two eclipse projects which are common code repositories. These two projects use the 4.0 versions of httpclient / core jars. Several dynamic web projects reference these two common projects, pulling in their class paths.

It sounds like my fix is simply allowing me to give specific jar versions higher priority by moving them before the jars pulled in from the referenced projects' classpaths.

Thanks for the reply!

Previous Topic:Problem adding tomcat6 server instance back in eclipse
Next Topic:[JSDT] Please make InferredType.java implements Interface.
Goto Forum:
  


Current Time: Tue Mar 19 05:19:45 GMT 2024

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

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

Back to the top