|Ensuring a class or jar takes precedence [message #514965]
||Wed, 17 February 2010 11:12
Registered: July 2009
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?
[Updated on: Wed, 17 February 2010 11:14]
Report message to a moderator
|Re: Ensuring a class or jar takes precedence [message #515054 is a reply to message #515005]
||Wed, 17 February 2010 10:22
| Larry Isaacs
Registered: July 2009
Mauro Molinari wrote:|
> Il 17/02/2010 12.12, breako ha scritto:
>> 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
> Try this: right click on your project, Properties | Java Build Path |
> Order and Export.
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.
Powered by FUDForum
. Page generated in 0.02339 seconds