Hi, I worked with a legacy app(WAR) these days. It works fine on Tomcat and Websphere(with parent last class loading). But when I deploy it on JBoss 5.1.0.GA, trouble comes.
My WAR contains some JARs which also shipped with JBoss, such as persistence api, hibernate*, jsf*...
I know it's class loading issue, I want my WAR use JARs under its own WEB-INF/lib. I searched on the internet for a solution, but I didn't work it out.
I read this article (ClassLoadingConfiguration) and tried, but not work.
According to the article, I add the class loading config in the jboss-web.xml:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 5.0//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd"> <jboss-web> <!--<class-loading java2ClassLoadingCompliance="true"/>--> <class-loading java2ClassLoadingCompliance="false"> <loader-repository> com.example:loader=3plweb.war <loader-repository-config> java2ParentDelegation=false </loader-repository-config> </loader-repository> </class-loading> <context-root>3plweb</context-root> </jboss-web>
this should use the parent last policy to load classes. But the conflict remains, ClassCastException was thrown(and some other exceptions that also caused by conflict).
java.lang.ClassCastException: org.hibernate.ejb.HibernatePersistence cannot be cast to javax.persistence.spi.PersistenceProvider
ejb3-persistence-api.jar in my WAR conflicts with that in JBoss's common/lib
and I tried
It works, but it use parent first policy, and hibernate*.jar/jsf*.jar/... in my WAR are not load. That's not what I want.
Attached is error log for your reference.
Thanks in advance.