5 Replies Latest reply on Jul 7, 2009 9:28 AM by toddcoulson

    Unable to configure EntityManagerFactory

    toddcoulson Level 1

      I have a Blaze/Hibernate/mySQL/Java project created locally on my machine.  This did call out to the database previously.  But lately it is giving me this error on every call to the Service:

      [RPC Fault faultString="javax.persistence.PersistenceException : [PersistenceUnit: tms] Unable to configure EntityManagerFactory" faultCode="Server.Processing" faultDetail="null"]
          at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[C:\autobuild\3.3.0\frameworks\p rojects\rpc\src\mx\rpc\AbstractInvoker.as:240]
          at mx.rpc::Responder/fault()[C:\autobuild\3.3.0\frameworks\projects\rpc\src\mx\rpc\Responder .as:53]
          at mx.rpc::AsyncRequest/fault()[C:\autobuild\3.3.0\frameworks\projects\rpc\src\mx\rpc\AsyncR equest.as:103]
          at NetConnectionMessageResponder/statusHandler()[C:\autobuild\3.3.0\frameworks\projects\rpc\ src\mx\messaging\channels\NetConnectionChannel.as:569]
          at mx.messaging::MessageResponder/status()[C:\autobuild\3.3.0\frameworks\projects\rpc\src\mx \messaging\MessageResponder.as:222]

      I have the Tomcat server running that came with Blaze DS and I have mySQL db open when this message appears.  I also have the persistence.xml file setup:

      <persistence version="1.0" 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">
        <persistence-unit name="tms">
          <properties>
            <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
            <property name="hibernate.connection.url" value="jdbc:mysql://localhost/tms" />
            <property name="hibernate.connection.username" value="root" />
            <property name="hibernate.connection.password" value="pass" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
            <property name="hibernate.connection.pool_size" value="6" />
            <property name="hibernate.connection.autoReconnect" value="true" />
            <property name="hibernate.generate_statistics" value="false" />
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.use_sql_comments" value="false" />
            <property name="hibernate.hbm2ddl.auto" value="update" />
          </properties>
        </persistence-unit>
      </persistence>
      

      And my code for the UsersService I created in java (I shortened it to just the service giving problems):

      package com.pegasus.tms;
      
      import java.util.List;
       
      import javax.persistence.EntityManager;
      import javax.persistence.EntityManagerFactory;
      import javax.persistence.EntityTransaction;
      import javax.persistence.Persistence;
      import javax.persistence.Query;
       
      import org.apache.log4j.Logger;
       
      public class UsersService {           
      
          private static final String PERSISTENCE_UNIT = "tms";                  
          private static Logger logger = Logger.getLogger(UsersService.class);                
          
          public UsersService() {                              
              super();                          
          }
      
          @SuppressWarnings("unchecked")
          public List<AbstractUser> getUsers() {                       
              logger.debug("** getUsers called...");                           
              EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT);                      
              EntityManager em = entityManagerFactory.createEntityManager(); 
              
              Query findAllQuery = em.createNamedQuery("users.findAll"); 
              
              List<AbstractUser> allUsers = findAllQuery.getResultList();                       
              if (allUsers != null) logger.debug("** Found " + allUsers.size() + "records:");
              return allUsers;                        
          }
      }
      

      I would appreciate any help with this error message, I have been searching google for two days with little help.  Lots more knowledge, but nothing in particular about my problem.  Just help brainstorm this with me please.

      Thanks.

        • 1. Re: Unable to configure EntityManagerFactory
          toddcoulson Level 1

          anyone?  I cannot be the only one with this error message?

           

          It might also be worth mentioning that the tutorial I followed is here: http://www.adobe.com/devnet/flex/articles/flex_hibernate_04.html

          • 2. Re: Unable to configure EntityManagerFactory
            toddcoulson Level 1

            I am getting in my stack trace in debugging in Flex:

            "Duplicate query mapping users.findAll"

             

            Does anyone know where to set the mappings for a project of this type?  I only have one query named findAll, but not sure where it is being mapped?  TIA

            • 3. Re: Unable to configure EntityManagerFactory
              Alex Glosband Adobe Employee

              Hi. From the original error you reported it looked like the problem was outside of BlazeDS. A Server.Processing error usually means that the problem is in some code that BlazeDS is calling and not in BlazeDS itself. Have you tried taking BlazeDS out of the picture entirely? I would maybe try calling your Hibernate code from a JSP or a Servlet and see if you get the same "Unable to configure EntityManagerFactory" error. I haven't worked with Hibernate much so sorry I can't help you more. I searched on Google for that error and found a couple people asking about it but no answers as to what the cause was or how to workaround it.

               

              -Alex

              1 person found this helpful
              • 4. Re: Unable to configure EntityManagerFactory
                toddcoulson Level 1

                I found out how to debug the hibernate, and found this in the stack of errors coming back.  It appears that my querries are mapped wrong, but I don't have control over this.  I may post to their forum to see if I can solve this too.  Here is the error:

                 

                10:48:05.937  ERROR  org.hibernate.impl.SessionFactoryImpl     - Error in named query: users.findAll
                org.hibernate.hql.ast.QuerySyntaxException: Users is not mapped [from Users]
                    at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelpe r.java:181)
                    at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:110)
                    at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:93)
                    at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:277)
                    at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3056)
                    at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
                    at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
                    at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
                    at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
                    at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
                    at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:251)
                    at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:183)
                    at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:134)
                    at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
                    at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
                    at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
                    at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:436)
                    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:384)
                    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
                    at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.jav a:867)
                    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
                    at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.ja va:126)
                    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)
                    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)
                    at com.pegasus.tms.UsersService.getUsers(UsersService.java:39)
                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                    at java.lang.reflect.Method.invoke(Unknown Source)
                    at flex.messaging.services.remoting.adapters.JavaAdapter.invoke(JavaAdapter.java:421)
                    at flex.messaging.services.RemotingService.serviceMessage(RemotingService.java:183)
                    at flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java:1503)
                    at flex.messaging.endpoints.AbstractEndpoint.serviceMessage(AbstractEndpoint.java:884)
                    at flex.messaging.endpoints.amf.MessageBrokerFilter.invoke(MessageBrokerFilter.java:121)
                    at flex.messaging.endpoints.amf.LegacyFilter.invoke(LegacyFilter.java:158)
                    at flex.messaging.endpoints.amf.SessionFilter.invoke(SessionFilter.java:44)
                    at flex.messaging.endpoints.amf.BatchProcessFilter.invoke(BatchProcessFilter.java:67)
                    at flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilter.java:146)
                    at flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.java:278)
                    at flex.messaging.MessageBrokerServlet.service(MessageBrokerServlet.java:322)
                    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j ava:290)
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
                    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
                    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.ja va:584)
                    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                    at java.lang.Thread.run(Unknown Source)
                • 5. Re: Unable to configure EntityManagerFactory
                  toddcoulson Level 1

                  It ended up being an incorrect reference to the database.