Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Failed using dynamically created datasources

Status
Not open for further replies.

developer72

Programmer
Mar 2, 2004
1
CH
Hi,

im using WAS 5.0 and my application creates datasources dynamically which works. (see code #1)
After the datasource has been created I look it up via jndi (see code #2) and try use it (e.g. get a connection), but here I get an exception (see stacktrace #3).

I found out, that WAS needs a Version 5 datasource for ejb 2.0. But when I create a datasource dynamically I can not set the version of the datasource to create and somehow WAS create a version 4 datasource.

How can I dynamically create a version 5 datasource?
Is one of you also using the datasource factory? How do you do it?

All tips are very welcome.

regards,

oliver

#1
// Create a properties file for the DataSource
java.util.Properties prop = new java.util.Properties();
prop.put(DataSourceFactory.NAME, dataSourceIdentifier);
prop.put(DataSourceFactory.DATASOURCE_CLASS_NAME, "oracle.jdbc.pool.OracleConnectionPoolDataSource");
prop.put(DataSourceFactory.USER, inDataSourceProperties.getUsername());
prop.put(DataSourceFactory.PASSWORD, inDataSourceProperties.getPassword());
prop.put("URL", inDataSourceProperties.getConnectionURI());

// Obtain a DataSource from the factory
try {
dataSource = DataSourceFactory.getDataSource(prop);
}
catch (Exception e) {
System.out.println("Exception:");
e.printStackTrace();
}

// Bind the DataSource into JNDI
try {

DataSourceFactory.bindDataSource(initialContext,dataSource);
}
catch (NamingException ne) {
System.out.println("NamingException: " + ne.getMessage());
}

#2
try {
dataSource = (javax.sql.DataSource)initialContext.lookup("thisNode/servers/server1/"+dataSourceIdentifier);
System.out.println("Datasource exists and was successfully looked up over jndi!");
}
catch (NamingException ne) {
ne.printStackTrace();
}

#3
javax.naming.NamingException: Attempted to use a 4.0 DataSource in EJB 2.0 Module. Invalid configuration.
at java.lang.Throwable.<init>(Throwable.java:59)
at java.lang.Throwable.<init>(Throwable.java:73)
at javax.naming.NamingException.<init>(NamingException.java:111)
at com.ibm.ejs.cm.DSFactoryImpl.verifyConfiguration(DSFactoryImpl.java:243)
at com.ibm.websphere.advanced.cm.factory.DataSourceFactory$ResourceReferenceObjectFactory.getObjectInstance(DataSourceFactory.java:845)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:313)
at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookupExt(Helpers.java:873)
at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookup(Helpers.java:680)
at com.ibm.ws.naming.jndicos.CNContextImpl.processResolveResults(CNContextImpl.java:1712)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1567)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1480)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1187)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1067)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:132)
at javax.naming.InitialContext.lookup(InitialContext.java:360)
at ch.steria.kisz.server.basicBOService.impl.WebsphereBMTConnectionFactory.create(WebsphereBMTConnectionFactory.java:74)
at ch.steria.kisz.model.KISZModelHome.switchIfNecessary(KISZModelHome.java:940)
at ch.steria.kisz.model.KISZModelHome.attachConnection(KISZModelHome.java:510)
at ch.steria.kisz.server.basicBOService.BasicBOServiceBean.readValues(BasicBOServiceBean.java:534)
at ch.steria.kisz.server.basicBOService.EJSRemoteStatefulBasicBOService_f5bf1b89.readValues(EJSRemoteStatefulBasicBOService_f5bf1b89.java:84)
at ch.steria.kisz.server.basicBOService._EJSRemoteStatefulBasicBOService_f5bf1b89_Tie.readValues(_EJSRemoteStatefulBasicBOService_f5bf1b89_Tie.java:445)
at ch.steria.kisz.server.basicBOService._EJSRemoteStatefulBasicBOService_f5bf1b89_Tie._invoke(_EJSRemoteStatefulBasicBOService_f5bf1b89_Tie.java:109)
at com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:602)
at com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:455)
at com.ibm.rmi.iiop.ORB.process(ORB.java:402)
at com.ibm.CORBA.iiop.ORB.process(ORB.java:1685)
at com.ibm.rmi.iiop.Connection.doWork(Connection.java:2173)
at com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:64)
at com.ibm.ejs.oa.pool.PooledThread.run(ThreadPool.java:95)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top