Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I manage the ClassPath in WebSphere

Tags:

java

websphere

I have a problem with my web module classpath in Websphere v6.1.

In my WEB-INF/lib I have a largish number of jar files which include xercesImpl.jar and xmlparserv2.jar. I need both jars to be present, but they appear to confict with each other. Specifically, each jar contains a META-INF/services directory so, when we try to get an instance of a DocumentBuilderFactory via JAXP, which instance we get depends upon the order in which these two jars appear in the classpath.

I always want to use the xerces instance of the DocumentBuildFactory, so I want to push xercesImpl.jar to the front of the classpath. I've tried to do this by specifying a Class-Path section in the Manifest file for the war file, but the class path that I actually get in my WAS Module Compound CLass Loader in is very strange. I seem to get some standard stuff that WAS puts on, followed by the contents of WEB-INF lib in alphabetical order, followed by the classpath specified by the Manifest file.

If I don't put a manifest file into the war at all, I get the standard stuff followed by the contents of WEB-INF/lib but in an arbitrary order.

What am I missing? Is there a way in which I can set the class path up to be exactly what I want?

Dave

like image 396
DaveH Avatar asked Jan 09 '09 12:01

DaveH


People also ask

How to set Classpath in WebSphere?

Log into the IBM WebSphere Application Server administrative console. Click Server > Application Servers and select the server_name . In the Configuration tab, navigate to Server Infrastructure > Java and Process Management > Process Definition > Servant > Java Virtual Machine. Edit the field Classpath.

How to add jar file to Classpath in WebSphere?

If you are running IBM WebSphere Application Server as an alternative, you can also add the JAR file directly from the WebSphere Application Server administrative console by using the following path: Application servers > servername > Process Definition > Java Virtual Machine > Classpath.

What is class loader policy in WebSphere?

The application class-loader policy controls the isolation of applications that run in the system (on the server). An application class loader groups enterprise bean (EJB) modules, shared libraries, resource adapter archives (RAR files), and dependency Java™ archive (JAR) files associated to an application.


1 Answers

I assume by WebSphere, you mean the regular J2EE Application Server (and not something like Community Edition; WebSphere is a brand name applied to a number of IBM products).

I think your options are limited. Since the dependencies look quite explicit, I would prefer a programmatic approach rather than relying on the vagaries of the classpath (like creating factory instances explicitly rather than relying on the SPI).

If that isn't an option, you might want to look at making one of your dependencies an EAR project utility JAR and configure MODULE classloading with a PARENT_LAST classloading policy on the WAR. This can be configured via the browser admin console (or via the RAD tooling if you use it).

Another thing I'd look at is the WAS Shared Libraries feature (under Environment in the browser admin console). These can be associated with servers or applications. The downside is that this requires more configuration.

like image 109
McDowell Avatar answered Oct 02 '22 04:10

McDowell