3 Replies Latest reply on Jul 16, 2007 10:21 AM by Jason Lee

    Seam 2 beta and JPA

    Jason Lee Newbie

      I'm trying to get a Seam 2 app working under OC4J 10.1.3. It's going mostly OK, but I'm getting some exceptions regarding my EntityManagerFactory that I can't seem to figure out. Here are my persistence.xml and components.xml files:

      <persistence xmlns="http://java.sun.com/xml/ns/persistence"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
       version="1.0">
       <persistence-unit name="em" transaction-type="RESOURCE_LOCAL">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>jdbc/Dev</jta-data-source>
       <!-- Snip -->
       <exclude-unlisted-classes>true</exclude-unlisted-classes>
       <properties>
       <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
       </properties>
       </persistence-unit>
      </persistence>
      


      and

      <?xml version="1.0" encoding="UTF-8"?>
      <components xmlns="http://jboss.com/products/seam/components"
       xmlns:core="http://jboss.com/products/seam/core"
       xmlns:persistence="http://jboss.com/products/seam/persistence"
       xmlns:security="http://jboss.com/products/seam/security"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation=
       "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd
       http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd
       http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
       http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd">
      
       <core:init debug="false"/>
      
       <core:manager conversation-timeout="120000"
       concurrent-request-timeout="500"
       conversation-id-parameter="cid"/>
      
      
       <persistence:entity-manager-factory name="entityManagerFactory">
       </persistence:entity-manager-factory>
       <persistence:managed-persistence-context name="entityManager"
       auto-create="true"
       entity-manager-factory="#{entityManagerFactory}" />
      </components>


      The exception I get varies, but currently I'm getting "org.hibernate.HibernateException: Hibernate Dialect must be explicitly set" but it looks to me like it is being set. What am I missing?

      Thanks!

        • 1. Re: Seam 2 beta and JPA
          Norman Richards Master

          I don't know if it is the issue you are facing, but I get that same error message when I forget to start the database and run a Seam application.

          • 2. Re: Seam 2 beta and JPA
            Jason Lee Newbie

            I'm not 100% sure what you mean by that, but, taking the simplest explanation :P I can connect to the DB (pgsql) using a variety of tools, and I can ping the connection pool from the GlassFish admin tool. I'm specifying the dialect in my persistence.xml, and connectivity with the DBMS seems to be fine. I'm at a loss for what to do. I have to have a prototype working by Wednesday at noon, and I had hoped to be using Seam to get it going. I had it working with Spring and decided to give Seam a shot at handling the EMF/EM as that looks like a more elegant solution, but I'll take working over elegant if I have to. :P Thanks!

            • 3. Re: Seam 2 beta and JPA
              Jason Lee Newbie

              I have removed the reference to the Hibernate persistence provider in my persistence.xml. Now I get these two errors when I deploy:

              Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error opening socket to server localhost on port 1527 with message : Connection refused: no further information;_RequestID=9a3c9def-0d6d-4b07-9ebf-4884caec03cf;|RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error opening socket to server localhost on port 1527 with message : Connection refused: no further information]


              Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener java.lang.NullPointerException
               at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:120)
               at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
               at org.jboss.seam.persistence.EntityManagerFactory.startup(EntityManagerFactory.java:72)


              If I had to guess, I'd say the first error is due to the Seam stuff trying to connect to a JNDI server, but I have no idea on the second. I guess I'm just going to have to revert to Spring-managed EMs for the time being, which is a pity, but I'm running out of time. :|