2 Replies Latest reply on Aug 2, 2012 11:11 AM by Anton Huba

    EntityManager null when trying to migrate to JBoss 7.1.1

    Anton Huba Newbie

      I am currently trying to migrate my web application from JBoss 5.1 to JBoss 7.1.1. I inject the entity manager into my jsp file but the entity manager is always null.

      persistence.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
         
      <!-- SSIS2 Productive Database -->
         
      <persistence-unit name="SSIS2" transaction-type="JTA">
             
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
             
      <jta-data-source>java:/SSIS2DSprod</jta-data-source>
             
      <properties>
                 
      <property name="hibernate.hbm2ddl.auto" value="update" />
                 
      <property name="hibernate.show_sql" value="false"/>
                 
      <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
             
      </properties>
         
      </persistence-unit>
      </persistence>

      Example of Entity Manager injection in a JSP file:

      <%! @PersistenceContext(unitName = "SSIS2")
         
      public EntityManager em;

         
      @Resource
         
      UserTransaction utx;
      %>

      The deployment itself contains no errors, so what is the problem with the Entity Manager here? It works without problems on JBoss 5.1.

      datasource in standalone.xml: (ip-address and SSID removed)

      <datasource jta="true" jndi-name="java:/SSIS2DSprod" pool-name="SSIS2DSprod" enabled="true" use-java-context="true" use-ccm="true">
                         
      <connection-url>jdbc:oracle:thin:@ip-address:1531:SSID</connection-url>
                         
      <driver>oracle</driver>
                         
      <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
                         
      <pool>
                             
      <prefill>true</prefill>
                             
      <use-strict-min>false</use-strict-min>
                             
      <flush-strategy>FailingConnectionOnly</flush-strategy>
                         
      </pool>
                         
      <security>
                             
      <user-name>ssis2</user-name>
                             
      <password>ssis2</password>
                         
      </security>
                     
      </datasource>