Connecting Tech Pros Worldwide Forums | Help | Site Map

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

John Davison
Guest
 
Posts: n/a
#1: Jul 18 '05
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

Michael Borgwardt
Guest
 
Posts: n/a
#2: Jul 18 '05

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


John Davison wrote:
[color=blue]
> 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?[/color]

Use an URLClassLoader.
Amitabh
Guest
 
Posts: n/a
#3: Jul 18 '05

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


> I'm trying to write an application that runs on an app server. The app[color=blue]
> 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[/color]

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
Amitabh
Guest
 
Posts: n/a
#4: Jul 18 '05

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


> I'm trying to write an application that runs on an app server. The app[color=blue]
> 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[/color]

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
Closed Thread