3 Replies Latest reply on Jun 29, 2011 5:18 AM by jaikiran pai

    JBoss AS 5.1 + JPA 2.0 class loading issue

    David Jitendranath Novice

      I am attempting to run a JPA 2.0 application on JBoss AS 5.1 server with the JPA 2.0 jars bundled in my WAR.

      Somehow when I deploy the app, the web-inf/lib jpa2.0 jars are ignored and JBoss's libraries are being used by the classloader.

      Can someone help me please in pointing out what I'm missing or how I can accomplish what I'm trying to do here?

       

      Below are my configuration changes to have JBoss's class loader user my bundled JPA 2.0 jars.

       

      The JPA 2.0 libraries are in the WEB-INF/lib of my exploded WAR app.  Below are the JPA 2.0 jars that are packaged.

       

      -rw-rw-rw-   1 user group  365546 Jun 23 13:22 hibernate-annotations-3.5.6-Final.jar
      -rw-rw-rw-   1 user group    6412 Jun 23 13:21 hibernate-c3p0-3.6.5.Final.jar
      -rw-rw-rw-   1 user group   66426 Jun 23 13:21 hibernate-commons-annotations-3.3.0.ga.jar
      -rw-rw-rw-   1 user group 3113051 Jun 23 13:21 hibernate-core-3.6.5.Final.jar
      -rw-rw-rw-   1 user group  421562 Jun 23 13:21 hibernate-entitymanager-3.6.5.Final.jar
      -rw-rw-rw-   1 user group  100884 Jun 23 13:21 hibernate-jpa-2.0-api-1.0.0.Final.jar
      -rw-rw-rw-   1 user group 

      226805 Jun 23 13:22 hibernate-validator-4.0.2.GA.jar

      -rw-rw-rw-   1 user group   25496 Jun 23 13:22 slf4j-api-1.6.1.jar
      -rw-rw-rw-   1 user group    9753 Jun 23 13:21 slf4j-log4j12-1.6.1.jar

       

      following this thread... http://community.jboss.org/thread/159628

      1) I have also added the persistence_2_0.xsd to <JBOSS5.1>/docs/schema directory

      2) Added the below entry in JBOSS_51_INSTALL_DIR>/server/default/deployers/metadata-deployer-jboss-beans.xml


      <entry> 
               <key>persistence_2_0.xsd</key> 
               <value>org.jboss.metadata.jpa.spec.PersistenceMetaData</value> 
      </entry>
      

       

      3) In my App.war/WEB-INF/jboss-classloading.xml file I have the below entry.

       

      <?xml version="1.0" encoding="UTF-8"?>
      <classloading xmlns="urn:jboss:classloading:1.0" 
                     parent-first="false" 
                     domain="DefaultDomain" 
                     top-level-classloader="true" 
                     parent-domain="Ignored" 
                     export-all="NON_EMPTY" 
                     import-all="true">  
      </classloading>
      

       

      4) Also in my App.war/WEB-INF/jboss-web.xml  I have

       

      <?xml version="1.0" encoding="UTF-8"?>
      <jboss-web>
          <resource-ref>
              <res-ref-name>jdbc/globalDS</res-ref-name>
              <res-type>javax.sql.DataSource</res-type>
              <jndi-name>java:/jdbc/globalDS</jndi-name>
          </resource-ref>
          <context-root>/</context-root>
           <class-loading java2ClassLoadingCompliance="false">
            <loader-repository>com.rtddenver:laoder=ties2.war
               <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
            </loader-repository>
         </class-loading> 
      </jboss-web>
      

       

      When I run the App to execute a CriteriaBuilder query...I get the following error in the logs....leading me to believe that JBoss is using the older JPA.

       

      Caused by: java.lang.NoSuchMethodError: javax.persistence.EntityManager.getCriteriaBuilder()Ljavax/persistence/criteria/CriteriaBuilder;
          at com.rtddenver.dao.jpa.TiesExtraboardRunsAvailVwDaoJpa.getAmAvailableRunsByDivision(TiesExtraboardRunsAvailVwDaoJpa.java:28)
          at com.rtddenver.gwt.server.TiesRunsServiceImpl.getExtraBoardRunsByDivision(TiesRunsServiceImpl.java:65)
      

       

      Also below are the log messages when the persistence unit is loaded on deployment..

       

      15:18:00,651 INFO  [PersistenceUnitDeployment] Starting persistence unit persistence.unit:unitName=#ties-2
      15:18:01,697 INFO  [Version] Hibernate Annotations 3.4.0.GA
      15:18:01,697 INFO  [Version] Hibernate Annotations 3.4.0.GA
      15:18:01,979 INFO  [Environment] Hibernate 3.3.1.GA
      15:18:01,979 INFO  [Environment] Hibernate 3.3.1.GA
      15:18:02,026 INFO  [Environment] hibernate.properties not found
      15:18:02,026 INFO  [Environment] hibernate.properties not found
      15:18:02,026 INFO  [Environment] Bytecode provider name : javassist
      15:18:02,026 INFO  [Environment] Bytecode provider name : javassist
      15:18:02,041 INFO  [Environment] using JDK 1.4 java.sql.Timestamp handling
      15:18:02,041 INFO  [Environment] using JDK 1.4 java.sql.Timestamp handling
      15:18:02,276 INFO  [Version] Hibernate Commons Annotations 3.1.0.GA
      15:18:02,276 INFO  [Version] Hibernate Commons Annotations 3.1.0.GA
      15:18:02,307 INFO  [Version] Hibernate EntityManager 3.4.0.GA
      15:18:02,307 INFO  [Version] Hibernate EntityManager 3.4.0.GA