| Author |
Jboss-seam EJB 3.0 "not bound" error.....
|
Brian Oleksa
Greenhorn
Joined: Jun 05, 2007
Posts: 15
|
|
I get this error when I try to persist/query data from DB using Jboss seam EJB 3.0 technologies. Caused by: javax.naming.NameNotFoundException:GenerateChartFromDBDataAction not bound. Here is my code: Here is my bean: package org.jboss.priscus; import static org.jboss.seam.ScopeType.SESSION; import java.io.Serializable; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope; @Entity @Name("databean") @Scope(SESSION) @Table(name="sarecord") public class DataBean implements Serializable { private long id; private int time; private int node; public DataBean(){} @Id public long getId() { return id; } public void setId(long id) { this.id = id; } public int getNode() { return node; } public void setNode(int node) { this.node = node; } public int getTime() { return time; } public void setTime(int time) { this.time = time; } } Here is my action class package org.jboss.priscus; import static org.jboss.seam.ScopeType.SESSION; import java.util.List; import javax.ejb.Remove; import javax.ejb.Stateful; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import org.jboss.seam.annotations.Create; import org.jboss.seam.annotations.Destroy; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Out; import org.jboss.seam.annotations.Scope; @Stateful @Name("genchartfromdb") @Scope(SESSION) public class GenerateChartFromDBDataAction implements GenerateChartFromDBData { @In @Out private DataBean databean; private List<DataBean> listOfBeans; @PersistenceContext private EntityManager em; public String getSomeData() { try { em.persist(databean); find(); } catch (Exception e) { e.printStackTrace(); System.out.println("Problem in the GenerateChartFromDBActionclass...."); } return "chartoutcomefromdbusingejb"; } @Create public void find () { System.out.println("Find called"); listOfBeans = em.createQuery("select * from public.SARECORD") .getResultList(); } @Destroy @Remove public void destroy() {} } Here is my interface package org.jboss.priscus; import javax.ejb.Local; @Local public interface GenerateChartFromDBData { public String getSomeData(); } Here is my persistence.xml file <?xml version="1.0" encoding="UTF-8"?> <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="Priscus"> <provider>org.jpox.jpa.PersistenceProviderImpl</provider> <jta-data-source>java:/PostgresDS</jta-data-source> <class>org.jboss.priscus.DataBean</class> <class>org.jboss.priscus.GenerateChartFromDBDataAction</class> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/> <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/> <property name="hibernate.transaction.flush_before_completion" value="true"/> <property name="hibernate.hbm2ddl.auto" value="create-drop"/> <property name="hibernate.show_sql" value="true"/> </properties> </persistence-unit> </persistence> Here is my components.xml file <?xml version="1.0" encoding="UTF-8"?> <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="Priscus/#{ejbName}/local" debug="false"/> <core:manager conversation-timeout="120000"/> </components> Here is my ejb-jar.xml file <ejb-jar> <assembly-descriptor> <interceptor-binding> <ejb-name>Priscus</ejb-name> <interceptor-class> org.jboss.seam.ejb.SeamInterceptor </interceptor-class> </interceptor-binding> </assembly-descriptor> </ejb-jar> Here is my postgres-ds.xml file <?xml version="1.0" encoding="UTF-8"?> <!-- ===================================================================== --> <!-- --> <!-- JBoss Server Configuration --> <!-- --> <!-- ===================================================================== --> <!-- $Id: postgres-ds.xml 41016 2006-02-07 14:23:00Z acoliver $ --> <!-- ==================================================================== --> <!-- Datasource config for Postgres --> <!-- ==================================================================== --> <datasources> <local-tx-datasource> <jndi-name>PostgresDS</jndi-name> <connection-url>jdbc ostgresql://localhost/DSMNT12</connection-url> <driver-class>org.postgresql.Driver</driver-class> <user-name>postgres</user-name> <password>oleksa</password> <!-- sql to call when connection is created. Can be anything, select 1 is valid for PostgreSQL <new-connection-sql>select 1</new-connection-sql> --> <!-- sql to call on an existing pooled connection when it is obtained from pool. Can be anything, select 1 is valid for PostgreSQL <check-valid-connection-sql>select 1</check-valid-connection-sql> --> <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) --> <metadata> <type-mapping>PostgreSQL 7.2</type-mapping> </metadata> </local-tx-datasource> </datasources> What could I be possible missing...??? Thanks Brian
|
 |
Brian Oleksa
Greenhorn
Joined: Jun 05, 2007
Posts: 15
|
|
Sorry.... I forgot to mention that this is a j2EE web app. I invoke the action class from my JSF page. <s:link action="#{genchartfromdb.getSomeData}" value="Get Data" disabled="false"/> Once I click the above link, I get the NOT BOUND error...
|
 |
Orem Hun
Greenhorn
Joined: May 24, 2005
Posts: 28
|
|
Please check your jndi-pattern declaration, in the Seam example I see the following: <components xmlns="http://jboss.com/products/seam/components" xmlns:core="http://jboss.com/products/seam/core"> <core:init jndi-pattern="@jndiPattern@"/> </components>
|
 |
Krishna Srinivasan
Ranch Hand
Joined: Jul 28, 2003
Posts: 1803
|
|
Read this article for JBoss Seam Introduction: http://www.javabeat.net/jboss-seam/2007/06/jboss-seam-introduction/
|
Krishna Srinivasan
OCAJP Mock Questions
|
 |
 |
|
|
subject: Jboss-seam EJB 3.0 "not bound" error.....
|
|
|