1 Reply Latest reply on Dec 8, 2010 3:48 AM by jaikiran pai

    JPA 2 support in JBoss

    Rajan Desai Newbie

      I am extremely frustrated with the support (or lack of) for JPA 2 in JBoss.

       

      I just can't get my JPA 2 + Spring 3  + hibernate application to deploy in JBoss  - JBoss 5.1 is just too rigid to support JPA 2 and JBoss 6.0 is not ready yet...

       

      My application that runs perfectly fine in Jetty or Tomcat, simply fails in JBoss 6.0 (Don't get me started with my experience with JBoss 5.1).

       

      My last error was:

       

      09:49:32,062  ERROR [AbstractKernelController] Error installing to Start:  name=persistence.unit:unitName=gateway-2.2.4-SNAPSHOT.war#ApplicationEntityManager  state=Create: java.lang.RuntimeException: Specification violation [EJB3  JPA 6.2.1.2] - You have not defined a non-jta-data-source for a  RESOURCE_LOCAL enabled persistence context named:  ApplicationEntityManager
          at org.jboss.jpa.impl.deployment.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:133) [:2.0.0]

       

      When I look at the Persistence XSD @ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd, non-jta-data-source is an optional element.

                    <xsd:element name="non-jta-data-source" type="xsd:string" 
                                 minOccurs="0">
                      <xsd:annotation>
                        <xsd:documentation>

                          The container-specific name of a non-JTA datasource to use.

                        </xsd:documentation>
                      </xsd:annotation>
                    </xsd:element>

       

      What I have is a Spring based application and I use the following beans to configure my EntityManager:

       

           <bean id="dataSource"
              class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
              p:driverClassName="${db.driver}"
              p:url="${db.url}"
              p:username="${db.username}"
              p:password="${db.password}" />

       

      and

             <bean id="jpaDialect"
                class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
         
          <bean id="entityManagerFactory"
              class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
              p:dataSource-ref="dataSource"
              p:persistenceUnitName="${persistence.unitname}"
              p:jpaDialect-ref="jpaDialect"
              p:jpaPropertyMap-ref="jpaPropertyMap"
              p:jpaVendorAdapter-ref="jpaAdapter">
          </bean>

       

      Why is JBoss forcing me define non-jta-data-source ?

       

      Am I missing something here?

       

      RD

        • 1. Re: JPA 2 support in JBoss
          jaikiran pai Master

          Rajan Desai wrote:

           

          I am extremely frustrated with the support (or lack of) for JPA 2 in JBoss.

           

          I just can't get my JPA 2 + Spring 3  + hibernate application to deploy in JBoss  - JBoss 5.1 is just too rigid to support JPA 2 and JBoss 6.0 is not ready yet...

           

          JBoss AS5 was never meant for JPA2. So it's obvious it wont work out well there. JBoss AS6 already has support for JPA2.

           

           

          Rajan Desai wrote:

           

          My application that runs perfectly fine in Jetty or Tomcat, simply fails in JBoss 6.0 (Don't get me started with my experience with JBoss 5.1).

           

          My last error was:

           

          09:49:32,062  ERROR [AbstractKernelController] Error installing to Start:  name=persistence.unit:unitName=gateway-2.2.4-SNAPSHOT.war#ApplicationEntityManager  state=Create: java.lang.RuntimeException: Specification violation [EJB3  JPA 6.2.1.2] - You have not defined a non-jta-data-source for a  RESOURCE_LOCAL enabled persistence context named:  ApplicationEntityManager
              at org.jboss.jpa.impl.deployment.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:133) [:2.0.0]

          ...

          Why is JBoss forcing me define non-jta-data-source ?

           

          Like the error message says:

           

          EJB3 JPA spec:

           

          6.2.1.2 transaction-type

           

          The transaction-type attribute is used to specify whether the entity managers provided by the entity manager factory for the persistence unit must be JTA entity managers or resource-local entity  managers. The value of this element is JTA or RESOURCE_LOCAL. A transaction-type of JTA assumes that a JTA data source will be provided—either as specified by the jta-data-source element or provided by the container. In general, in Java EE environments, a transaction-type of RESOURCE_LOCAL assumes that a non-JTA datasource will be provided.