aspose file tools*
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Could not find datasource" Watch "Could not find datasource" New topic
Author

Could not find datasource

Abhi Gowda
Greenhorn

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
FATAL: MSG_EXCEPTION_LOGGED
Mar 28, 2008 8:58:15 AM com.sony.pip.util.HibernateUtil
SEVERE: Building SessionFactory failed.
Mar 28, 2008 8:58:15 AM com.sony.pip.util.HibernateUtil
SEVERE: MSG_EXCEPTION_LOGGED
org.hibernate.HibernateException: Could not find datasource
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:56)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:414)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
at com.sony.pip.util.HibernateUtil.<clinit>(HibernateUtil.java:24)
at com.sony.pip.service.impl.command.CommandInvoker.deleteEntities(CommandInvoker.java:157)
at com.sony.pip.service.impl.command.CommandInvoker.execute(CommandInvoker.java:82)
at com.sony.pip.service.impl.StepImportServiceImpl.invokeCommandsForExport(StepImportServiceImpl.java:288)
at com.sony.pip.service.impl.StepImportServiceImpl.importStepXML(StepImportServiceImpl.java:61)
at com.sony.pip.service.impl.StepImportServiceImplTest.testStepImport(StepImportServiceImplTest.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
at java.lang.reflect.Method.invoke(Method.java:391)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
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 com.ibm.ws.naming.java.javaURLContextFactory.isNameSpaceAccessable(javaURLContextFactory.java:98)
at com.ibm.ws.naming.urlbase.UrlContextFactory.getObjectInstance(UrlContextFactory.java:73)
at javax.naming.spi.NamingManager.getURLObject(NamingManager.java:592)
at javax.naming.spi.NamingManager.getURLContext(NamingManager.java:541)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:289)
at javax.naming.InitialContext.lookup(InitialContext.java:361)
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
... 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
Greenhorn

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

For. E.G.
<resource-ref id="ResourceRef_1251416779852">
<description></description>
<res-ref-name>PIPDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

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.
 
wood burning stoves
 
subject: Could not find datasource