File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and Other Java EE Technologies and the fly likes about resource reference for ejb Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » EJB and Other Java EE Technologies
Reply Bookmark "about resource reference for ejb" Watch "about resource reference for ejb" New topic
Author

about resource reference for ejb

liang sun
Ranch Hand

Joined: May 12, 2001
Posts: 51


in ejb-jar.xml,
......
<resource-ref>
<description>DataSource for db<description>
<res-ref-name>jdbc/JZHDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

In Deployment Descriptor has already generated DataSource (jdni is JZHDB)

(NOTE:they were automatic generated by jbuilder5 entitybean wizard

below is my Client.java
..............
InitialContext c1=new InitialContext();
DataSource ds=(DataSource)c1.lookup("jdbc/JZHDB"); //<======Client.java:28 line
Connection n1=ds.getConnection();
......................
when running,generated following exception
org.omg.CORBA.OBJECT_NOT_EXIST: minor code: 0 completed: No
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Class.java:237)
at com.inprise.vbroker.orb.SE.read(SE.java:28)
at com.inprise.vbroker.orb.DelegateImpl.handleReply(DelegateImpl.java:711)
at com.inprise.vbroker.orb.DelegateImpl.invoke(DelegateImpl.java:606)
at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:297)
at com.inprise.vbroker.orb.RequestImpl._invoke(RequestImpl.java:195)
at com.inprise.vbroker.orb.RequestImpl.invoke(RequestImpl.java:130)
at org.omg.CosNaming._NamingContextStub.resolve(_NamingContextStub.java:156)
at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:324)
at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:373)
at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:351)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at hav1.Client.main(Client.java:28)
pls ask, how to solve?
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3878
This is only a guess (I don't know what JBuilder's wizards do) but neither the deployment descriptor of the EJB nor the reference on the client side actually CREATE the DataSource. They both simply reference a DataSource that must be created separately in the application server. My guess is you haven't created the DataSource inside your app server.
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
ruilin yang
Ranch Hand

Joined: Feb 25, 2001
Posts: 334
Suggestion:
1. you need use your app server to configurate a datasource.
2. The part of the full name of the data source is determined by your app server. So I am not sure: jdbc/JZHDB is correct ?
Best luck.
Ruilin
Marco Barenkamp
Ranch Hand

Joined: Aug 27, 2001
Posts: 94
You should probably try the following:
ctx.lookup("java:comp/env/jdbc/JZHDB") if you created a reference especially for that bean. Otherwise the datasource does not exist, if the posted JNDI name is the real name of the
entry.
------------------
Marco Barenkamp
____________________________________________
L M I N T E R N E T S E R V I C E S AG
Senior Trainer & Architect,
BEA Certified Enterprise Developer
Sun Certified Programmer for the Java2 Platform
Sun Certified Web Component Developer for the Java2 Platform
Sun Certified Developer for the Java 2 Platform
Sun Certified Enterprise Architect for the Java 2 Platform Enterprise Edition (PI)


Marco Barenkamp<br />_ _ _ _ _ ________________________ _ _ _ _ _ <br />L M I N T E R N E T S E R V I C E S AG<br /> <br />Head of Software Development<br /> <br /> <br />BEA Certified Enterprise Developer<br />Sun Certified Programmer for the Java2 Platform<br />Sun Certified Web Component Developer for the Java2 Platform<br />Sun Certified Developer for the Java 2 Platform <br />Sun Certified Business Component Developer for the Java 2 Platform <br />Sun Certified Enterprise Architect for the Java 2 Platform Enterprise Edition<br /> <br />LMIS AG
 
 
subject: about resource reference for ejb
 
Threads others viewed
EJB & JBuilder
"comp/env/ejb/DcOtherInStateBenefitsSessionEJB" not found in context "java:"
Retrieving datasource from jndi in java studio creator
JBOSS connection pooling
Stateless EBJ using JNDI to get DataSource with JBOSS 4.2
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture