aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes EJB 2.0 Deployment problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB 2.0 Deployment problem" Watch "EJB 2.0 Deployment problem" New topic
Author

EJB 2.0 Deployment problem

sunil kelkar
Greenhorn

Joined: Aug 16, 2005
Posts: 16
This is with reference to the book - Oreilly's Enterprise JavaBeans 4th Edition, ISBN 0-596-00530-X

I am trying to run the Entity Bean of Chapter 4 in JBoss 4.0+ and mySQL. I have followed all the instructions given in the book.

However instead of titandb-ds.xml I have mysql-ds.xml file. I have also created and copied the file jbosscmp-jdbc.xml to the folder src\resources\META-INF This file has <datasource>java:/DefaultDS</datasource>

What changes do I need to do to the file Client_1.java, especially to the statement Object ref = jndiContext.lookup("CabinHomeRemote");

Are there any other changes, to make my client program work?
Dave Salter
Ranch Hand

Joined: Jul 20, 2005
Posts: 292

What exactly are the problems you are getting?
sunil kelkar
Greenhorn

Joined: Aug 16, 2005
Posts: 16
When I run my client, it says DefaultDS not bound.
My application's files are as follows:
jndi.properties file is:


jboss.xml file is:


jbosscmp-jdbc.xml part of the file is:


ejb-jar.xml part of the file is:


My Client.java part of the file is:


Where am I going wrong?

Originally posted by Dave Salter:
What exactly are the problems you are getting?
Dave Salter
Ranch Hand

Joined: Jul 20, 2005
Posts: 292

What does your mysql-ds.xml look like. Have you deployed this to your deploy directory?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Is your client running in the container? If not, how does your getInitialContext() method get a Context?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
sunil kelkar
Greenhorn

Joined: Aug 16, 2005
Posts: 16
mysql-ds.xml file is there in the deploy folder of JBoss and here are it's contents:


Originally posted by Dave Salter:
What does your mysql-ds.xml look like. Have you deployed this to your deploy directory?
sunil kelkar
Greenhorn

Joined: Aug 16, 2005
Posts: 16
The client is not running in JBoss.

Originally posted by Paul Sturrock:
Is your client running in the container? If not, how does your getInitialContext() method get a Context?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

So how do you get your Context? Can you see your DataSource in JNDI with the jmx-console? Are there any errors in your server.log when the DataSource was created.
[ September 19, 2005: Message edited by: Paul Sturrock ]
Dave Salter
Ranch Hand

Joined: Jul 20, 2005
Posts: 292



OK, I see. Why are you trying to lookup java:/DefaultDS on the client? This is not bound on the client, only on the server, so the error that you are getting is expected behaviour.

Have a look at this.
sunil kelkar
Greenhorn

Joined: Aug 16, 2005
Posts: 16
When I run, http://127.0.0.1:8080/jmx-console/ I can see:

jboss.j2ee

* jndiName=CabinHomeRemote,plugin=cache,service=EJB
* jndiName=CabinHomeRemote,plugin=pool,service=EJB
* jndiName=CabinHomeRemote,service=EJB

Also, I checked the server.log file, I did not find any problems related to DefaultDS. Also, here's an extract of server.log -


Originally posted by Paul Sturrock:
So how do you get your Context? Can you see your DataSource in JNDI with the jmx-console? Are there any errors in your server.log when the DataSource was created.

[ September 19, 2005: Message edited by: Paul Sturrock ]
sunil kelkar
Greenhorn

Joined: Aug 16, 2005
Posts: 16
Does that mean, I cannot connect to this EJB from an external client? Very confusing.

Originally posted by Dave Salter:
<hr></blockquote>

OK, I see. Why are you trying to lookup java:/DefaultDS on the client? This is not bound on the client, only on the server, so the error that you are getting is expected behaviour.

Have a look at this.
sunil kelkar
Greenhorn

Joined: Aug 16, 2005
Posts: 16
One more thing, if I modify my client have something like this -

then I guess it is inserting a record in the default Hypersonic database table, Cabin and not in the mySQL database table, Cabin. More confusion!
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


Does that mean, I cannot connect to this EJB from an external client?

No, but it does mean you can't connect to the DataSource (as you are trying) from a client.


then I guess it is inserting a record in the default Hypersonic database table

No. Unless your Cabin Entity Bean uses the default Hypersonic DataSource?
sunil kelkar
Greenhorn

Joined: Aug 16, 2005
Posts: 16
The basic problem still persists - I am unable to add arecord into the mySQL based Cabin table. What should I do?

Originally posted by Paul Sturrock:

No. Unless your Cabin Entity Bean uses the default Hypersonic DataSource?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

So can you now successfully lookup your entity bean? If this is the case, look at your entity bean mapping. Double-check the table-name you have mapped this bean to. It will never insert into a "cabin" table as it is currently defined.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB 2.0 Deployment problem