Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (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 11:12 Go to next message
breako  is currently offline breako Friend
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 11: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 13:31 Go to previous messageGo to next message
Mauro Molinari is currently offline Mauro MolinariFriend
Messages: 285
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 14:39 Go to previous message
breako  is currently offline breako Friend
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 10:22 Go to previous message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
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: Fri Apr 19 20:55:37 GMT 2024

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

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

Back to the top