469,323 Members | 1,611 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

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

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
3 11629
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
> 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
> 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.

Similar topics

2 posts views Thread by Roger | last post: by
17 posts views Thread by Aguilar, James | last post: by
6 posts views Thread by Pete Davis | last post: by
3 posts views Thread by Scott Langham | last post: by
3 posts views Thread by Peter Oliphant | last post: by
28 posts views Thread by larpup | last post: by
3 posts views Thread by downloads4birdman | last post: by
8 posts views Thread by =?Utf-8?B?TWFyaw==?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.