5 Replies Latest reply on Mar 12, 2014 10:05 PM by Michael Kucinski

    TransactionRequiredException with JPA IDM & Glassfish

    John Schneider Newbie

      Hi,

       

      I'm setting up a proof of concept for IDM JPA with PicketLink 2.5.3-SNAPSHOT on Glassfish 4.  I've followed the picketlink-authorization-idm-jpa quickstart  and I have a MySQL database all set up.  I worked through a few mapping problems with EclipseLink 2.5.1 by adding an orm.xml and I'm so close to making it all work.  Within my IDMInitializer, EclipseLink is throwing a TransactionRequiredException when "IdentityManager identityManager = partitionManager.createIdentityManager();" is called, trying to create a default partition.

       

      I've tried downgrading to PicketLink 2.5.2.Final and the result is the same.  I've also tried providing my own ContextInitialzer as described at Chapter 7. Identity Management - Working with JPA

      but this doesn't fix the problem either.  I've also tried @TransactionAttribute(TransactionAttributeType.REQUIRED), @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) and even doing Bean Managed Transactions with an injected UserTransaction.  The result is always a TransactionRequiredException.

       

      I'd really appreciate some help on this.  My stacktrace is below.

       

      Thanks!

      John

       

       

      SEVERE: Exception while loading the app : javax.ejb.CreateException: Initialization failed for Singleton IDMInitializer

      javax.ejb.CreateException: Initialization failed for Singleton IDMInitializer

        at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:483)

        at com.sun.ejb.containers.AbstractSingletonContainer.access$000(AbstractSingletonContainer.java:81)

        at com.sun.ejb.containers.AbstractSingletonContainer$SingletonContextFactory.create(AbstractSingletonContainer.java:654)

        at com.sun.ejb.containers.AbstractSingletonContainer.instantiateSingletonInstance(AbstractSingletonContainer.java:396)

        at org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:219)

        at org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:180)

        at org.glassfish.ejb.startup.SingletonLifeCycleManager.doStartup(SingletonLifeCycleManager.java:158)

        at org.glassfish.ejb.startup.EjbApplication.start(EjbApplication.java:166)

        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)

        at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)

        at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:352)

        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:497)

        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)

        at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)

        at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:527)

        at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523)

        at java.security.AccessController.doPrivileged(Native Method)

        at javax.security.auth.Subject.doAs(Subject.java:356)

        at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522)

        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546)

        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423)

        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108)

        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762)

        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674)

        at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)

        at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)

        at org.glassfish.grizzly.http.server.StaticHttpHandler.service(StaticHttpHandler.java:297)

        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:246)

        at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)

        at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)

        at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)

        at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)

        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)

        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)

        at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)

        at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)

        at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)

        at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)

        at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)

        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)

        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)

        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)

        at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)

        at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)

        at java.lang.Thread.run(Thread.java:724)

      Caused by: org.picketlink.idm.IdentityManagementException: PLIDM000401: Could not create partition [59f360a8-0abd-41a7-b03a-e59b8a30d953] using configuration [default].

        at org.picketlink.idm.internal.DefaultPartitionManager.add(DefaultPartitionManager.java:367)

        at org.picketlink.idm.internal.DefaultPartitionManager.add(DefaultPartitionManager.java:334)

        at org.picketlink.producer.IdentityManagerProducer.createDefaultPartition(IdentityManagerProducer.java:201)

        at org.picketlink.producer.IdentityManagerProducer.createEmbeddedPartitionManager(IdentityManagerProducer.java:213)

        at org.picketlink.producer.IdentityManagerProducer.init(IdentityManagerProducer.java:105)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:606)

        at org.jboss.weld.injection.MethodInjectionPoint.invokeWithSpecialValue(MethodInjectionPoint.java:72)

        at org.jboss.weld.injection.MethodInjectionPoint.invoke(MethodInjectionPoint.java:66)

        at org.jboss.weld.util.Beans.callInitializers(Beans.java:401)

        at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:389)

        at org.jboss.weld.injection.producer.DefaultInjector.inject(DefaultInjector.java:72)

        at org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:60)

        at org.jboss.weld.injection.producer.DefaultInjector$1.proceed(DefaultInjector.java:66)

        at org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:142)

        at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:46)

        at org.jboss.weld.injection.producer.DefaultInjector.inject(DefaultInjector.java:64)

        at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:91)

        at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:158)

        at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:103)

        at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:742)

        at org.jboss.weld.injection.producer.AbstractMemberProducer.getReceiver(AbstractMemberProducer.java:110)

        at org.jboss.weld.injection.producer.AbstractMemberProducer.produce(AbstractMemberProducer.java:129)

        at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:189)

        at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:69)

        at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:742)

        at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:798)

        at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:92)

        at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:376)

        at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:388)

        at org.jboss.weld.injection.producer.DefaultInjector.inject(DefaultInjector.java:72)

        at org.jboss.weld.injection.producer.DefaultInjector$1.proceed(DefaultInjector.java:66)

        at org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:142)

        at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:46)

        at org.jboss.weld.injection.producer.DefaultInjector.inject(DefaultInjector.java:64)

        at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:91)

        at org.glassfish.weld.services.JCDIServiceImpl.injectEJBInstance(JCDIServiceImpl.java:257)

        at com.sun.ejb.containers.BaseContainer.injectEjbInstance(BaseContainer.java:1683)

        at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:443)

        ... 44 more

      Caused by: javax.persistence.TransactionRequiredException

        at com.sun.enterprise.container.common.impl.EntityManagerWrapper.doTxRequiredCheck(EntityManagerWrapper.java:161)

        at com.sun.enterprise.container.common.impl.EntityManagerWrapper.doTransactionScopedTxCheck(EntityManagerWrapper.java:151)

        at com.sun.enterprise.container.common.impl.EntityManagerWrapper.persist(EntityManagerWrapper.java:281)

        at org.picketlink.idm.jpa.internal.mappers.EntityMapper.persist(EntityMapper.java:113)

        at org.picketlink.idm.jpa.internal.JPAIdentityStore.addAttributedType(JPAIdentityStore.java:143)

        at org.picketlink.idm.internal.AbstractIdentityStore.add(AbstractIdentityStore.java:89)

        at org.picketlink.idm.jpa.internal.JPAIdentityStore.add(JPAIdentityStore.java:231)

        at org.picketlink.idm.internal.DefaultPartitionManager.add(DefaultPartitionManager.java:357)

        ... 84 more