• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB 2.0 Deployment problem

 
sunil kelkar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 293
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly are the problems you are getting?
 
sunil kelkar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 293
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does your mysql-ds.xml look like. Have you deployed this to your deploy directory?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your client running in the container? If not, how does your getInitialContext() method get a Context?
 
sunil kelkar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 293
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic