3 Replies Latest reply on Jan 23, 2013 5:53 AM by garethed

    Problem with Spring and Persistence

    garethed

      Hello,

       

      I'm creating a jbpm 5.4 web-app.  I am using spring for some restful services.

      I have a persistence.xml in META-INF which seems to start up correctly.

      The problem manifests when I try to add the following spring bean into my applicationContext.xml

       

        <bean id="jbpmEMF"

             class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">

             <property name="persistenceUnitName" value="org.jbpm.persistence.jta" />

        </bean>

       

      The error is:

       

      Error creating bean with name 'jbpmEMF' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No persistence unit with name 'org.jbpm.persistence.jta' found

       

      It seems like a spring problem as I'm pretty sure that the persistence unit has been created.

       

      I'm running jboss from eclipse Juno.

       

      update:

       

      It is not related to running from Eclipse, I tried deploying the war.

       

      Any ideas?

       

      Gareth.



        • 1. Re: Problem with Spring and Persistence
          garethed

          I'm just doing this instead now:

           

          if (emf == null){

                                        emf = Persistence.createEntityManagerFactory( "org.jbpm.persistence.jpa" );

                                        Environment env = KnowledgeBaseFactory.newEnvironment();

                                        env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );

                              }

            return emf;

          • 2. Re: Problem with Spring and Persistence
            swiderski.maciej

            notice that you have different names in both cases, in spring config you define org.jbpm.persistence.jta and in code you use org.jbpm.persistence.jpa. maybe that's just typo in spring config that you have jta instead of jpa?

             

            HTH

            • 3. Re: Problem with Spring and Persistence
              garethed

              That is embarrassing, I can't believe I didn't spot that.

               

              Thanks.