File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and the fly likes Could not find datasource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Could not find datasource" Watch "Could not find datasource" New topic

Could not find datasource

Abhi Gowda

Joined: Mar 27, 2008
Posts: 1
Hi All,

I am using Websphere. I have created a Data sources with JNDI :
jdbc/com/sony/pip/pipdb. I have deployed the ear and trying to run the application but i am getting the following error. Please help me in this.

FATAL: Could not find datasource: java:comp/env/PIPDataSource
Mar 28, 2008 8:58:15 AM org.hibernate.connection.DatasourceConnectionProvider
Mar 28, 2008 8:58:15 AM
SEVERE: Building SessionFactory failed.
Mar 28, 2008 8:58:15 AM
org.hibernate.HibernateException: Could not find datasource
at org.hibernate.connection.DatasourceConnectionProvider.configure(
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(
at org.hibernate.cfg.SettingsFactory.buildSettings(
at org.hibernate.cfg.Configuration.buildSettings(
at org.hibernate.cfg.Configuration.buildSessionFactory(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at junit.framework.TestCase.runTest(
at junit.framework.TestCase.runBare(
at junit.framework.TestResult$1.protect(
at junit.framework.TestResult.runProtected(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
Caused by: javax.naming.ConfigurationException: Name space accessor for the java: name space has not been set. Possible cause is that the user is specifying a java: URL name in a JNDI Context method call but is not running in a J2EE client or server environment.
at javax.naming.spi.NamingManager.getURLObject(
at javax.naming.spi.NamingManager.getURLContext(
at javax.naming.InitialContext.getURLOrDefaultInitCtx(
at javax.naming.InitialContext.lookup(
at org.hibernate.connection.DatasourceConnectionProvider.configure(
... 26 more

Here is the Hibernate thing:

<property name="connection.datasource">java:comp/env/PIPDataSource</property>

<!-- Database Settings -->
<property name="default_schema">PIPUSER</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="show_sql">false</property>

<!-- JDBC Settings -->
<property name="jdbc.use_streams_for_binary">true</property>
<property name="max_fetch_depth">1</property>

Please help me. Its urgent....

Thanks in advance.

Abhi Gowda.
Pratap Shinde

Joined: Sep 05, 2008
Posts: 5
Declare <resource-ref> in web.xml.

For. E.G.
<resource-ref id="ResourceRef_1251416779852">

Also if you are using RAD or some similar editor then I would suggest don't just add these entries manually. Better go to the 'References' tab and the add from there.
I agree. Here's the link:
subject: Could not find datasource
Similar Threads
Simple Hibernate Help (Im Noob)
How to use datasource for Hibernate Entity Manager
Problem with EJB lookup on GlassFish 2
How to hibernate Session while running the test cases
Connection Pool (couldn't find datasource)