2 Replies Latest reply on Apr 25, 2010 7:32 PM by Leo van den berg

    PersistenceContext vs In entitymanager error

    John McClain Newbie

      I have a slsb and I wish to inject an entitymanger into it. I am using an XA datasource.


      When I use @PersistenceContext to inject, my em.persist() call works fine. When I use @In to let seam manage the entitymanger, it fails



      Annotations on entitymanager



      @In(value="CamOracleEntityManager")
      /*@PersistenceContext(unitName="avmserviceOracle")*/
      private EntityManager em;




      Components.xml



      <persistence:managed-persistence-context 
                name="CamOracleEntityManager"
                auto-create="true"
                persistence-unit-jndi-name="java:/avmserviceOracleEntityManagerFactory" />




      Persistence.xml



      <persistence-unit name="avmserviceOracle">
                <provider>org.hibernate.ejb.HibernatePersistence</provider>
                <jta-data-source>java:/jdbc/avmservice/avmservice</jta-data-source>
                <properties>
                     <!--property name="hibernate.cache.use_query_cache" value="true"/-->
                     <property name="hibernate.format_sql" value="true" />
                     <property name="hibernate.show_sql" value="true" />
                     <property name="hibernate.dialect"
                          value="org.hibernate.dialect.Oracle9iDialect" />
                     <property name="jboss.entity.manager.factory.jndi.name"
                          value="java:/avmserviceOracleEntityManagerFactory" />
                </properties>
           </persistence-unit>





      Error



       insert 
          into
              AVM_REQUEST_RESPONSE
              (REQ_PARSED_DIRECTIONSUFFIX, RESP_HIGHVALUERANGEAMT, REQ_PARSED_STREETNAME, RESP_RESRESPONSEIDENT, REQ_CRIT_STREETADDRESS, SYSTEM_ERROR, REQ_PARSED_APTORUNIT, RESP_PARSED_HOUSENUMBER, RESP_PROPPOSTALCODE, REQ_CRIT_COUNTY, RESP_RESPONSEDATETIME, RESP_PARSED_STREETNAME, RESP_PROPPLUSFOURPOSTALCODE, REQ_CRIT_CITY, RESP_PARSED_DIRECTIONSUFFIX, REQ_CRIT_STATE, REQ_PRODUCTCODE, RESP_STATUSDESCRIPTION, RESP_VALUATIONSCOREIDENT, RESP_PROPCITY, RESP_PARSED_STREETSUFFIX, REQ_PARSED_DIRECTIONPREFIX, REQ_LOANNUMBER, RESP_LOWVALUERANGEAMT, RESP_STATUSCONDITION, RESP_PARSED_APTORUNIT, RESP_PARSED_DIRECTIONPREFIX, REQ_PARSED_STREETSUFFIX, RESP_INDICVALUEAMOUNT, RESP_CUSTOMERREFIDENT1, REQ_CRIT_POSTALCODE, RESP_PROPSTATE, REQ_REQUESTEDBY, RESP_FORECASTSTDDEV, RESP_PROPCOUNTY, REQ_PARSED_HOUSENUMBER, REQ_CRIT_STREETADDRESS2, REQ_REQUESTDATETIME, id) 
          values
              (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
      08:48:21,475 ERROR [SeamPhaseListener] uncaught exception
      java.lang.IllegalStateException: Could not start transaction
           at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:592)
           at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsBeforePhase(SeamPhaseListener.java:323)
           at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:140)
           at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:114)
      .
      .
      Caused by: javax.ejb.NoSuchEJBException: Could not find stateful bean: a4f162y-zbo57r-fluzpibx-1-fluzqgt6-8
           at org.jboss.ejb3.cache.simple.SimpleStatefulCache.get(SimpleStatefulCache.java:390)
           at org.jboss.ejb3.cache.simple.SimpleStatefulCache.get(SimpleStatefulCache.java:375)
           at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:61)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
           at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext