wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes EJB / Jboss configuration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB / Jboss configuration " Watch "EJB / Jboss configuration " New topic
Author

EJB / Jboss configuration

Brian Oleksa
Greenhorn

Joined: Jun 05, 2007
Posts: 15
I believe that I am having problems setting up Jboss and EJB. The code was the easy part, but when I run my web app and hit the EJB code to query the DB, I get the following error.

Caused by: javax.naming.NameNotFoundException: databean not bound

DataBean is the name of my bean class.

Here are some snipits of my code.

DataBean

@Entity
@Name("databean")
public class DataBean implements Serializable {

private long id;

private int time;

private int node;

@Id
public long getId() {
return id;
}

//the rest of the getters and setters


Here is my action class

@Stateless
@Name("genchartfromdb")
public class GenerateChartFromDBDataAction implements GenerateChartFromDBData {

@In
@Out
private DataBean databean;

@Out
private List<DataBean> listOfBeans;

@PersistenceContext
private EntityManager em;

public String getSomeData() {

try {

em.persist(databean);
databean = new DataBean();
listOfBeans = em.createQuery("select * from SARECORD").getResultList();
}

catch (Exception e) {
System.out.println("Problem in the GenerateChartFromDBAction class....");
}
return "chartoutcomefromdb";

}


Here is it's interface.

@Local
public interface GenerateChartFromDBData {

public String getSomeData();

}


Here is my persistence.xml file

<?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="Priscus">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/DerbyDS</jta-data-source>
<jar-file>../Priscus.jar</jar-file>
<class>org.jboss.priscus.DataBean</class>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect"/>
<property name="hibernate.connection.url" value="jdbc erby SMNT12;create=true"/>
<property name="hibernate.connection.driver_class" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<property name="hibernate.c3p0.timeout" value="5000"/>
</properties>
</persistence-unit>

</persistence>


Here is my ejb-jar.xml file

<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise
JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>DataBean</ejb-name>
<home>org.jboss.priscus</home>
<remote>org.jboss.priscus</remote>
<ejb-class>org.jboss.priscus.DataBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>


Here is my front end code that calls the above class which is when I get the databean not bound error.

<s:link action="#{genchartfromdb.getSomeData}" value="get data from DB">

SO what does this error mean...???
Caused by: javax.naming.NameNotFoundException: databean not bound


Here is the FULL stack trace.

08:18:44,515 ERROR [SeamPhaseListener] uncaught exception
javax.faces.el.EvaluationException: Exception while invoking expression #{gencha
rtfromdb.getSomeData}
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java
:165)
at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpressi
on(ActionParamBindingHelper.java:58)
at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionPara
mMethodBinding.java:75)
at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:148)
at org.jboss.seam.core.Pages.callAction(Pages.java:499)
at org.jboss.seam.core.Pages.enterPage(Pages.java:282)
at org.jboss.seam.jsf.AbstractSeamPhaseListener.enterPage(AbstractSeamPh
aseListener.java:276)
at org.jboss.seam.jsf.AbstractSeamPhaseListener.beforeRender(AbstractSea
mPhaseListener.java:214)
at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.ja
va:56)
at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListener
sBefore(PhaseListenerManager.java:70)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:
373)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.jav
a:63)
at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.jav
a:49)
at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.jav
a:49)
at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.jav
a:49)
at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseX
MLFilter.java:96)
at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.
java:220)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
lter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
yAssociationValve.java:175)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:432)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
e.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConne
ctionValve.java:156)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
rocessConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWor
kerThread.java:112)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam com
ponent: genchartfromdb
at org.jboss.seam.Component.newInstance(Component.java:1740)
at org.jboss.seam.Component.getInstance(Component.java:1643)
at org.jboss.seam.Component.getInstance(Component.java:1610)
at org.jboss.seam.jsf.SeamVariableResolver.resolveVariable(SeamVariableR
esolver.java:53)
at org.apache.myfaces.config.LastVariableResolverInChain.resolveVariable
(LastVariableResolverInChain.java:42)
at org.apache.myfaces.el.ValueBindingImpl$ELVariableResolver.resolveVari
able(ValueBindingImpl.java:574)
at org.apache.commons.el.NamedValue.evaluate(NamedValue.java:124)
at org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(Value
BindingImpl.java:455)
at org.apache.myfaces.el.MethodBindingImpl.resolveToBaseAndProperty(Meth
odBindingImpl.java:180)
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java
:114)
... 45 more
Caused by: javax.naming.NameNotFoundException: databean 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:625)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at org.jboss.seam.Component.instantiateSessionBean(Component.java:1107)
at org.jboss.seam.Component.instantiate(Component.java:1093)
at org.jboss.seam.Component.newInstance(Component.java:1736)
... 54 more




To me, as soon as I hit this line of code... em.persist(databean); is when it blows up which tells me that I do not have Jboss and or EJB configured properly.

Thank you

Brian
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Alright, I am seeing a bunch of things.

First you are using Annotations for the Beans, so why do you want to also have an ejb-jar.xml

And in the ejb-jar you are making your Entity Bean listed as a Stateless Session Bean.

3. To inject an EJB into another EJB the annotation is @EJB.

4. So I think it is trying to lookup "databean" all lowercase, and it is actually deployed as an EJB like "DataBean" actually a little bit more, but that is a JBoss binding thing. So what is in your JBoss AS copnsole for deploying the Bean, it will show you how it is bound in the JNDI Tree.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB / Jboss configuration
 
Similar Threads
Service with handlers on JBoss. BIG Problem
Problem with entity bean
Java Serializable on Servlets
Not able to access Session Bean in Seam Framework
need help configuring Jboss, EJB, Derby DB