GeeCON Prague 2014*
The moose likes Object Relational Mapping and the fly likes need help configuring Jboss, EJB, Derby DB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "need help configuring Jboss, EJB, Derby DB" Watch "need help configuring Jboss, EJB, Derby DB" New topic
Author

need help configuring Jboss, EJB, Derby DB

Brian Oleksa
Greenhorn

Joined: Jun 05, 2007
Posts: 15
I am currently trying to set up EJB 3.0 within Jboss so I can pull data from a Derby DB. The EJB 3.0 annotations in the code and writing the Java code was the easy part. I have a pretty good understanding of how to use EJB 3.0 within Jboss. The main problem that I am having is setting up / configuring all the XML files to get Jboss to start up happily.

Below are some of the errors that I am having during start up of Jboss.

But first let me show you my code.

FYI.
The name of my derby db is: DSMNT12
The name of my web-app is: Priscus

When I hit this class, this is where it seems to break. Is my code wrong, or isn't Jboss/EJB set up properly?


@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 my 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 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 persistence.xml file.


<persistence>
<persistence-unit name="Priscus">
<jta-data-source>java:/DSMNT12</jta-data-source>
<properties>

</properties>
</persistence-unit>
</persistence>


Here is my Priscus-ds.xml file.


<datasources>
<local-tx-datasource>

<!-- The jndi name of the DataSource, it is prefixed with java:/ -->
<!-- Datasources are not available outside the virtual machine -->
<jndi-name>DerbyDS</jndi-name>

<!-- for in-process persistent db, saved when jboss stops. The
org.jboss.jdbc.DerbyDatabase mbean is necessary for properly db shutdown -->
<connection-url>jdbc erby:C:\Documents and Settings\oleksab\Desktop\derby\DSMNT12;create=true</connection-url>

<!-- The driver class -->
<driver-class>org.apache.derby.jdbc.EmbeddedDriver</driver-class>

<!-- The login and password -->
<user-name>sa</user-name>
<password></password>

<!-- The minimum connections in a pool/sub-pool. Pools are lazily constructed on first use -->
<min-pool-size>5</min-pool-size>

<!-- The maximum connections in a pool/sub-pool -->
<max-pool-size>20</max-pool-size>

<!-- The time before an unused connection is destroyed -->
<idle-timeout-minutes>5</idle-timeout-minutes>

<!-- Whether to check all statements are closed when the connection is returned to the pool,
this is a debugging feature that should be turned off in production -->
<track-statements/>

<!-- This mbean can be used when using in process persistent derby -->
<depends>jboss:service=Derby</depends>
</local-tx-datasource>

<!--This next line was causing problems-->
<!--<mbean code="org.jboss.jdbc.DerbyDatabase" name="jboss:service=Derby"/>-->
</datasources>


Here are some errors that I get during start-up of Jboss


12:21:25,140 INFO [EARDeployer] Started J2EE application: file:/C:/Program File
s/jboss-4.0.5.GA/server/default/deploy/Priscus.ear
12:21:25,140 ERROR [URLDeploymentScanner] Incomplete Deployment listing:

--- MBeans waiting for other MBeans ---
ObjectName: jboss.jca:service=LocalTxCM,name=DerbyDS
State: CONFIGURED
I Depend On:
jboss.jca:service=ManagedConnectionPool,name=DerbyDS
jboss.jca:service=CachedConnectionManager
jboss:service=TransactionManager
Depends On Me:
jboss.jca:service=DataSourceBinding,name=DerbyDS

ObjectName: jboss.jca:service=ManagedConnectionPool,name=DerbyDS
State: CONFIGURED
I Depend On:
jboss.jca:service=ManagedConnectionFactory,name=DerbyDS
Depends On Me:
jboss.jca:service=LocalTxCM,name=DerbyDS

ObjectName: jboss.jca:service=ManagedConnectionFactory,name=DerbyDS
State: CONFIGURED
I Depend On:
jboss:service=Derby
jboss.jca:service=RARDeployment,name='jboss-local-jdbc.rar'
Depends On Me:
jboss.jca:service=ManagedConnectionPool,name=DerbyDS

ObjectName: jboss.jca:service=DataSourceBinding,name=DerbyDS
State: CONFIGURED
I Depend On:
jboss.jca:service=LocalTxCM,name=DerbyDS
jboss:service=invoker,type=jrmp

ObjectName: persistence.units:ear=Priscus.ear,jar=Priscus.jar,unitName=Priscus
State: NOTYETINSTALLED
I Depend On:
jboss.jca:name=DSMNT12,service=DataSourceBinding
Depends On Me:
jboss.j2ee:ear=Priscus.ear,jar=Priscus.jar,name=GenerateChartFromDBDataActio
n,service=EJB3

ObjectName: jboss.j2ee:ear=Priscus.ear,jar=Priscus.jar,name=GenerateChartFromDBD
ataAction,service=EJB3
State: NOTYETINSTALLED
I Depend On:
persistence.units:ear=Priscus.ear,jar=Priscus.jar,unitName=Priscus

--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: jboss:service=Derby
State: NOTYETINSTALLED
Depends On Me:
jboss.jca:service=ManagedConnectionFactory,name=DerbyDS

ObjectName: jboss.jca:name=DSMNT12,service=DataSourceBinding
State: NOTYETINSTALLED
Depends On Me:
persistence.units:ear=Priscus.ear,jar=Priscus.jar,unitName=Priscus



Then When I actually hit the code that tries to query the DB I get these errors. My databean cannot be found.

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

All help is greatly appreciated...!!!

Thank you

Brian Oleksa
Software Engineer
Dark Corner Software
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10145
    
165

<!-- This mbean can be used when using in process persistent derby -->
<depends>jboss:service=Derby</depends>


This does not look right. Remove this depends line or comment it out from the datasource and try it out. Any idea why that's there?


[My Blog] [JavaRanch Journal]
Brian Oleksa
Greenhorn

Joined: Jun 05, 2007
Posts: 15
Ok...I commented the line out.
<!--<depends>jboss:service=Derby</depends>-->

I still get the same errors on start up of Jboss. (the State:NOTYETINSTALLED errors)

And when I hit that code again, I still get the...
Caused by: javax.naming.NameNotFoundException: databean not bound
error.

The <depends> line of code that you asked me to remove was a cut and paste from my many many many attempts to get this to work.

Thank you

Brian
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10145
    
165

The reason why you get NameNotFoundException is because your application hasnt been deployed completely. Specifically, the datasource is not deployed. Follow this wiki and configure your datasource for Derby. This would mean that you will have to revert back all the changes that you have done. Once that's done, restart your server. If you still see errors post them here. Also note that the 'MBeans waiting for....' message your are seeing is not the rootcause. The actual exception stacktrace will be somewhere above those messages.
[ June 05, 2007: Message edited by: Jaikiran Pai ]
Brian Oleksa
Greenhorn

Joined: Jun 05, 2007
Posts: 15
OK

I went to the wiki and added the exact same text to my -ds.xml file that was on the wiki. I deployed it and started Jboss. This is the error that I get now on start up of Jboss.

org.jboss.deployment.DeploymentException: No ClassLoaders found for: org.jboss.jdbc.DerbyDatabase; - nested throwable: (java.lang.ClassNotFoundException: No ClassLoaders found for: org.jboss.jdbc.DerbyDatabase)

My Derby.jar file lives inside Jboss lib directory.


Thanks

brian
Brian Oleksa
Greenhorn

Joined: Jun 05, 2007
Posts: 15
Also...???

Doesn't the connection URL have to map to your derby DB...???

for example (this is my original connectionURL):
<connection-url>jdbc erby:C:\Documents and Settings\oleksab\Desktop\derby\DSMNT12;create=true</connection-url>

The connectionUrl on the wiki was a basic URL
<connection-url>jdbc erby:${jboss.server.data.dir}${/}derby${/}localDB;create=true</connection-url>

I never used Derby DB before but what I am aware of is that the Derby DB is a folder. The name of the folder / DB that I am trying to connect to is DSMNT12. SO the connection should point to that folder correct...???

Thanks

Brian
Brian Oleksa
Greenhorn

Joined: Jun 05, 2007
Posts: 15
Another thing that I noticed is that this: No ClassLoaders found for: org.jboss.jdbc.DerbyDatabase is a Jboss driver issue. Is this a config issue within Jboss? Does Joboss have their bundle of drivers in one place? If so, Jboss should have found the jdbc for derby. Correct...???

Thanks

Brian
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10145
    
165

org.jboss.deployment.DeploymentException: No ClassLoaders found for: org.jboss.jdbc.DerbyDatabase; - nested throwable: (java.lang.ClassNotFoundException: No ClassLoaders found for: org.jboss.jdbc.DerbyDatabase)


That will be easy to fix. The jar file containing the Derby database driver (org.jboss.jdbc.DerbyDatabase) should be placed in %JBOSS_HOME%/server/default/lib folder.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10145
    
165

Have a look at this JBAS-4147. Looks like the derby plugin jar was not shipped till JBoss-4.0.5. Seems to have been fixed in 4.2. Which version are you using? I would recommend you to download the derby related jar files (i think there are 2 of them) and place them in the %JBOSS_HOME%/server/default/lib folder to get this working.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10145
    
165

I would recommend you to download the derby related jar files (i think there are 2 of them)


Looks like 3. derby.jar, derby-plugin.jar and derby-client.jar. I guess this is where you can download it from:

Derby release
Brian Oleksa
Greenhorn

Joined: Jun 05, 2007
Posts: 15
I am using jboss version 4.0.5.GA
I downloaded derby version 10.2.2.0-bin

There is no derby-plugin.jar in this derby distribution. Does one even exist...???

There is however a derby.jar and a derbyclient.jar.

I have placed both of these in the C:\Program Files\jboss-4.0.5.GA\server\default\lib directory. I put them in there 4-5 days ago.

When I remove the line <!--<mbean code="org.jboss.jdbc.DerbyDatabase" name="jboss:service=Derby"/>--> from the ds.xml file, jboss starts up a lot better and I do not get the NOCLASSFOUND error anymore.

When I do leave this line in the ds.xml file and I have both the derby.jar and the derbyclient.jar in the server\default\lib directory I still get the NOCLASSFOUND error.

What is the importance of this line...???
<mbean code="org.jboss.jdbc.DerbyDatabase" name="jboss:service=Derby"/>

If I do keep this line commentted out and run the app, I get the error:
Caused by: javax.naming.NameNotFoundException: databean not bound

Where databean is the name of my bean.

So by commennting out the line above, did this fix the issue? If so, my new issue is: Caused by: javax.naming.NameNotFoundException: databean not bound

Thanks

Brian
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10145
    
165

So by commennting out the line above, did this fix the issue?


Yes, looks like your datasource is successfully deployed now. The "databean" error that you are seeing, can you post the stacktrace of that exception? When does this occur?
Brian Oleksa
Greenhorn

Joined: Jun 05, 2007
Posts: 15
This error happens when I click on the link in my webapp.

Here is the link.
<s:link action="#{genchartfromdb.getSomeData}" value="Pull Data from Derby DB>

When I click this link the error occurs.

This link calls this code:

package org.jboss.priscus;

import java.sql.Connection;
import java.sql.DriverManager;
import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;

@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";

}

}

The error: Caused by: javax.naming.NameNotFoundException: databean not bound. What does databean not bound mean...???

How do I BOUND my DataBean class...???

Here is the FULL stack trace that I get in my console:

2007-06-05 17:00:03,843 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] resolved name to Seam component
2007-06-05 17:00:03,843 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] resolving name: genchartfromdb
2007-06-05 17:00:03,843 DEBUG [org.jboss.seam.Component] instantiating Seam component: genchartfromdb
2007-06-05 17:00:03,859 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming rg.jnp.interfaces}
2007-06-05 17:00:03,859 ERROR [org.jboss.seam.jsf.SeamPhaseListener] uncaught exception
javax.faces.el.EvaluationException: Exception while invoking expression #{genchartfromdb.getSomeData}
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:165)
at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.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(AbstractSeamPhaseListener.java:276)
at org.jboss.seam.jsf.AbstractSeamPhaseListener.beforeRender(AbstractSeamPhaseListener.java:214)
at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:56)
at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersBefore(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(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:96)
at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:220)
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.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
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.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
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:619)
Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: 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(SeamVariableResolver.java:53)
at org.apache.myfaces.config.LastVariableResolverInChain.resolveVariable(LastVariableResolverInChain.java:42)
at org.apache.myfaces.el.ValueBindingImpl$ELVariableResolver.resolveVariable(ValueBindingImpl.java:574)
at org.apache.commons.el.NamedValue.evaluate(NamedValue.java:124)
at org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:455)
at org.apache.myfaces.el.MethodBindingImpl.resolveToBaseAndProperty(MethodBindingImpl.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


Thanks

Brian
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10145
    
165

What does databean not bound mean...???


It means that the JNDI tree is being looked up for the name 'databean'. However nothing is bound to the the jndi tree by this name. I guess, the DataBean class is supposed to be bound by this name to the jndi tree. I havent tried my hands with persistence.xml or for that matter much of annotations, so not sure where you are missing the step. But as far as i can say, you havent mentioned your DataBean class in the persistence.xml. As per this article, you have to.

Here's an extract:


jar-file and class
The class element specifies a fully qualified classname that you will belong to the persistence unit. The jar-file element specifies another jar you want automatically scanned for @Entity classes. When using jar-file, you must specify a path relative to the jar file the persistence.xml file is in. By default also, the jar the persistence.xml file is placed in is scanned for @Entity classes as well.
Brian Oleksa
Greenhorn

Joined: Jun 05, 2007
Posts: 15
Basically what it looks like this is coming down to is Jboss and Ejb configuration. There are several XML files to get up and running.

persistence.XML
ejb-jar.xml
components.xml
applications.xml

This is what I have to dive into and figure out.

Thanks for your help thus far.

Brian
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Well,. I think the problem might stem, and I emphasis "might" is what does your persistence.xml look like, and are you positive it is in the META-INF directory, which is in all caps? Also what does your xxx-ds.xml file look like. Basically you can't depoly your app because the datasource isn't deployed, most common reason is the dir structure, or the wrong jndi lookup for your DS in the persistence.xml.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
GeeCON Prague 2014
 
subject: need help configuring Jboss, EJB, Derby DB