4 Replies Latest reply on Dec 17, 2006 2:50 PM by lajoie

    Persistence unit not bound

    lajoie

      I'm using SEAM 1.1 with the embedded EJB container running inside Tomcat (JBoss Tomcat for development and plain ol' Apache Tomcat at the customer's site). For the purposes of development I'm using an in-memory HSQLDB database defined in jboss-beans.xml.

      Everything seems to start up fine, I see all my entity and stateless session beans get created, I see the datasource I define get created and get bound under the given JNDI name. However, when I try to load a page that uses a stateless bean I get an exception that a bean can not be instantiated with a root cause of:

      javax.naming.NameNotFoundException: portal not bound


      where "portal" is the name of my persistence context.

      Any suggestions? I imagine I'm either missing some nuance about how these config files are working together or incorrectly assuming that the "portal" referred to in the error is the "portal" persistence unit.

      Thanks.

      jboss-beans.xml - define the data source w/ JNDI name
      <deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
       xmlns="urn:jboss:bean-deployer">
      
       <bean name="PortalDatasourceBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
       <property name="driverClass">org.hsqldb.jdbcDriver</property>
       <property name="connectionURL">jdbc:hsqldb:mem:portal</property>
       <property name="userName"><value class="java.lang.String">sa</value></property>
       <property name="password"><value class="java.lang.String"></value></property>
       <property name="jndiName">java:/PortalDatasource</property>
       <property name="minSize">0</property>
       <property name="maxSize">10</property>
       <property name="blockingTimeout">1000</property>
       <property name="idleTimeout">100000</property>
       <property name="transactionManager"><inject bean="TransactionManager"/></property>
       <property name="cachedConnectionManager"><inject bean="CachedConnectionManager"/></property>
       <property name="initialContextProperties"><inject bean="InitialContextProperties"/></property>
       </bean>
      
       <bean name="PortalDatasource" class="java.lang.Object">
       <constructor factoryMethod="getDatasource">
       <factory bean="PortalDatasourceBootstrap"/>
       </constructor>
       </bean>
      
      </deployment>
      


      components.xml - create entity manager and bind to JNDI
      <components xmlns="http://jboss.com/products/seam/components"
       xmlns:core="http://jboss.com/products/seam/core"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://jboss.com/products/seam/core http://jboss.com/products/seam/core-1.1.xsd
       http://jboss.com/products/seam/components http://jboss.com/products/seam/components-1.1.xsd">
      
       <core:init jndi-pattern="@jndiPattern@" debug="true" />
      
       <core:pages no-conversation-view-id="/main.xhtml" />
      
       <core:manager conversation-timeout="120000"
       concurrent-request-timeout="500" conversation-id-parameter="cid"
       conversation-is-long-running-parameter="clr" />
      
       <core:ejb installed="true" />
      
       <core:managed-persistence-context name="PortalDatabase"
       auto-create="true"
       persistence-unit-jndi-name="java:/PortalEntityManagerFactory" />
      
       <component name="StringConverter"
       class="javax.faces.convert.CharacterConverter" />
      
      </components>
      


      persistence.xml - Define persistence unit reference datasource and entity manager
      <persistence>
       <persistence-unit name="portal">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:/PortalDatasource</jta-data-source>
       <properties>
       <property name="hibernate.hbm2ddl.auto" value="update"/>
       <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:/PortalEntityManagerFactory"/>
       </properties>
       </persistence-unit>
      
      </persistence>
      




        • 1. Re: Persistence unit not bound
          gavin.king

          stack trace?

          • 2. Re: Persistence unit not bound
            lajoie

             

            10:57:32,801 INFO [STDOUT] 10:57:32,801 DEBUG [SeamVariableResolver] resolving name: basicSearch
            10:57:32,802 INFO [STDOUT] 10:57:32,802 DEBUG [Component] instantiating Seam component: basicSearch
            10:57:32,802 INFO [STDOUT] 10:57:32,802 DEBUG [Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.LocalOnlyContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
            10:57:32,804 ERROR [STDERR] Dec 17, 2006 10:57:32 AM com.sun.facelets.FaceletViewHandler handleRenderException
            SEVERE: Error Rendering View[/basicSearch.xhtml]
            org.jboss.seam.InstantiationException: Could not instantiate Seam component: basicSearch
             at org.jboss.seam.Component.newInstance(Component.java:1722)
             at org.jboss.seam.Component.getInstance(Component.java:1625)
             at org.jboss.seam.Component.getInstance(Component.java:1592)
             at org.jboss.seam.jsf.SeamVariableResolver.resolveVariable(SeamVariableResolver.java:46)
             at org.apache.myfaces.config.LastVariableResolverInChain.resolveVariable(LastVariableResolverInChain.java:42)
             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.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.UIOutput.getValue(UIOutput.java:77)
             at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getStringValue(RendererUtils.java:217)
             at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.renderInput(HtmlTextRendererBase.java:135)
             at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:53)
             at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:536)
             at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:242)
             at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
             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:384)
             at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
             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:613)
            Caused by: javax.naming.NameNotFoundException: portal 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:267)
             at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:626)
             at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:588)
             at javax.naming.InitialContext.lookup(InitialContext.java:351)
             at org.jboss.seam.Component.instantiateSessionBean(Component.java:1027)
             at org.jboss.seam.Component.instantiate(Component.java:1013)
             at org.jboss.seam.Component.newInstance(Component.java:1718)
             ... 45 more
            


            • 3. Re: Persistence unit not bound
              gavin.king

              So its nothing to do with the persistence unit. Seam can't locate the session bean in JNDI. Maybe your jndi-pattern is wrong.

              • 4. Re: Persistence unit not bound
                lajoie

                Sure enough. I had a spurious "portal" prefixed to the jndi-path in the components.xml.

                Thanks Gavin.