4 Replies Latest reply on Feb 24, 2011 1:50 PM by ebross

    Failed to set value TransactionScopedEntityManager:EntityManager

    ebross

      Hello JBoss World,

       

       

      JBossAS [6.1.0.SNAPSHOT "Neo"]

       

      I am consistently having the following error:

       

       

      14:13:26,564 ERROR [STDERR] java.lang.IllegalArgumentException: failed to set value TransactionScopedEntityManager: persistence.unit:unitName=myEAR.ear/myPersistence.jar#myPersistenceUnit on field private org.eclipse.persistence.jpa.JpaEntityManager com.myproject.my.dao.impl.EclipselinkDAOImpl.entityManager

      14:13:26,566 ERROR [STDERR]      at org.jboss.injection.injector.util.FieldInjectionPoint.set(FieldInjectionPoint.java:73)

      14:13:26,566 ERROR [STDERR]      at org.jboss.injection.injector.EEInjector.inject(EEInjector.java:159)

      14:13:26,566 ERROR [STDERR]      at org.jboss.injection.injector.EEInjector.inject(EEInjector.java:133)

      14:13:26,567 ERROR [STDERR]      at org.jboss.injection.injector.EEInjector.inject(EEInjector.java:81)

      14:13:26,567 ERROR [STDERR]      at org.jboss.injection.manager.core.DefaultInjectionContext.proceed(DefaultInjectionContext.java:58)

      14:13:26,567 ERROR [STDERR]      at org.jboss.injection.manager.core.DefaultInjectionManager.inject(DefaultInjectionManager.java:58)

      14:13:26,567 ERROR [STDERR]      at org.jboss.injection.manager.core.DefaultInjectionManager.inject(DefaultInjectionManager.java:64)

      14:13:26,567 ERROR [STDERR]      at org.jboss.ejb3.injection.InjectionInvocation.invokeTarget(InjectionInvocation.java:140)

      14:13:26,567 ERROR [STDERR]      at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:125)

      14:13:26,567 ERROR [STDERR]      at org.jboss.ejb3.core.context.CurrentInvocationContextInterceptor.invoke(CurrentInvocationContextInterceptor.java:47)

      14:13:26,567 ERROR [STDERR]      at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:116)

      14:13:26,567 ERROR [STDERR]      at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)

      14:13:26,568 ERROR [STDERR]      at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:116)

      14:13:26,568 ERROR [STDERR]      at org.jboss.ejb3.EJBContainer.injectBeanContext(EJBContainer.java:1363)

      14:13:26,568 ERROR [STDERR]      at org.jboss.ejb3.stateless.StatelessContainer.createBeanContext(StatelessContainer.java:139)

       

       

       

      Due to unresoved issue [https://issues.jboss.org/browse/JBAS-8803], I have had to place my persistence.xml in an ejb project [myPersistence.jar] created just for the peristence.xml only. myPersistence.jar is packaged in my myEAR.ear; and entities are in a jpa jar and under myEAR.ear/lib.

       

       

      Here is the rest:

       

       

      @javax.ejb.Stateless

      public class XManagerImpl implements  IXManagerLocal, IXManagerRemote, java.io.Serializable{

       

      @javax.ejb.EJB

      private IXDAOLocal dataConstraintDaoReference;

       

       

      public Future<XEntity[]> queryByExample(final XEntity entity) throws IEJBBaseInterface.ApplicationException{

       

       

      XEntity[] retList = null;

      try{

      java.util.Collection<XEntity> results = dataConstraintDaoReference.queryByExample(entity);<----------##ERROR THROWN HERE##

      if(results.isEmpty()){

      throw new IEJBBaseInterface.EmptyValueException("X results");

      }

      retList = toArray(results);

        } catch (Exception ex) {

      //throw new IEJBBaseInterface.FindObjectException(ex);

      ex.printStackTrace();

        }

         return new AsynResult<XEntity[]>(retList);

       

         }

       

      }

       

      //--------------------------------------------------------------------------------

      @javax.ejb.Stateless

      public class XDAOImpl extends EclipselinkDAOImpl<XEntity,Long> implements  IXDAOLocal, IXDAORemote, java.io.Serializable{

       

      }

       

      //--------------------------------------------------------------------------------

      public abstract class EclipselinkDAOImpl<T extends Persistable<PK>, PK extends Serializable> extends AbstractIGenericDAO<T, PK> implements IEclipselinkDAO<T, PK>, Serializable{

       

      @javax.persistence.PersistenceContext

      private JpaEntityManager entityManager;<-------------------------- ##PROBLEM POINT##

       

      }

       

       

       

      Thanks

        • 1. Failed to set value TransactionScopedEntityManager:EntityManager
          jaikiran

          Please post the entire exception stacktrace.

          • 2. Re: Failed to set value TransactionScopedEntityManager:EntityManager
            ebross

            Hi jaikiran pai,

             

            Thanks for your response, and please find the attached stacktrace file.

             

             

            And here is also my persistence.xml which hasn't changed since JBoss5.0 except the version:

             

            <persistence version="2.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_2_0.xsd">

            <persistence-unit name="myPersistenceUnit" transaction-type="JTA">

            <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

            <jta-data-source>java:/DefaultDS</jta-data-source>

            <jar-file>/lib/myJPA.jar</jar-file>

            <properties>

            <property name="eclipselink.weaving" value="true" />

            <property name="eclipselink.session-name" value="default-session" />

            <property name="eclipselink.orm.throw.exceptions" value="true" />

            <property name="eclipselink.validation-only" value="true" />

            <property name="eclipselink.profiler" value="PerformanceProfiler" />

            <property name="eclipselink.cache.size.default" value="500" />

            <property name="eclipselink.cache.type.default" value="Full" />

            <property name="eclipselink.cache.size.default" value="1000" />

            <property name="eclipselink.logging.timestamp" value="true" />

            <property name="eclipselink.logging.thread" value="true" />

            <property name="eclipselink.logging.session" value="true" />

            <property name="eclipselink.logging.exceptions" value="true" />

            <property name="eclipselink.logging.level" value="INFO" />

            <property name="eclipselink.target-database" value="PostgreSQL" />

            <property name="eclipselink.jdbc.batch-writing" value="JDBC" />

            <property name="eclipselink.persistence-context.flush-mode"

            value="COMMIT" />

            <property name="eclipselink.target-server" value="JBoss" />

            <property name="eclipselink.jdbc.uppercase-columns" value="true" />

            <property name="eclipselink.ddl-generation" value="none" />

            <property name="eclipselink.ddl-generation.output-mode"

            value="database" />

            <property name="eclipselink.logging.logger" value="ServerLogger" />

            </properties>

            </persistence-unit>

            </persistence>

             

            Thanks

            • 3. Re: Failed to set value TransactionScopedEntityManager:EntityManager
              wolfc

              Injection of the EclipseLink org.eclipse.persistence.jpa.JpaEntityManager is not supported. You can only inject a JPA javax.persistence.EntityManager. This is because a container managed transaction scoped entity manager is an indirection to the underlying entity manager.

              • 4. Failed to set value TransactionScopedEntityManager:EntityManager
                ebross

                Thanks Carlo de Wolf,

                 

                The code is almost two years old and running on Jboss 5.1 in production mode; and I have been wondering why I am having all these problems on JBoss6 . Following your response, I did a compare and found that indeed the code in production is:

                 

                @javax.persistence.PersistenceContext

                private EntityManager entityManager;

                 

                public JpaEntityManager getEntityManager() {

                if(entityManager == null){

                throw new IllegalStateException("EntityManager has not been set before usage");

                }

                return JpaHelper.getEntityManager(entityManager);

                }

                 

                How this became JpaEntityManager entityManager in the version I am currently working on, I don't know. Anyway thanks so much!