Persistence unit not bound
lajoie Dec 17, 2006 11:13 AMI'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>