Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Error looking up dataSource using JNDI from Entity Beans

843829May 1 2002 — edited Sep 18 2002
Hi,

I wrote a simple Entity Bean class. I am using JBuilder5, Weblogic 6.0 sp2 and Oracle 8.1.7.
In JBuilder under Tools->Enterprise Setup->Database Drivers, I have added the Oracle driver.

I created a project and created all interfaces and classes. JBuilder generated a class that extends the Bean class, in which the code to accecc datase are implemented.

This is the code it generated for setEntityContext method.

public void setEntityContext(EntityContext entityContext) throws RemoteException {
super.setEntityContext(entityContext);
try {
javax.naming.Context context = new javax.naming.InitialContext();
try {
dataSource = (DataSource) context.lookup("java:comp/env/jdbc/DataSource");
}
catch(Exception e) {
throw new EJBException("Error looking up dataSource: " + e.toString());
}
}
catch(Exception e) {
throw new EJBException("Error initializing context in setEntityContext of BMP:" + e.toString());
}
}

I am able to compile, deploy the beans. After creating a client application, if I run the client, I am getting the following exception.

java.rmi.RemoteException: EJB Exception: ; nested exception is:
javax.ejb.EJBException: Error initializing context in setEntityContext of BMP:javax.ejb.EJBException: Error looking up dataSource: javax.naming.NameNotFoundException: Unable to resolve jdbc/DataSource Resolved: '' Unresolved:'jdbc' ; remaining name 'DataSource'

javax.ejb.EJBException: Error initializing context in setEntityContext of BMP:javax.ejb.EJBException: Error looking up dataSource: javax.naming.NameNotFoundException: Unable to resolve jdbc/DataSource Resolved: '' Unresolved:'jdbc' ; remaining name 'DataSource'

<<no stack trace available>>

The JNDI name for the data source is correct. I checked that. I don't find any mistake.
Can anybody find a mistake and help me solve this error.

Thanks in advance.


Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 16 2002
Added on May 1 2002
8 comments
7,908 views