1 2 Previous Next 19 Replies Latest reply on Jan 10, 2012 3:00 AM by mihaisheng

    Seam Managed persistence Context Problem

    mbsakho
      Hi all,
      I'm facing with problem when I try to use a Seam Managed Persistence Context.
      I'm using Jboss 7.0.2 and have followed the steps explained in the Seam Persistence Module documentation like below:

      I have declared the transaction interceptor in the beans.xml like below:


         <interceptors>
            <class>org.jboss.seam.transaction.TransactionInterceptor</class>
         </interceptors>
      </beans>

      I've also added the requires librairies(persistence.jar, persistence-impl.jar solder.jar) to my deployment.

      <dependency>
        <groupId>org.jboss.seam.persistence</groupId>
        <artifactId>seam-persistence-api</artifactId>
        <version>${seam.persistence.version}</version>
      </dependency>

      <dependency>
        <groupId>org.jboss.seam.persistence</groupId>
        <artifactId>seam-persistence-impl</artifactId>
        <version>${seam.persistence.version}</version>
      </dependency>

      <dependency>
        <groupId>org.jboss.seam.solder</groupId>
        <artifactId>seam-solder</artifactId>
        <version>${seam.solder.version}</version>
      </dependency>



      The class below permits me to have a SMPC created by seam.
      public class Resources
      {
                @SuppressWarnings("unused")
                @ExtensionManaged
                @Produces
                @PersistenceUnit
                @ConversationScoped
              private EntityManagerFactory emFactory;

      }

      I've declared the injection of the created EntityManager in my Stateful ManagedBean.
      public void register(Article article) throws Exception
           {
                log.info("Enregistrement "+article.getName() );
                em.persist(article);
                
           }

      ATTENTION [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http--127.0.0.1-8080-1) #{memberRegistration.register}: javax.ejb.EJBException:
      java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: Could not find TransactionManager in JNDI:
      javax.faces.FacesException: #{memberRegistration.register}: javax.ejb.EJBException: java.lang.RuntimeException:
      java.lang.RuntimeException: java.lang.RuntimeException: Could not find TransactionManager in JNDI


      thank you for your help
        • 1. Re: Seam Managed persistence Context Problem
          lightguard

          Sounds like you're using 3.0.0.Final. Please use a 3.1.0 Beta (Beta4 is the current one) and use Seam Transaction (it was split out of Seam Persistence in 3.1.0).

          • 2. Re: Seam Managed persistence Context Problem
            mbsakho
            I've updated to 3.1.0 Beta. (Seam persistence, seam transaction and solder).
            My application is not started now and I'm getting another stacktrace below:

            "
            15:43:16,999 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.deployment.unit."extranet-sigma.war".WeldService:
            org.jboss.msc.service.StartException in service jboss.deployment.unit."extranet-sigma.war".WeldService:
            org.jboss.weld.exceptions.DefinitionException:
            WELD-001502 Resource producer field [Resource Producer Field [EntityManagerFactory] with qualifiers [@Any @Default]
            declared as [[field] @Default @ExtensionManaged @PersistenceUnit @ConversationScoped @Produces private com.natixis.extranet.sigma.services.Resources.emFactory]]
            must be @Dependent scoped
                 at org.jboss.as.weld.services.WeldService.start(WeldService.java:96)
                 at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
                 at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
                 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_27]
                 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_27]
                 at java.lang.Thread.run(Thread.java:662) [:1.6.0_27]

            "
            It's telling me that the the field emfactory must be @Dependent scoped.
            here is the owner class of the designed field.

            '
            public class Resources
            {        
                      @SuppressWarnings("unused")
                      @Produces
                      @ExtensionManaged
                      @PersistenceUnit
                      @ConversationScoped
                      @Default
                    private EntityManagerFactory emFactory;

            }
            '

            I really don't undestand what's wrong.

            Any idea?

            Meissa
            • 3. Re: Seam Managed persistence Context Problem
              hantsy

              I switched to Beta 5 today and it was already in jboss maven repository,I found beta 5 was tagged yesterday, but there is no official news.

              • 4. Re: Seam Managed persistence Context Problem
                hantsy

                The following is  my code fragment used in my project.


                     @ExtensionManaged
                     @Produces
                     @PersistenceUnit
                     @ConversationScoped
                     EntityManagerFactory producerField;
                

                • 5. Re: Seam Managed persistence Context Problem
                  mbsakho
                  <blockquote>
                  _Jason Porter wrote on Nov 18, 2011 13:06:_<br/>

                  Sounds like you're using 3.0.0.Final. Please use a 3.1.0 Beta (Beta4 is the current one) and use Seam Transaction (it was split out of Seam Persistence in 3.1.0).
                  </blockquote>

                  I've updated to 3.1.0 Beta.
                  My application is not starting now and I'm having a new kind of exception. Here is the trace:

                  5:43:16,999 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.deployment.unit."extranet-sigma.war".WeldService:
                  org.jboss.msc.service.StartException in service jboss.deployment.unit."extranet-sigma.war".WeldService:
                  org.jboss.weld.exceptions.DefinitionException:
                  WELD-001502 Resource producer field [Resource Producer Field [EntityManagerFactory] with qualifiers [@Any @Default]
                  declared as [[field] @Default @ExtensionManaged @PersistenceUnit @ConversationScoped @Produces private com.natixis.extranet.sigma.services.Resources.emFactory]]
                  must be @Dependent scoped
                       at org.jboss.as.weld.services.WeldService.start(WeldService.java:96)
                       at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
                       at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
                       at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_27]
                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_27]
                       at java.lang.Thread.run(Thread.java:662) [:1.6.0_27]
                  Caused by: org.jboss.weld.exceptions.DefinitionException: WELD-001502 Resource producer field [Resource Producer Field [EntityManagerFactory] with qualifiers [@Any @Default] declared
                  as [[field] @Default @ExtensionManaged @PersistenceUnit @ConversationScoped @Produces private com.natixis.extranet.sigma.services.Resources.emFactory]] must be @Dependent scoped
                       at org.jboss.weld.bean.builtin.ee.EEResourceProducerField.checkEEResource(EEResourceProducerField.java:133)
                       at org.jboss.weld.bean.builtin.ee.EEResourceProducerField.initialize(EEResourceProducerField.java:125)
                       at org.jboss.weld.bootstrap.AbstractBeanDeployer.deploy(AbstractBeanDeployer.java:119)
                       at org.jboss.weld.bootstrap.BeanDeployment.deployBeans(BeanDeployment.java:227)
                       at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:378)
                       at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:81)
                       at org.jboss.as.weld.services.WeldService.start(WeldService.java:89)
                       ... 5 more

                  It's telling me that the emFactory field must be @Dependant scoped. The owner class of the field is below:
                  '
                  public class Resources
                  {        
                            @SuppressWarnings("unused")
                            @Produces
                            @ExtensionManaged
                            @PersistenceUnit
                            @ConversationScoped
                          private EntityManagerFactory emFactory;

                  }
                  '

                  I really don't undestant what's wrong.
                  Any idea?
                  • 6. Re: Seam Managed persistence Context Problem
                    lightguard

                    For both Meissa and Hansty is that the only thing that changed in the application was moving to Beta5?

                    • 7. Re: Seam Managed persistence Context Problem
                      hantsy

                      I did not encounter problem now.

                      • 8. Re: Seam Managed persistence Context Problem
                        lightguard

                        Okay, great. I also just tried it with Beta5 and didn't run into a problem.

                        • 9. Re: Seam Managed persistence Context Problem
                          mbsakho
                          <blockquote>
                          _Jason Porter wrote on Nov 22, 2011 01:40:_<br/>

                          Okay, great. I also just tried it with Beta5 and didn't run into a problem.
                          </blockquote>

                          I've updated seam-persistence and seam-transaction to 3.1.0.beta5.
                          I'm still having the exception below.

                          10:51:27,498 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.deployment.unit."extranet-sigma.war".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."extranet-sigma.war".WeldService: org.jboss.weld.exceptions.DefinitionException: WELD-001502 Resource producer field [Resource Producer Field [EntityManagerFactory] with qualifiers [@Any @Default] declared as [[field] @PersistenceUnit @Produces @ExtensionManaged @ConversationScoped private com.natixis.extranet.sigma.services.Resources.entityManagerFactory]] must be @Dependent scoped
                               at org.jboss.as.weld.services.WeldService.start(WeldService.java:96)
                               at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
                               at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
                               at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_27]
                               at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_27]
                               at java.lang.Thread.run(Thread.java:662) [:1.6.0_27]
                          Caused by: org.jboss.weld.exceptions.DefinitionException: WELD-001502 Resource producer field [Resource Producer Field [EntityManagerFactory] with qualifiers [@Any @Default] declared as [[field] @PersistenceUnit @Produces @ExtensionManaged @ConversationScoped private com.natixis.extranet.sigma.services.Resources.entityManagerFactory]] must be @Dependent scoped
                               at org.jboss.weld.bean.builtin.ee.EEResourceProducerField.checkEEResource(EEResourceProducerField.java:133)
                               at org.jboss.weld.bean.builtin.ee.EEResourceProducerField.initialize(EEResourceProducerField.java:125)
                               at org.jboss.weld.bootstrap.AbstractBeanDeployer.deploy(AbstractBeanDeployer.java:119)
                               at org.jboss.weld.bootstrap.BeanDeployment.deployBeans(BeanDeployment.java:227)
                               at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:378)
                               at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:81)
                               at org.jboss.as.weld.services.WeldService.start(WeldService.java:89)
                               ... 5 more

                          Are there additionnal librairies that need to be updated?

                          Meissa
                          • 10. Re: Seam Managed persistence Context Problem
                            hantsy

                            If u are using the Eclispe and m2e, switch to Dependency Hierarchy tab in the POM editor.


                            Have a look and confirm there is no conflicts.


                            I encountered some problem before , and  it was caused by dependency version conflict.

                            • 11. Re: Seam Managed persistence Context Problem
                              mbsakho

                              hantsy bai wrote on Nov 22, 2011 05:10:


                              If u are using the Eclispe and m2e, switch to Dependency Hierarchy tab in the POM editor.

                              Have a look and confirm there is no conflicts.

                              I encountered some problem before , and  it was caused by dependency version conflict.


                              I confirm that there is no conflcts in the Dependency Hierarchy of the POM Editor.


                              I really don't undestand what I've missed.
                              Meissa

                              • 12. Re: Seam Managed persistence Context Problem
                                mbsakho
                                While looking to the execption stack, I see the recurrent message below:

                                WELD-001502 Resource producer field [Resource Producer Field [EntityManagerFactory]
                                with qualifiers [@Any @Default] declared as [[field] @PersistenceUnit @ExtensionManaged @Produces @ConversationScoped
                                private com.natixis.extranet.sigma.services.Resources.entityManagerFactory]] must be @Dependent scoped

                                The class that's involved is below:
                                public class Resources
                                {          
                                                @SuppressWarnings("unused")
                                               
                                                @ExtensionManaged
                                                @Produces
                                                @PersistenceUnit
                                                @ConversationScoped
                                           private EntityManagerFactory entityManagerFactory;

                                }
                                It's just similar of what people are using here.
                                I really don't undestand the reason of the complain.

                                Meissa
                                • 13. Re: Seam Managed persistence Context Problem
                                  mbsakho

                                  I've finally managed to make it working.
                                  Tke problem was due to the solder version 3.0.0 that is not compatible with the
                                  Beta 5 version of seam persistence.
                                  Meissa

                                  • 14. Re: Seam Managed persistence Context Problem
                                    lightguard

                                    Yep, bad version of Solder. I've seen that too. Makes sure you're using the most current version of all modules.

                                    1 2 Previous Next