Explanation of class loading in an EAR for non-requested but dependent class

社会主义新天地 提交于 2019-12-08 00:51:43

问题


I'm trying to track down a problem I'm having in WAS 6.1 with AXIS 1 and Commons Logging. My EAR is set to parent last. In the ear is commons-logging, Axis and a client jar that uses Axis. The classes in the client jar are called from a WAR.

The WAR calls the client, which calls the axis jar, which needs commons-logging. But it does not appear as if the EAR is loading commons-logging from itself. It looks like commons-logging is coming from WebSphere.

Then another class in the WAR directly asks for commons-logging and the EAR appears to be loading it. As a result I'm getting this error: org.apache.commons.logging.impl.LogFactoryImpl incompatible with org.apache.commons.logging.LogFactory

Is there anything I can do to prevent this? Am I reading the situation wrong?


回答1:


Since both commons-logging and Axis 1 are built into WAS 6.1, I'd try to remove them from the EAR and WARs entirely; you could then set your classloader policy to the default "PARENT_FIRST", which is certainly more robust.

You'll still need Axis and jcl to compile your code, so only eliminate them from the EAR. If you use Maven, that would mean changing their scope to "provided", with Ant that would be constructing the jar list separately for the ear task, with Eclipse EAR project — removing appropriate jars from the Deployment Assembly.

I'd be grateful for a short info how you did.



来源:https://stackoverflow.com/questions/7691377/explanation-of-class-loading-in-an-ear-for-non-requested-but-dependent-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!