6 Replies Latest reply on Jun 10, 2013 10:43 AM by Julien Kronegg

    jboss 5.1.0.GA class loading, parent last

    Charlie Yang Novice

      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"
          <!--<class-loading java2ClassLoadingCompliance="true"/>-->
          <class-loading java2ClassLoadingCompliance="false">


      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).


      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


      <class-loading java2ClassLoadingCompliance="true"/>

      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.


      Any ideas?


      Attached is error log for your reference.

      Thanks in advance.