Question

To summarize the issue I'm encountering, I have an EJB which uses version A of a library (let's call it dep-vA.jar). dep-vA.jar is packaged in the root of the EJB's jar file. The domain lib folder in the application server contains version B of the same library (let's call it dep-vB.jar). When calling the EJB, I get an error due to dep-vB.jar file being loaded rather than dep-vA.jar.

I guess the first part of this question is, does Sun One Application Server v9.1 isolate EJBs from each other? I was under the impression that it does. But it seems like another application loaded dep-vB.jar and this EJB is directly using it without loading its own.

The second question is, if the app server does isolate EJBs, does it load dependencies from the EJB's jar file before looking in the application server's lib folders? I was under the impression that this is also true, but maybe not...

Is anyone familiar enough with Sun application servers to explain why dep-vB.jar is being loaded rather than dep-vA.jar? Is there any way to get it to load dep-vA.jar without changing what's in the application server's lib folders? (I would hesitate to do anything that might affect other applications on the server)

Thanks.

Was it helpful?

Solution

I guess the first part of this question is, does Sun One Application Server v9.1 isolate EJBs from each other? I was under the impression that it does. But it seems like another application loaded dep-vB.jar and this EJB is directly using it without loading its own.

According to Sahoo (which is a GlassFish developer), the Java EE spec does not mandate class loading isolation among modules of a single ear so the behavior can be different from one app server to another. With Sun ONE, my understanding of the documentation is that EJB-JARs are isolated.

The second question is, if the app server does isolate EJBs, does it load dependencies from the EJB's jar file before looking in the application server's lib folders? I was under the impression that this is also true, but maybe not...

It's a parent-first strategy (and to my knowledge, Sun ONE allows to change the delegating mode for webapps only).

That being said, what happens if you list dep-vA.jar in the Class-Path entry of the MANIFEST.MF of the EJB-JAR?

See also

OTHER TIPS

I haven't used that particular server, but I do know that in WebSphere, there is an option to use PARENT_FIRST or PARENT_LAST classloading. You would be looking for an equivalent of PARENT_LAST where the classes are loaded from the EAR first before going up to the server.

I would assume that such a configuration is possible in any app server, as you should always be able to enforce your application specific jars to be loaded over any others.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top