2 Replies Latest reply on Mar 31, 2011 1:24 AM by Thai Dang Vu

    Problem with seam persistance on jetty

    MIklos Piklos Newbie

      Hello i am still trying to make JPA work with simple maven archetype for WELD on servlet containers. I added seam-solder and seam-persistence modules (both cr 04).
      So my pom dependecies look like this:



      <dependency>
                     <groupId>org.jboss.seam.persistence</groupId>
                     <artifactId>seam-persistence</artifactId>
                     <version>${seam.solder.version}</version>
                </dependency>
                
                <dependency>
                     <groupId>org.jboss.logging</groupId>
                     <artifactId>jboss-logging</artifactId>
                     <version>3.0.0.Beta4</version>
                </dependency>
                
                 <dependency>
                <groupId>hsqldb</groupId>
                <artifactId>hsqldb</artifactId>
                <version>1.8.0.5</version>
              </dependency>
                
                <dependency>
                     <groupId>org.hibernate</groupId>
                     <artifactId>hibernate-core</artifactId>
                     <version>3.5.6-Final</version>
                </dependency>
                <dependency>     
                     <groupId>org.hibernate.javax.persistence</groupId>
                     <artifactId>hibernate-jpa-2.0-api</artifactId>
                     <version>1.0.0-CR-1</version>
                </dependency>
                 <dependency>
                  <groupId>org.hibernate</groupId>
                  <artifactId>hibernate-annotations</artifactId>
                  <version>3.3.1.GA</version>
              </dependency>
               <dependency>
                  <groupId>org.hibernate</groupId>
                  <artifactId>hibernate-commons-annotations</artifactId>
                  <version>3.1.0.GA</version>
              </dependency>
        
      
                <!-- Common to JEE and Servlet containers -->
                <dependency>
                     <groupId>javax.enterprise</groupId>
                     <artifactId>cdi-api</artifactId>
                     <scope>provided</scope>
                </dependency>
      
                <dependency>
                     <groupId>javax.annotation</groupId>
                     <artifactId>jsr250-api</artifactId>
                     <scope>provided</scope>
                </dependency>
      
                <dependency>
                     <groupId>javax.servlet</groupId>
                     <artifactId>servlet-api</artifactId>
                     <version>2.5</version>
                     <scope>provided</scope>
                </dependency>
      
                <!-- <dependency> <groupId>javax.el</groupId> <artifactId>el-api</artifactId> 
                     <version>2.2.1-b04</version> <scope>compile</scope> </dependency> <dependency> 
                     <groupId>org.glassfish.web</groupId> <artifactId>el-impl</artifactId> <version>2.2.1-b04</version> 
                     <scope>runtime</scope> </dependency> -->
      
                <dependency>
                     <groupId>org.jboss.weld.servlet</groupId>
                     <artifactId>weld-servlet</artifactId>
                     <scope>runtime</scope>
                </dependency>
      
                <dependency>
                     <groupId>org.jboss.seam.solder</groupId>
                     <artifactId>seam-solder</artifactId>
                     <version>${seam.solder.version}</version>
                </dependency>
      
                <!-- Bean Validation API (JSR 303) -->
                <dependency>
                     <groupId>javax.validation</groupId>
                     <artifactId>validation-api</artifactId>
                </dependency>
      
                <!-- Bean Validation Implementation -->
                <!-- Provides portable constraints such as @NotEmpty, @Email and @Url -->
                <dependency>
                     <groupId>org.hibernate</groupId>
                     <artifactId>hibernate-validator</artifactId>
                     <version>4.0.0.GA</version>
                </dependency>
      
                <dependency>
                     <groupId>junit</groupId>
                     <artifactId>junit</artifactId>
                     <version>4.8.1</version>
                     <scope>test</scope>
                </dependency>
      
                <dependency>
                     <groupId>org.jboss.arquillian</groupId>
                     <artifactId>arquillian-junit</artifactId>
                     <version>${version.arquillian}</version>
                     <scope>test</scope>
                </dependency>
           </dependencies>



      I also added persistence.xml with the following entries:



      <?xml version="1.0" encoding="UTF-8"?>
      <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
          <persistence-unit name="foo" transaction-type="RESOURCE_LOCAL">
              <provider>org.hibernate.ejb.HibernatePersistence</provider>
                  <properties>
                      <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
                      <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" />
                      <property name="hibernate.connection.username" value="sa" />
                      <property name="hibernate.connection.password" value="" />
                      <property name="hibernate.connection.url" value="jdbc:hsqldb:mem:todo" />
                      <property name="hibernate.hbm2ddl.auto" value="create" />
                  </properties>
              </persistence-unit>
      </persistence>



      My bean xml looks like this:



      <beans xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:s="urn:java:ee" 
         xmlns:t="urn:java:org.jboss.seam.persistence.transaction"
         xsi:schemaLocation="
            http://java.sun.com/xml/ns/javaee 
            http://docs.jboss.org/cdi/beans_1_0.xsd">
      
            <t:SeSynchronizations>
               <s:modifies/>
            </t:SeSynchronizations>
      
            <t:EntityTransaction>
               <s:modifies />         
            </t:EntityTransaction>
      </beans>



      i have a class that has



      public class EmProducer {
           
           @ExtensionManaged
           @Produces
           @PersistenceUnit
           @ConversationScoped
           EntityManagerFactory producerField;
      }



      But i cannot inject entity manager anywhere.


      I tried obtaining it via


      Persistence.createEntityManagerFactory("foo")



      But i always get an exception:




       javax.persistence.PersistenceException: No Persistence provider for EntityManager named foo



      It is a strage because i named my persistance unit in persistance xml foo.
      Any help would be appreciated.


      Thanks in advance.