10 Replies Latest reply on Dec 29, 2009 2:03 PM by Mohamed Himi

    Seam-gen from Seam In Action by Dan Allen

    Paul Meehan Newbie
      Hi

      Due to a problem with the H2 database I followed the advice of another poster in a related thread and switched to using MySql with seam-gen. I manually populated the database using the sql scripts provided by Dan Allen in the source code accompanying his book. This has delivered limited success.When I try to open the HoleList page for example I get the following error:

      Could not instantiate Seam component: holeList

      Here is the top end of the stack trace:

      org.jboss.seam.InstantiationException: Could not instantiate Seam component: holeList
      at org.jboss.seam.Component.newInstance(Component.java:2144)
      at org.jboss.seam.Component.getInstance(Component.java:2021)
      at org.jboss.seam.Component.getInstance(Component.java:1983)
      at org.jboss.seam.Component.getInstance(Component.java:1977)
      at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
      at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
      at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:148)
      at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:51)
      at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)

      Heer is the bottom end of the stack trace:

      Caused by: javax.naming.NameNotFoundException: entityManager 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:667)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:241)
      ... 126 more


      I do have a holeList.class action class under WEB-INF\dev.

      Has anyone encountered this error before or understand why it might be happening?

      thanks
      Paul Meehan
        • 1. Re: Seam-gen from Seam In Action by Dan Allen
          Rodrigo Dellacqua Newbie

          Hey Paul,


          I dont know whats going on, because I have 3 posts about problems in the latest seam-gen (in my case I use postgresql) and nobody answers, like theres an NDA on seam-gen.


          I don't wanna make you lose your hopes, but my opnion now, is. Seam-gen DOESNT WORK.


          I just went deeper into the book and got the stuff done manually.


          Dellacqua

          • 2. Re: Seam-gen from Seam In Action by Dan Allen
            Stuart Douglas Master

            post your persistence.xml and components.xml. The problem is that the server cannot get the entityManager from JNDI.


            Also what app server are you using.

            • 3. Re: Seam-gen from Seam In Action by Dan Allen
              Paul Meehan Newbie
              Thank you to both posters who replied!

              I am using jboss-4.2.2.GA

              HERE IS MY components.xml:

              <?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:drools="http://jboss.com/products/seam/drools"
                          xmlns:bpm="http://jboss.com/products/seam/bpm"
                          xmlns:security="http://jboss.com/products/seam/security"
                          xmlns:mail="http://jboss.com/products/seam/mail"
                          xmlns:web="http://jboss.com/products/seam/web"
                          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                          xsi:schemaLocation=
                              "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.2.xsd
                               http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.2.xsd
                               http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.2.xsd
                               http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.2.xsd
                               http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.2.xsd
                               http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.2.xsd
                               http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.2.xsd
                               http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.2.xsd">

                 <core:init debug="@debug@" jndi-pattern="@jndiPattern@"/>

                 <core:manager concurrent-request-timeout="500"
                               conversation-timeout="120000"
                               conversation-id-parameter="cid"
                               parent-conversation-id-parameter="pid"/>

                 <!-- Make sure this URL pattern is the same as that used by the Faces Servlet -->
                 <web:hot-deploy-filter url-pattern="*.seam"/>

                 <!-- If you are still using JBoss 4, uncomment this to have you PU started -->
                 <persistence:entity-manager-factory name="entityManagerFactory"
                                    persistence-unit-name="open18"
                                                installed="@seamBootstrapsPu@"/>

                 <persistence:managed-persistence-context name="entityManager" auto-create="true"
                                        entity-manager-factory="@seamEmfRef@"
                                    persistence-unit-jndi-name="@puJndiName@"/>

                 <drools:rule-base name="securityRules">
                    <drools:rule-files><value>/security.drl</value></drools:rule-files>
                 </drools:rule-base>

                 <security:rule-based-permission-resolver security-rules="#{securityRules}"/>

                 <security:identity authenticate-method="#{authenticator.authenticate}" remember-me="true"/>

                 <event type="org.jboss.seam.security.notLoggedIn">
                    <action execute="#{redirect.captureCurrentView}"/>
                 </event>
                 <event type="org.jboss.seam.security.loginSuccessful">
                    <action execute="#{redirect.returnToCapturedView}"/>
                 </event>

                 <mail:mail-session host="localhost" port="25"/>

                 <!-- For use with jBPM pageflow or process management -->
                 <!--
                 <bpm:jbpm>
                    <bpm:process-definitions></bpm:process-definitions>
                    <bpm:pageflow-definitions></bpm:pageflow-definitions>
                 </bpm:jbpm>
                 -->

              </components>

              HERE IS MY persistence.xml for the dev profile (persistence-dev.xml):

              <?xml version="1.0" encoding="UTF-8"?>
              <!-- Persistence deployment descriptor for dev profile -->
              <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="open18" transaction-type="JTA">
                    <provider>org.hibernate.ejb.HibernatePersistence</provider>
                    <jta-data-source>open18Datasource</jta-data-source>
                    <properties>
                       <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
                       <property name="hibernate.hbm2ddl.auto" value="update"/>
                       <property name="hibernate.show_sql" value="true"/>
                       <property name="hibernate.format_sql" value="true"/>
                       <property name="hibernate.default_catalog" value="open18"/>
                       <property name="hibernate.default_schema" value="open18"/>
                       <!-- Only relevant if Seam is loading the persistence unit (Java SE bootstrap) -->
                       <property name="hibernate.transaction.manager_lookup_class" value="@transactionManagerLookupClass@"/>
                    </properties>
                 </persistence-unit>
                 
              </persistence>



              THANK YOU
              • 4. Re: Seam-gen from Seam In Action by Dan Allen
                Paul Meehan Newbie
                I upgraded to version 5 of JBOSS AS and the problem seems to have gone away. But I do get a new exception now:

                org.jboss.seam.InstantiationException: Could not instantiate Seam component: courseList
                     at org.jboss.seam.Component.newInstance(Component.java:2144)
                     at org.jboss.seam.Component.getInstance(Component.java:2021)
                     at org.jboss.seam.Component.getInstance(Component.java:1983)
                     at org.jboss.seam.Component.getInstance(Component.java:1977)
                     at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
                     at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
                     at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:148)
                     at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:51)
                     at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
                     at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
                     at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
                     at org.jboss.el.parser.AstValue.getValue(AstValue.java:63)
                     at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
                     at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
                     at javax.faces.component.UIOutput.getValue(UIOutput.java:184)
                     at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:201)
                     at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:284)
                     at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:154)
                     at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:861)
                     at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:190)
                     at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
                     at org.jboss.seam.ui.renderkit.DecorateRendererBase.doEncodeChildren(DecorateRendererBase.java:152)
                     at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
                     at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
                     at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:277)
                     at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
                     at org.richfaces.renderkit.html.SimpleToggleControlTemplate.doEncodeChildren(SimpleToggleControlTemplate.java:347)
                     at org.richfaces.renderkit.html.SimpleToggleControlTemplate.doEncodeChildren(SimpleToggleControlTemplate.java:342)
                     at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
                     at org.richfaces.renderkit.html.SimpleTogglePanelRenderer.encodeChildren(SimpleTogglePanelRenderer.java:186)
                     at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
                     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
                     at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
                     at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
                     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
                     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
                     at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
                     at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
                     at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
                     at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
                     at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
                     at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
                     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
                     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                     at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                     at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                     at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                     at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                     at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                     at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                     at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
                     at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
                     at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                     at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                     at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
                     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                     at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                     at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
                     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                     at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
                     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
                     at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
                     at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
                     at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
                     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                     at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
                     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
                     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
                     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
                     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                     at java.lang.Thread.run(Thread.java:619)
                Caused by: java.lang.NullPointerException
                     at org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.nextTimestamp(RegionFactoryCacheProviderBridge.java:85)
                     at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:526)
                     at org.hibernate.ejb.EntityManagerImpl.getRawSession(EntityManagerImpl.java:87)
                     at org.hibernate.ejb.EntityManagerImpl.getSession(EntityManagerImpl.java:67)
                     at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:436)
                     at org.hibernate.ejb.AbstractEntityManagerImpl.postInit(AbstractEntityManagerImpl.java:82)
                     at org.hibernate.ejb.EntityManagerImpl.<init>(EntityManagerImpl.java:61)
                     at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:39)
                     at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:34)
                     at org.jboss.jpa.injection.InjectedEntityManagerFactory.createEntityManager(InjectedEntityManagerFactory.java:82)
                     at org.jboss.seam.persistence.ManagedPersistenceContext.initEntityManager(ManagedPersistenceContext.java:78)
                     at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManager(ManagedPersistenceContext.java:107)
                     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:597)
                     at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
                     at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
                     at org.jboss.seam.Component.callComponentMethod(Component.java:2249)
                     at org.jboss.seam.Component.unwrap(Component.java:2275)
                     at org.jboss.seam.Component.getInstance(Component.java:2041)
                     at org.jboss.seam.Component.getInstance(Component.java:1983)
                     at org.jboss.seam.Component.getInstance(Component.java:1977)
                     at org.jboss.seam.Component.getInstance(Component.java:1972)
                     at org.jboss.seam.framework.Controller.getComponentInstance(Controller.java:272)
                     at org.jboss.seam.framework.PersistenceController.getPersistenceContext(PersistenceController.java:20)
                     at org.jboss.seam.framework.EntityQuery.getEntityManager(EntityQuery.java:159)
                     at org.jboss.seam.framework.EntityQuery.validate(EntityQuery.java:39)
                     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:597)
                     at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
                     at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
                     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                     at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
                     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                     at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:97)
                     at org.jboss.seam.util.Work.workInTransaction(Work.java:47)
                     at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:91)
                     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                     at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
                     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                     at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
                     at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
                     at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
                     at com.mydomain.open18.action.CourseList_$$_javassist_seam_2.validate(CourseList_$$_javassist_seam_2.java)
                     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:597)
                     at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
                     at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
                     at org.jboss.seam.Component.callComponentMethod(Component.java:2249)
                     at org.jboss.seam.Component.callCreateMethod(Component.java:2172)
                     at org.jboss.seam.Component.newInstance(Component.java:2132)
                     ... 85 more
                • 5. Re: Seam-gen from Seam In Action by Dan Allen
                  Paul Meehan Newbie

                  NullPointerException it seems?

                  • 6. Re: Seam-gen from Seam In Action by Dan Allen
                    Stuart Douglas Master

                    This bit is the problem:


                    
                     at org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.nextTimestamp(RegionFactoryCacheProviderBridge.java:85)
                    



                    This is to do with the hibernate 2nd level cache (I think), which seems odd considering you do not have it enabled in persistence.xml

                    • 7. Re: Seam-gen from Seam In Action by Dan Allen
                      Paul Meehan Newbie

                      Rodrigo Dellacqua might be right. Maybe it's time to give up on seam-gen and start doing stuff manually - unless someone else has the last word?

                      • 8. Re: Seam-gen from Seam In Action by Dan Allen
                        Rodrigo Dellacqua Newbie

                        Just like my other post, Stuart was the only one that tried to help.


                        Nobody else cares..


                        Thx Stuart!

                        • 9. Re: Seam-gen from Seam In Action by Dan Allen
                          Paul Meehan Newbie

                          Thanks for the reality check. I wish you well.

                          • 10. Re: Seam-gen from Seam In Action by Dan Allen
                            Mohamed Himi Newbie

                            I had struggled this day with this issue.
                            It seems it has to do with seam 2.2.0 GA in combination with jboss as 4.2.2GA. Seam-gen generates the project, you can deploye it, all goes fine, till you trigger an action in the UI...then you get the entityManager not found issue. I have tried to reverse engineer from H2 and SQL server database, but no difference. I think it's more a jndi lookup issue.


                            Btw, creating seam project using the jboss tools plug-ins, works fine. But you get a project without ant build preparation.


                            I discovered that, Seam-gen works fine, when using seam 2.1.2 distribution in combination with jboss as 4.2.2GA.