1 2 Previous Next 16 Replies Latest reply: Dec 21, 2012 11:47 AM by Matheus Binotto RSS

Creating EntityManagerFactory inside a session bean

Dattaram Porob Newbie

I have a piece of code in which I create an entityManagerFactory and entityManager using the folllwing calls inside a session bean: ///////////////////// EntityManagerFactory emf = Persistence.createEntityManagerFactory("TestPU"); em = emf.createEntityManager(); ///////////////////// The createEnityManager call is throwing a NullPointerException. The persistent unit TestPU is defined as follows: ///////////////////// ///////////////////// The above code used to work fine in JBoss AS 4.2.3 but stopped working when I moved to AS 7. Any ideas ? Note: It does not throw the NullPointerException if I change the persistent unit to 'RESOURCE_LOCAL' and the datasource to 'non-jta-data-source'.

  • 1. Re: Creating EntityManagerFactory inside a session bean
    Scott Marlow Master

    This is a bug, if you create an AS7 JPA jira (https://issues.jboss.org/browse/AS7), it can be fixed.  Once fixed, you can get the nightly build to test.

  • 2. Re: Creating EntityManagerFactory inside a session bean
    Scott Marlow Master

    Actually, to verify that its a bug, can you show the exception call stack?  It sounds like emf is null and that would likely be a bug.  Confirm that before creating the jira.

  • 3. Re: Creating EntityManagerFactory inside a session bean
    Dattaram Porob Newbie

    The emf is not null; the createEntityManager call is failing when it tries to join a JTA transaction (the JTA Platform returned in NoJTAPlatform). The stack trace looks like : ////////////////////////////////////////// 04:46:15,163 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) java.lang.NullPointerException 04:46:15,164 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.getStatus(JtaStatusHelper.java:72) 04:46:15,164 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.isActive(JtaStatusHelper.java:114) 04:46:15,164 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.hibernate.engine.transaction.internal.jta.CMTTransaction.join(CMTTransaction.java:149) 04:46:15,164 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:1197) 04:46:15,165 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.hibernate.ejb.AbstractEntityManagerImpl.postInit(AbstractEntityManagerImpl.java:170) 04:46:15,165 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.hibernate.ejb.EntityManagerImpl.(EntityManagerImpl.java:90) 04:46:15,165 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:111) 04:46:15,165 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:106) 04:46:15,165 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at com.test.mgmt.TestDAOImpl.init(TestDAOImpl.java:35) 04:46:15,166 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 04:46:15,166 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 04:46:15,166 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 04:46:15,166 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at java.lang.reflect.Method.invoke(Method.java:597) 04:46:15,166 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptor.java:69) 04:46:15,166 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,167 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) 04:46:15,167 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,167 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ee.component.ManagedReferenceInterceptor.processInvocation(ManagedReferenceInterceptor.java:53) 04:46:15,167 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,167 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) 04:46:15,168 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,168 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:44) 04:46:15,168 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,168 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor.processInvocation(SessionInvocationContextInterceptor.java:71) 04:46:15,168 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,168 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) 04:46:15,169 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,169 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) 04:46:15,169 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:152) 04:46:15,169 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:77) 04:46:15,169 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ejb3.component.stateless.StatelessSessionComponent$1.create(StatelessSessionComponent.java:70) 04:46:15,169 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ejb3.component.stateless.StatelessSessionComponent$1.create(StatelessSessionComponent.java:67) 04:46:15,170 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.ejb3.pool.AbstractPool.create(AbstractPool.java:65) 04:46:15,170 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.ejb3.pool.strictmax.StrictMaxPool.get(StrictMaxPool.java:145) 04:46:15,170 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:41) 04:46:15,170 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,170 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor$CustomSessionInvocationContext.proceed(SessionInvocationContextInterceptor.java:126) 04:46:15,171 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:233) 04:46:15,171 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.required(CMTTxInterceptor.java:363) 04:46:15,171 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invoke(CMTTxInterceptor.java:219) 04:46:15,171 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:35) 04:46:15,171 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,171 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor.processInvocation(SessionInvocationContextInterceptor.java:71) 04:46:15,172 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,172 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) 04:46:15,172 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:146) 04:46:15,172 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,172 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) 04:46:15,172 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:76) 04:46:15,173 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at com.test.mgmt.AlarmDAO$$$view14.save(Unknown Source) 04:46:15,173 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at com.test.mgmt.persist(Persist.java:80) 04:46:15,173 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 04:46:15,173 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 04:46:15,173 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 04:46:15,174 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at java.lang.reflect.Method.invoke(Method.java:597) 04:46:15,174 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:51) 04:46:15,174 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,174 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) 04:46:15,174 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,174 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:45) 04:46:15,175 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,175 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:44) 04:46:15,175 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,175 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) 04:46:15,175 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,175 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) 04:46:15,176 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,176 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) 04:46:15,176 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ee.component.ViewDescription$ComponentDispatcherInterceptor.processInvocation(ViewDescription.java:202) 04:46:15,176 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,176 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:44) 04:46:15,176 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,177 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor$CustomSessionInvocationContext.proceed(SessionInvocationContextInterceptor.java:126) 04:46:15,177 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:233) 04:46:15,177 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.required(CMTTxInterceptor.java:363) 04:46:15,177 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invoke(CMTTxInterceptor.java:219) 04:46:15,177 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:35) 04:46:15,178 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,178 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor.processInvocation(SessionInvocationContextInterceptor.java:71) 04:46:15,178 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,178 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) 04:46:15,178 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:146) 04:46:15,178 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,179 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) 04:46:15,179 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:76) 04:46:15,179 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at com.test.mgmt.PersistLocal$$$view17.persist(Unknown Source) 04:46:15,179 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at com.test.mgmt.Helper.persist(Helper.java:92) 04:46:15,179 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at com.test.mgmt.Helper.TestMDB.persist(TestMDB.java:58) 04:46:15,180 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at com.test.mgmt.Helper.TestMDB.onMessage(TestMDB.java:43) 04:46:15,180 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 04:46:15,180 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 04:46:15,180 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 04:46:15,180 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at java.lang.reflect.Method.invoke(Method.java:597) 04:46:15,180 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:51) 04:46:15,181 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,181 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) 04:46:15,181 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,182 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:44) 04:46:15,189 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,189 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) 04:46:15,189 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,189 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) 04:46:15,189 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,189 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) 04:46:15,195 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ee.component.ViewDescription$ComponentDispatcherInterceptor.processInvocation(ViewDescription.java:202) 04:46:15,195 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,195 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:44) 04:46:15,195 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,195 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ejb3.component.messagedriven.MessageDrivenInvocationContextInterceptor.processInvocation(MessageDrivenInvocationContextInterceptor.java:60) 04:46:15,195 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,196 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) 04:46:15,196 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:146) 04:46:15,196 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) 04:46:15,196 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) 04:46:15,196 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:76) 04:46:15,196 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at javax.jms.MessageListener$$$view18.onMessage(Unknown Source) 04:46:15,197 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 04:46:15,197 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 04:46:15,197 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 04:46:15,197 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at java.lang.reflect.Method.invoke(Method.java:597) 04:46:15,197 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ejb3.inflow.MessageEndpointInvocationHandler.doInvoke(MessageEndpointInvocationHandler.java:140) 04:46:15,198 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.jboss.as.ejb3.inflow.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:73) 04:46:15,198 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at $Proxy44.onMessage(Unknown Source) 04:46:15,198 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.hornetq.ra.inflow.HornetQMessageHandler.onMessage(HornetQMessageHandler.java:278) 04:46:15,198 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.hornetq.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:866) 04:46:15,198 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.hornetq.core.client.impl.ClientConsumerImpl.access$100(ClientConsumerImpl.java:44) 04:46:15,198 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.hornetq.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:983) 04:46:15,199 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:100) 04:46:15,199 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 04:46:15,199 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 04:46:15,199 ERROR [stderr] (Thread-4 (group:HornetQ-client-global-threads-4559126)) at java.lang.Thread.run(Thread.java:619) ////////////////////////////////////////// Do you think this is a bug ?

  • 4. Re: Creating EntityManagerFactory inside a session bean
    jaikiran pai Master

    Off topic: What's up with the formatting of your posts in this thread? Just curious - Is it the editor messing up the newlines or did you not add any newlines?

  • 5. Re: Creating EntityManagerFactory inside a session bean
    Scott Marlow Master

    A cleaner view of the exception is pasted here http://pastebin.com/4qRLKuex  (thanks Intellij!)

     

    Clearly, its not working the way you expected it to.  It looks like we are trying to enable autocommit with an active JTA transaction.  Which is not allowed.  It feels like a bug but I'm not 100% yet.

     

    You mentioned the workaround of using RESOURCE_LOCAL and non-jta-data-source.  That means ignoring the active JTA transaction as well.  Does your application expect to control the entity manager with the active JTA transaction?

     

    Also, could give a little more information as to why your bootstraping the entity manager this way, rather than the EE way (

    @PersistenceUnit EntityManagerFactory).  I assume it has to do with being portable to non-EE environments but still wanted to ask.

  • 6. Re: Creating EntityManagerFactory inside a session bean
    Scott Marlow Master

    Jira https://hibernate.onjira.com/browse/HHH-6651 is for the bug.

     

    Maybe next time, try clicking on the "use advanced editor" and click on the ">>".  Choose "Quote".  Then paste the exception into the opened quote box.  I'll paste part of the exception (from my local testcase reproducing it) below to show what that looks like.

     

     

    11:28:33,009 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (RMI TCP Connection(72)-127.0.0.1) HHH00231:Schema export unsuccessful: java.sql.SQLException: You cannot set autocommit during a managed transaction!

        at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.setJdbcAutoCommit(BaseWrapperManagedConnection.java:878)

        at org.jboss.jca.adapters.jdbc.WrappedConnection.setAutoCommit(WrappedConnection.java:712)

        at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:59) [hibernate-core-4.0.0.CR2.jar:4.0.0.CR2]

        at org.hibernate.tool.hbm2ddl.DatabaseExporter.<init>(DatabaseExporter.java:52) [hibernate-core-4.0.0.CR2.jar:4.0.0.CR2]

        at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:354) [hibernate-core-4.0.0.CR2.jar:4.0.0.CR2]

        at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:291) [hibernate-core-4.0.0.CR2.jar:4.0.0.CR2]

        at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:280) [hibernate-core-4.0.0.CR2.jar:4.0.0.CR2]

        at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:440) [hibernate-core-4.0.0.CR2.jar:4.0.0.CR2]

        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1722) [hibernate-core-4.0.0.CR2.jar:4.0.0.CR2]

        at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:76) [hibernate-entitymanager-4.0.0.CR2.jar:4.0.0.CR2]

        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899) [hibernate-entitymanager-4.0.0.CR2.jar:4.0.0.CR2]

        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:884) [hibernate-entitymanager-4.0.0.CR2.jar:4.0.0.CR2]

        at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56) [hibernate-entitymanager-4.0.0.CR2.jar:4.0.0.CR2]

        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]

        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]

        at org.jboss.as.testsuite.integration.jpa.bootstrap.SFSB1.createEmployeeNoTx(SFSB1.java:47) [jpa_bootstrapTestCase.jar:]

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_26]

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_26]

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_26]

        at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_26]

        at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

        at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

        at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:45) [jboss-as-jpa-7.1.0.Alpha1-SNAPSHOT.jar:7.1.0.Alpha1-SNAPSHOT]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

        at org.jboss.as.ejb3.component.stateful.StatefulSessionSynchronizationInterceptor.processInvocation(StatefulSessionSynchronizationInterceptor.java:132) [jboss-as-ejb3-7.1.0.Alpha1-SNAPSHOT.jar:7.1.0.Alpha1-SNAPSHOT]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

        at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:44)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

        at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

        at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

        at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

        at org.jboss.as.ee.component.ViewDescription$ComponentDispatcherInterceptor.processInvocation(ViewDescription.java:202)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

        at org.jboss.as.jpa.interceptor.SFSBInvocationInterceptor.processInvocation(SFSBInvocationInterceptor.java:58) [jboss-as-jpa-7.1.0.Alpha1-SNAPSHOT.jar:7.1.0.Alpha1-SNAPSHOT]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

        at org.jboss.as.ejb3.component.stateful.StatefulComponentInstanceInterceptor.processInvocation(StatefulComponentInstanceInterceptor.java:61) [jboss-as-ejb3-7.1.0.Alpha1-SNAPSHOT.jar:7.1.0.Alpha1-SNAPSHOT]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

        at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor$CustomSessionInvocationContext.proceed(SessionInvocationContextInterceptor.java:126) [jboss-as-ejb3-7.1.0.Alpha1-SNAPSHOT.jar:7.1.0.Alpha1-SNAPSHOT]

        at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:211) [jboss-as-ejb3-7.1.0.Alpha1-SNAPSHOT.jar:7.1.0.Alpha1-SNAPSHOT]

        at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:284) [jboss-as-ejb3-7.1.0.Alpha1-SNAPSHOT.jar:7.1.0.Alpha1-SNAPSHOT]

        at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:182) [jboss-as-ejb3-7.1.0.Alpha1-SNAPSHOT.jar:7.1.0.Alpha1-SNAPSHOT]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

        at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor.processInvocation(SessionInvocationContextInterceptor.java:71) [jboss-as-ejb3-7.1.0.Alpha1-SNAPSHOT.jar:7.1.0.Alpha1-SNAPSHOT]

     

  • 7. Re: Creating EntityManagerFactory inside a session bean
    Scott Marlow Master

    Looks like HHH-6651 is a different bug.

  • 8. Re: Creating EntityManagerFactory inside a session bean
    Scott Marlow Master

    You originally said that the app was calling Persistence.createEntityManagerFactory but from the exception call stack, that is not the case.  You probably mean the Persistence provider createEntityManagerFactory was called instead of javax.persistence.Persistence.createEntityManagerFactory.

  • 9. Re: Creating EntityManagerFactory inside a session bean
    Scott Marlow Master

    It looks like in the test code, the TransactionManager is not being passed in. 

     

    Can you provide a link to the source for com.test.mgmt.TestDAOImpl.init (perhaps paste into http://pastie.org and give the link here).

  • 10. Re: Creating EntityManagerFactory inside a session bean
    Dattaram Porob Newbie

    I would not be able to send the entire code but the init function just does 2 things as shown below :

     

    import javax.persistence.EntityManager;

    import javax.persistence.EntityManagerFactory;

    import javax.persistence.Persistence;

     

    @PostConstruct

        public void init(){

            EntityManagerFactory emf = Persistence.createEntityManagerFactory("TestPU");

            EntityManager em = emf.createEntityManager();

        }

     

    We actually have a jar which can be used in a SE as well as EE environment and that jar is using this method to create an entity manager. I got the NPE while using this jar. Thats when I tried doing the same thing directly in a test session bean as shown above.

  • 11. Re: Creating EntityManagerFactory inside a session bean
    Scott Marlow Master

    That is what I thought you were doing, but the exception test that you pasted, doesn't match.  Perhaps you copied the wrong exception from server.log.

     

    In the exception that you pasted, I see com.test.mgmt.TestDAOImpl.init calling org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager.

     

    Could you paste the NullPointerException with the call stack for when you get the NPE calling Persistence.createEntityManagerFactory().  This is the error that I recreated but I want to verify that your hitting the same exact issue.

  • 12. Re: Creating EntityManagerFactory inside a session bean
    Scott Marlow Master

    When its time to create the EntityManagerFactory, can you suspend the transaction?  Or maybe get it before the transaction begins?

  • 13. Re: Creating EntityManagerFactory inside a session bean
    Dattaram Porob Newbie

    The only thing missing in the code snippet which I sent earlier is the try/catch block where I catch the exception and print the stack trace. So, the code looks like this:

    @PostConstruct

        public void init(){

            try{

            EntityManagerFactory emf = Persistence.createEntityManagerFactory("TestPU");

            em = emf.createEntityManager();

            }catch(Exception ex){

                ex.printStackTrace();

            }

        }

    And the exception trace looks like this:

    03:43:33,453 ERROR [stderr] () java.lang.NullPointerException

    03:43:33,453 ERROR [stderr] ()     at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.getStatus(JtaStatusHelper.java:72)

    03:43:33,453 ERROR [stderr] ()     at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.isActive(JtaStatusHelper.java:114)

    03:43:33,454 ERROR [stderr] ()     at org.hibernate.engine.transaction.internal.jta.CMTTransaction.join(CMTTransaction.java:149)

    03:43:33,454 ERROR [stderr] ()     at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:1197)

    03:43:33,454 ERROR [stderr] ()     at org.hibernate.ejb.AbstractEntityManagerImpl.postInit(AbstractEntityManagerImpl.java:170)

    03:43:33,454 ERROR [stderr] ()     at org.hibernate.ejb.EntityManagerImpl.<init>(EntityManagerImpl.java:90)

    03:43:33,454 ERROR [stderr] ()     at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:111)

    03:43:33,454 ERROR [stderr] ()     at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:106)

    03:43:33,454 ERROR [stderr] ()     at com.test.mgmt.TestDAOImpl.init(TestDAOImpl.java:34)

    03:43:33,454 ERROR [stderr] ()     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    03:43:33,454 ERROR [stderr] ()     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    03:43:33,455 ERROR [stderr] ()     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    03:43:33,455 ERROR [stderr] ()     at java.lang.reflect.Method.invoke(Method.java:597)

    03:43:33,455 ERROR [stderr] ()     at org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptor.java:69)

    03:43:33,455 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,455 ERROR [stderr] ()     at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

    03:43:33,455 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,455 ERROR [stderr] ()     at org.jboss.as.ee.component.ManagedReferenceInterceptor.processInvocation(ManagedReferenceInterceptor.java:53)

    03:43:33,455 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,456 ERROR [stderr] ()     at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

    03:43:33,456 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,456 ERROR [stderr] ()     at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:44)

    03:43:33,456 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,456 ERROR [stderr] ()     at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor.processInvocation(SessionInvocationContextInterceptor.java:71)

    03:43:33,456 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,456 ERROR [stderr] ()     at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)

    03:43:33,457 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,457 ERROR [stderr] ()     at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

    03:43:33,457 ERROR [stderr] ()     at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:152)

    03:43:33,457 ERROR [stderr] ()     at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:77)

    03:43:33,457 ERROR [stderr] ()     at org.jboss.as.ejb3.component.stateless.StatelessSessionComponent$1.create(StatelessSessionComponent.java:70)

    03:43:33,457 ERROR [stderr] ()     at org.jboss.as.ejb3.component.stateless.StatelessSessionComponent$1.create(StatelessSessionComponent.java:67)

    03:43:33,457 ERROR [stderr] ()     at org.jboss.ejb3.pool.AbstractPool.create(AbstractPool.java:65)

    03:43:33,457 ERROR [stderr] ()     at org.jboss.ejb3.pool.strictmax.StrictMaxPool.get(StrictMaxPool.java:145)

    03:43:33,458 ERROR [stderr] ()     at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:41)

    03:43:33,458 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,458 ERROR [stderr] ()     at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor$CustomSessionInvocationContext.proceed(SessionInvocationContextInterceptor.java:126)

    03:43:33,458 ERROR [stderr] ()     at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:233)

    03:43:33,458 ERROR [stderr] ()     at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.required(CMTTxInterceptor.java:363)

    03:43:33,458 ERROR [stderr] ()     at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invoke(CMTTxInterceptor.java:219)

    03:43:33,458 ERROR [stderr] ()     at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:35)

    03:43:33,458 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,458 ERROR [stderr] ()     at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor.processInvocation(SessionInvocationContextInterceptor.java:71)

    03:43:33,459 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,459 ERROR [stderr] ()     at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

    03:43:33,459 ERROR [stderr] ()     at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:146)

    03:43:33,459 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,459 ERROR [stderr] ()     at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

    03:43:33,459 ERROR [stderr] ()     at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:76)

    03:43:33,459 ERROR [stderr] ()     at com.test.mgmt.TestDAO$$$view50.save(Unknown Source)

    03:43:33,460 ERROR [stderr] ()     at com.test.mgmt.Persist.persist(Persist.java:101)

    03:43:33,460 ERROR [stderr] ()     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    03:43:33,460 ERROR [stderr] ()     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    03:43:33,460 ERROR [stderr] ()     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    03:43:33,460 ERROR [stderr] ()     at java.lang.reflect.Method.invoke(Method.java:597)

    03:43:33,460 ERROR [stderr] ()     at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:51)

    03:43:33,460 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,460 ERROR [stderr] ()     at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

    03:43:33,460 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,461 ERROR [stderr] ()     at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:45)

    03:43:33,461 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,461 ERROR [stderr] ()     at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:44)

    03:43:33,461 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,461 ERROR [stderr] ()     at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)

    03:43:33,461 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,461 ERROR [stderr] ()     at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)

    03:43:33,461 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,461 ERROR [stderr] ()     at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

    03:43:33,462 ERROR [stderr] ()     at org.jboss.as.ee.component.ViewDescription$ComponentDispatcherInterceptor.processInvocation(ViewDescription.java:202)

    03:43:33,462 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,462 ERROR [stderr] ()     at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:44)

    03:43:33,462 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,462 ERROR [stderr] ()     at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor$CustomSessionInvocationContext.proceed(SessionInvocationContextInterceptor.java:126)

    03:43:33,462 ERROR [stderr] ()     at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:233)

    03:43:33,462 ERROR [stderr] ()     at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.required(CMTTxInterceptor.java:363)

    03:43:33,463 ERROR [stderr] ()     at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invoke(CMTTxInterceptor.java:219)

    03:43:33,463 ERROR [stderr] ()     at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:35)

    03:43:33,463 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,463 ERROR [stderr] ()     at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor.processInvocation(SessionInvocationContextInterceptor.java:71)

    03:43:33,463 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,463 ERROR [stderr] ()     at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

    03:43:33,463 ERROR [stderr] ()     at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:146)

    03:43:33,464 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,464 ERROR [stderr] ()     at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

    03:43:33,464 ERROR [stderr] ()     at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:76)

    03:43:33,464 ERROR [stderr] ()     at com.test.mgmt.PersistLocal$$$view53.persist(Unknown Source)

    03:43:33,464 ERROR [stderr] ()     at com.test.mgmt.Helper.persist(Helper.java:92)

    03:43:33,465 ERROR [stderr] ()     at com.test.mgmt.TestMDB.persist(TestMDB.java:58)

    03:43:33,465 ERROR [stderr] ()     at com.test.mgmt.TestMDB.onMessage(TestMDB.java:43)

    03:43:33,465 ERROR [stderr] ()     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    03:43:33,465 ERROR [stderr] ()     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    03:43:33,465 ERROR [stderr] ()     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    03:43:33,465 ERROR [stderr] ()     at java.lang.reflect.Method.invoke(Method.java:597)

    03:43:33,466 ERROR [stderr] ()     at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:51)

    03:43:33,466 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,466 ERROR [stderr] ()     at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

    03:43:33,466 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,466 ERROR [stderr] ()     at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:44)

    03:43:33,466 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,467 ERROR [stderr] ()     at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)

    03:43:33,467 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,467 ERROR [stderr] ()     at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)

    03:43:33,467 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,467 ERROR [stderr] ()     at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

    03:43:33,468 ERROR [stderr] ()     at org.jboss.as.ee.component.ViewDescription$ComponentDispatcherInterceptor.processInvocation(ViewDescription.java:202)

    03:43:33,468 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,468 ERROR [stderr] ()     at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:44)

    03:43:33,468 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,468 ERROR [stderr] ()     at org.jboss.as.ejb3.component.messagedriven.MessageDrivenInvocationContextInterceptor.processInvocation(MessageDrivenInvocationContextInterceptor.java:60)

    03:43:33,468 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,469 ERROR [stderr] ()     at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

    03:43:33,469 ERROR [stderr] ()     at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:146)

    03:43:33,469 ERROR [stderr] ()     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)

    03:43:33,469 ERROR [stderr] ()     at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

    03:43:33,469 ERROR [stderr] ()     at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:76)

    03:43:33,469 ERROR [stderr] ()     at javax.jms.MessageListener$$$view54.onMessage(Unknown Source)

    03:43:33,469 ERROR [stderr] ()     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    03:43:33,470 ERROR [stderr] ()     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    03:43:33,470 ERROR [stderr] ()     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    03:43:33,470 ERROR [stderr] ()     at java.lang.reflect.Method.invoke(Method.java:597)

    03:43:33,470 ERROR [stderr] ()     at org.jboss.as.ejb3.inflow.MessageEndpointInvocationHandler.doInvoke(MessageEndpointInvocationHandler.java:140)

    03:43:33,470 ERROR [stderr] ()     at org.jboss.as.ejb3.inflow.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:73)

    03:43:33,471 ERROR [stderr] ()     at $Proxy46.onMessage(Unknown Source)

    03:43:33,471 ERROR [stderr] ()     at org.hornetq.ra.inflow.HornetQMessageHandler.onMessage(HornetQMessageHandler.java:278)

    03:43:33,471 ERROR [stderr] ()     at org.hornetq.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:866)

    03:43:33,471 ERROR [stderr] ()     at org.hornetq.core.client.impl.ClientConsumerImpl.access$100(ClientConsumerImpl.java:44)

    03:43:33,471 ERROR [stderr] ()     at org.hornetq.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:983)

    03:43:33,471 ERROR [stderr] ()     at org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:100)

    03:43:33,472 ERROR [stderr] ()     at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

    03:43:33,472 ERROR [stderr] ()     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

    03:43:33,472 ERROR [stderr] ()     at java.lang.Thread.run(Thread.java:619)

     

    Are you saying that the problem is that it cannot join an active transaction and so I should suspend the current one ? I could try that, but is this a workaround for a bug ? This code was working fine in 4.2.3; so am I doing something against the specs which is causing it to fail in AS 7 ?

  • 14. Re: Creating EntityManagerFactory inside a session bean
    Scott Marlow Master

    The EJB specification notes that it is implementation defined, whether a transaction is started or not for the PostConstruct. 

     

    4.3.4 Session Bean Lifecycle Callback Interceptor Methods

    ...

    The PostConstruct lifecycle callback interceptor methods for stateless and stateful session beans execute in an unspecified transaction context.

     

    I wonder what the transaction context for a PostConstruct is in AS5.x.  If there is no transaction for the PostConstruct in AS 4.x and 5.x, that might be an incentive to change AS 7 to also not run the PostConstruct in a transaction.  Unless there is a strong reason why we are running the PostConstruct in a transaction (in AS 7).

     

    You might want to create a jira for this issue (https://issues.jboss.org/browse/AS7).

1 2 Previous Next