5 Replies Latest reply on Nov 29, 2006 6:43 AM by Andrew Gavrilov

    Error with SeamGen

    Andrew Gavrilov Newbie

      I do the following:
      - Create database.
      - run "seam generate-enties"
      - run "seam restart"
      - Go to the page and it looks ok, but after clicking on one of the menu items I got "EntityManagerFactory not found in JNDI". I found what it's an error from Seam sources, however I don't know how to fix it.

      java.lang.IllegalArgumentException: EntityManagerFactory not found in JNDI
       at org.jboss.seam.core.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:145)
       at org.jboss.seam.core.ManagedPersistenceContext.createEntityManager(ManagedPersistenceContext.java:88)
       at org.jboss.seam.core.ManagedPersistenceContext.create(ManagedPersistenceContext.java:69)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
       at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:102)
       at org.jboss.seam.Component.callComponentMethod(Component.java:1767)
       at org.jboss.seam.Component.callCreateMethod(Component.java:1707)
       at org.jboss.seam.Component.newInstance(Component.java:1696)
       at org.jboss.seam.Component.getInstance(Component.java:1600)
       at org.jboss.seam.Component.getInstance(Component.java:1567)
       at org.jboss.seam.Component.getInstance(Component.java:1561)
       at org.jboss.seam.framework.EntityQuery.getEntityManager(EntityQuery.java:82)
       at org.jboss.seam.framework.EntityQuery.validate(EntityQuery.java:25)
       at org.jboss.seam.framework.EntityQuery$$FastClassByCGLIB$$225925e6.invoke(<generated>)
       at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
       at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:45)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:55)
       at org.jboss.seam.interceptors.OutcomeInterceptor.interceptOutcome(OutcomeInterceptor.java:23)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
       at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
       at org.jboss.seam.interceptors.RollbackInterceptor.rollbackIfNecessary(RollbackInterceptor.java:33)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
       at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
       at org.jboss.seam.interceptors.BijectionInterceptor.bijectTargetComponent(BijectionInterceptor.java:51)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
       at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
       at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor.java:51)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
       at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
       at org.jboss.seam.interceptors.TransactionInterceptor$1.work(TransactionInterceptor.java:25)
       at org.jboss.seam.util.Work.workInTransaction(Work.java:31)
       at org.jboss.seam.interceptors.TransactionInterceptor.doInTransactionIfNecessary(TransactionInterceptor.java:19)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
       at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
       at org.jboss.seam.interceptors.ExceptionInterceptor.handleExceptions(ExceptionInterceptor.java:28)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
       at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
       at org.jboss.seam.intercept.RootInterceptor.createSeamInvocationContext(RootInterceptor.java:144)
       at org.jboss.seam.intercept.RootInterceptor.invokeInContexts(RootInterceptor.java:129)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:102)
       at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:140)
       at org.jboss.seam.intercept.JavaBeanInterceptor.intercept(JavaBeanInterceptor.java:75)
       at ru.nsk.stealth.seam_test.UserList$$EnhancerByCGLIB$$f892238d.validate(<generated>)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
       at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:102)
       at org.jboss.seam.Component.callComponentMethod(Component.java:1759)
       at org.jboss.seam.Component.callCreateMethod(Component.java:1707)
       at org.jboss.seam.Component.newInstance(Component.java:1696)
       at org.jboss.seam.Component.getInstance(Component.java:1600)
       at org.jboss.seam.Component.getInstance(Component.java:1567)
       at org.jboss.seam.jsf.SeamVariableResolver.resolveVariable(SeamVariableResolver.java:45)
       at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:134)
       at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:65)
       at com.sun.el.parser.AstValue.getValue(AstValue.java:106)
       at com.sun.el.parser.AstEmpty.getValue(AstEmpty.java:49)
       at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
       at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
       at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:56)
       at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:822)
       at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:231)
       at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:580)
       at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:32)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:46)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: javax.naming.NameNotFoundException: seam_testEntityManagerFactory not bound
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
       at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
       at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
       at javax.naming.InitialContext.lookup(InitialContext.java:351)
       at org.jboss.seam.core.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:141)
       ... 125 more


        • 1. Re: Error with SeamGen
          Gavin King Master

          what does persistence.xml look like. What does components.xml look like?

          • 2. Re: Error with SeamGen
            Andrew Gavrilov Newbie

            All code is autogenerated.

            persistence.xml

            <persistence>
             <persistence-unit name="seam_test">
             <provider>org.hibernate.ejb.HibernatePersistence</provider>
             <jta-data-source>java:/seam_testDatasource</jta-data-source>
             <properties>
             <property name="hibernate.hbm2ddl.auto" value="validate"/>
             <property name="hibernate.cache.use_query_cache" value="true"/>
             <property name="hibernate.show_sql" value="true"/>
             <property name="jboss.entity.manager.factory.jndi.name" value="java:/seam_testEntityManagerFactory"/>
             </properties>
             </persistence-unit>
            </persistence>
            


            components.xml
            <?xml version="1.0" ?>
            <!DOCTYPE components PUBLIC
             "-//JBoss/Seam Component Configuration DTD 1.1//EN"
             "http://jboss.com/products/seam/components-1.1.dtd">
            
            <components>
            
             <component name="org.jboss.seam.core.init">
             <property name="debug">true</property>
             <property name="jndiPattern">@jndiPattern@</property>
             </component>
            
             <component name="org.jboss.seam.core.manager">
             <!-- half second wait for conversation lock on concurrent requests -->
             <property name="concurrentRequestTimeout">500</property>
             <!-- 120 second conversation timeout -->
             <property name="conversationTimeout">120000</property>
             <property name="conversationIdParameter">cid</property>
             <property name="conversationIsLongRunningParameter">clr</property>
             </component>
            
             <component name="org.jboss.seam.core.pages">
             <property name="noConversationViewId">/home.xhtml</property>
             </component>
            
             <component name="entityManager"
             class="org.jboss.seam.core.ManagedPersistenceContext">
             <property name="persistenceUnitJndiName">java:/seam_testEntityManagerFactory</property>
             </component>
            
             <component class="org.jboss.seam.core.Ejb" installed="@embeddedEjb@"/>
            
             <!-- For use with jBPM pageflow or process management -->
             <!--
             <component class="org.jboss.seam.core.Jbpm">
             <property name="processDefinitions"></property>
             <property name="pageflowDefinitions"></property>
             </component>
             -->
            
            </components>


            • 3. Re: Error with SeamGen
              Gavin King Master

              I bet there are other errors in your startup log.

              • 4. Re: Error with SeamGen
                Andrew Gavrilov Newbie

                Yes, found a lot of them, but this obe seems to be a root:

                ObjectName: persistence.units:ear=seam_test.ear,unitName=seam_test
                 State: FAILED
                 Reason: org.hibernate.HibernateException: Wrong column type: fields, expected: bytea
                 I Depend On:
                 jboss.jca:service=ManagedConnectionFactory,name=seam_testDatasource
                


                Probably it's due to using postgresql. I'll do some checks, but looks like hibernate can't work with some postgres datatypes and seam_gen doesn't inform about it.

                • 5. Re: Error with SeamGen
                  Andrew Gavrilov Newbie

                  Yes, I was correct. The error is caused by Postgres arrays.

                  I think this isse needs to be fixed somehow. At least by skipping fields of non-standard types. Here is the generate class with array:

                  @Entity
                  @Table(name = "tt", schema = "public", uniqueConstraints = {})
                  public class Tt implements java.io.Serializable {
                  
                   // Fields
                  
                   private long id;
                   private String name;
                   private Serializable arr;
                  
                   // Constructors
                  
                   /** default constructor */
                   public Tt() {
                   }
                  
                   /** minimal constructor */
                   public Tt(long id) {
                   this.id = id;
                   }
                   /** full constructor */
                   public Tt(long id, String name, Serializable arr) {
                   this.id = id;
                   this.name = name;
                   this.arr = arr;
                   }
                  
                   // Property accessors
                   @Id
                   @Column(name = "id", unique = true, nullable = false)
                   @NotNull
                   public long getId() {
                   return this.id;
                   }
                  
                   public void setId(long id) {
                   this.id = id;
                   }
                  
                   @Column(name = "name")
                   public String getName() {
                   return this.name;
                   }
                  
                   public void setName(String name) {
                   this.name = name;
                   }
                  
                   @Column(name = "arr")
                   public Serializable getArr() {
                   return this.arr;
                   }
                  
                   public void setArr(Serializable arr) {
                   this.arr = arr;
                   }
                  
                  }