Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Ensuring a class or jar takes precedence(Ensuring a class or jar takes precedence)
Ensuring a class or jar takes precedence [message #514965] Wed, 17 February 2010 06:12 Go to next message
breako  is currently offline breako
Messages: 57
Registered: July 2009
Member
Hi,
Suppose I have two versions of the same jar on my classpath.
One in my WEB-INF/lib directory which gets picked up automatically and one is an upgraded version of the same jar (say a bug fix) which gets picked up from an external location.

How do I ensure one jar will always take precedence? Same question for classes? And similar question when a class in a jar in my web-info/lib gets updated. I want to ensure the class that I add as an external class gets precedence over the class name that is in an existing jar?

Thanks.

[Updated on: Wed, 17 February 2010 06:14]

Report message to a moderator

Re: Ensuring a class or jar takes precedence [message #515005 is a reply to message #514965] Wed, 17 February 2010 08:31 Go to previous messageGo to next message
Mauro Molinari is currently offline Mauro Molinari
Messages: 278
Registered: July 2009
Senior Member
Il 17/02/2010 12.12, breako ha scritto:
> Hi,
> Suppose I have two versions of the same jar on my classpath.
> One in my WEB-INF/lib directory which gets picked up automatically and
> one is an upgraded version of the same jar (say a bug fix) which gets
> picked up from an external location.
>
> How do I ensure one jar will always take precedence? Same question for
> classes?

Try this: right click on your project, Properties | Java Build Path |
Order and Export.

Mauro.
Re: Ensuring a class or jar takes precedence [message #515041 is a reply to message #515005] Wed, 17 February 2010 09:39 Go to previous message
breako  is currently offline breako
Messages: 57
Registered: July 2009
Member
Mauro Molinari wrote on Wed, 17 February 2010 08:31
Il 17/02/2010 12.12, breako ha scritto:
> Hi,
> Suppose I have two versions of the same jar on my classpath.
> One in my WEB-INF/lib directory which gets picked up automatically and
> one is an upgraded version of the same jar (say a bug fix) which gets
> picked up from an external location.
>
> How do I ensure one jar will always take precedence? Same question for
> classes?

Try this: right click on your project, Properties | Java Build Path |
Order and Export.

Mauro.

Thanks Mauro,
That only allows you to order libraries. Which begs the question how do you order within a library or how do you create or change your library?

Also, you can have libraries on the order list which you never build but that you still use at runtime.

I think the order tab you refer to is only for building - not for anything at runtime.

Comments appreciated.
Re: Ensuring a class or jar takes precedence [message #515054 is a reply to message #515005] Wed, 17 February 2010 05:22 Go to previous message
Larry Isaacs is currently offline Larry Isaacs
Messages: 1305
Registered: July 2009
Senior Member
Mauro Molinari wrote:
> Il 17/02/2010 12.12, breako ha scritto:
>> Hi,
>> Suppose I have two versions of the same jar on my classpath.
>> One in my WEB-INF/lib directory which gets picked up automatically and
>> one is an upgraded version of the same jar (say a bug fix) which gets
>> picked up from an external location.
>>
>> How do I ensure one jar will always take precedence? Same question for
>> classes?
>
> Try this: right click on your project, Properties | Java Build Path |
> Order and Export.
>
> Mauro.

I'm not sure to what degree this use case is supported. Generally,
incorporating an ambiguity like this into your project is likely to get
you into trouble at some point. For example, there is build-time
precedence and runtime precedence. With an ambiguity like this, it
becomes much easier to get the project into a state that builds fine,
but has problems at runtime.

My guess is the the Order and Export that Mauro suggests will affect the
build-time precedence, but will likely not affect the runtime
precedence. A simple test suggests the runtime precedence will be
controlled by the Java EE Module Dependencies page. If the jar is
checked there, that jar will take precedence over the jar in
WEB-INF/lib. If not checked, you will get the one on WEB-INF/lib.

With respect to classes instead of jars, I'm not clear on where these
classes are between which you are trying to control the precedence.

Cheers,
Larry
Previous Topic:JSP EL Support - why to invent the wheel again?
Next Topic:Resolving HTML, JSP, and XML Schema Problems
Goto Forum:
  


Current Time: Wed Aug 20 06:57:39 EDT 2014

Powered by FUDForum. Page generated in 0.01850 seconds