By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,541 Members | 1,109 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,541 IT Pros & Developers. It's quick & easy.

Loading Two Different Versions of the Same Class/JAR???

P: n/a
I'm trying to write an application that runs on an app server. The app
server uses an older version of a particular API. In my application I
need to use a newer version of the same API. If I put the JAR
containing the newer version of the API in my app server's classpath,
the app server fails. How do I load my own copy of this JAR?

-- John
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
John Davison wrote:
I'm trying to write an application that runs on an app server. The app
server uses an older version of a particular API. In my application I
need to use a newer version of the same API. If I put the JAR
containing the newer version of the API in my app server's classpath,
the app server fails. How do I load my own copy of this JAR?


Use an URLClassLoader.
Jul 17 '05 #2

P: n/a
> I'm trying to write an application that runs on an app server. The app
server uses an older version of a particular API. In my application I
need to use a newer version of the same API. If I put the JAR
containing the newer version of the API in my app server's classpath,
the app server fails. How do I load my own copy of this JAR?

-- John


Hi John,

You should'nt add your application specific jar in the apps server
classpath. Most app server provide a method to include the jar file
only for the context of your application. Usually (at least in tomcat)
you put the jar file in WEB-INF/lib directory of your context. In
tomcat if you want to use a jar across multiple contexts, the place to
put the jar is $CATALINA_TOP/shared/lib.

If this does not help, then the only way out would be to write your
own ClassLoader and load the target classes and all other classes that
use them through this ClassLoader. But this method has its own
disadvantages. You will loose the benifits, like dynamic reloading
etc, that the apps server ClassLoader would provide you.

Regards

Amitabh
Jul 17 '05 #3

P: n/a
> I'm trying to write an application that runs on an app server. The app
server uses an older version of a particular API. In my application I
need to use a newer version of the same API. If I put the JAR
containing the newer version of the API in my app server's classpath,
the app server fails. How do I load my own copy of this JAR?

-- John


Hi John,

You should'nt add your application specific jar in the apps server
classpath. Most app server provide a method to include the jar file
only for the context of your application. Usually (at least in tomcat)
you put the jar file in WEB-INF/lib directory of your context. In
tomcat if you want to use a jar across multiple contexts, the place to
put the jar is $CATALINA_TOP/shared/lib.

If this does not help, then the only way out would be to write your
own ClassLoader and load the target classes and all other classes that
use them through this ClassLoader. But this method has its own
disadvantages. You will loose the benifits, like dynamic reloading
etc, that the apps server ClassLoader would provide you.

Regards

Amitabh
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.