Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JNDI LOOK up problem for datasource

 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI
I am trying to do a jndi look up for datasource from a standalone java client. The code for the same and printstack is as stated below.

Code
***********************
try
{
java.util.Hashtable parms = new java.util.Hashtable();
parms.put(
Context.PROVIDER_URL, "IIOP://10.10.50.175:900/"; );
parms.put (Context.INITIAL_CONTEXT_FACTORY, "com.ibm.ejs.ns.jndi.CNInitialContextFactory");

InitialContext ctx = new InitialContext(parms);

DataSource ds = (DataSource)ctx.lookup("sbcdatasource");
System.out.println("ds ::: " + ds);

}
catch(Exception e)
{
System.out.println("Exception e " + e.getClass().getName());
System.out.println("Exception e " + e.getMessage());
e.printStackTrace();
}

Stack trace
************************
Exception e java.lang.ClassCastException
Exception e com.ibm.ws.naming.util.CacheableReference
java.lang.ClassCastException: com.ibm.ws.naming.util.CacheableReference at com.metlife.renewal.datasource.RenewalConnection.createConnectionPool(RenewalConnection.java:108)at com.metlife.renewal.batch.BatchProcess.processRunOnce(BatchProcess.java:159)at com.metlife.renewal.batch.BatchProcess.startProcess(BatchProcess.java:73) at com.metlife.renewal.batch.BatchProcess.main(BatchProcess.java:52)


Have no idea where i am going wrong. can anybody help.

Regards
Makarand Parab
 
author & internet detective
Posts: 40035
809
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Makarand,
What line of code throws the exception?

Also, the datasource JNDI name looks odd. Usually it is of the form "java:env/jdbc/sbcdatasource" or at least "jdbc/sbcdatasource"

DataSource ds = (DataSource)ctx.lookup("sbcdatasource");
 
Makarand Parab
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne
Thanks for responding.

What line of code throws the exception?
DataSource ds = (DataSource)ctx.lookup("sbcdatasource");
It says classcastexception.

Well if u says there is problem in look up name, if i print the
Object ds = ctx.lookup("sbcdatasource");
System.out.println("ds ::: " + ds);

It gives me all the information abt the Datasource, shown below is the o/p
ds ::: Reference Class Name: com.ibm.ejs.cm.portability.PortableDataSource
Type: name
Content: SBCRenewalsDataSource
Type: dataBaseVersion
Content: 0
Type: minimumPoolSize
Content: 1
Type: maximumPoolSize
Content: 10
Type: connectionTimeout
Content: 180
Type: idleTimeout
Content: 1800
Type: orphanTimeout
Content: 1800
Type: agedTimeout
Content: 0
Type: statementCacheSize
Content: 100
Type: disableAutoConnectionCleanup
Content: false
Type: informixLockModeWait
Content: 0
Type: oracleStmtCacheSize
Content: 0
Type: disable2Phase
Content: false
Type: connectionValidation
Content: false
Type: logOrphan
Content: false
Type: diagOptions
Content: 0
Type: surgeThreshold
Content: -1
Type: surgeTime
Content: 20
Type: stuckTime
Content: 30
Type: stuckThreshold
Content: -1
Type: stuckTimerTime
Content: 5
Type: resetReadOnly
Content: false
Type: secureXACredential
Content: false
Type: dataSourceClassName
Content: oracle.jdbc.pool.OracleConnectionPoolDataSource
Type: URL
Content: jdbc racle:thin:@ssrsdup2:1521:SCLGDOC
Type: user
Content: mrnew
Type: password
Content: {xor}Mi0xOig=
Type: description
Content: sbcdatasource
Type: dataSourceName
Content: SBCRenewalsDataSource
Type: databaseName
Content: SCLGDOC
Type: serverName
Content: SSRSDUP2
 
Jeanne Boyarsky
author & internet detective
Posts: 40035
809
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Makarand,
Ok. So obviously the JNDI lookup is fine. (That's good because those errors are harder to figure out.) Check the import statements. Maybe the code is referring to the wrong DataSource interface?
 
Makarand Parab
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne
Well, my problem of ClassCastException is gone. One needs to have cm.jar in the classpath, but then i started getting class not found exception which lead me to have some more jars in the classpath, they are as follows
cm.jar
utils.jar
perf.jar
jts.jar

but now i am getting exception
Exception e com.ibm.ejs.jts.jts.CurrentSet$InitializationError
Exception e not initialized
com.ibm.ejs.jts.jts.CurrentSet$InitializationError: not initialized
at com.ibm.ejs.jts.jts.CurrentSet.self(CurrentSet.java:218)
at com.ibm.ejs.jts.jts.CurrentSet.get_control(CurrentSet.java:265)
at com.ibm.ejs.jts.jts.Current.get_control(Current.java:72)
at com.ibm.ejs.util.tran.Util.getCoordinator(Util.java:13)
at com.ibm.ejs.cm.pool.ConnectionPool.allocateConnection(ConnectionPool.java:686)
at com.ibm.ejs.cm.pool.ConnectionPool.getConnection(ConnectionPool.java:312)
at com.ibm.ejs.cm.DataSourceImpl$1.run(DataSourceImpl.java:129)
at java.security.AccessController.doPrivileged(Native Method)
at com.ibm.ejs.cm.DataSourceImpl.getConnection(DataSourceImpl.java:127)
at com.ibm.ejs.cm.DataSourceImpl.getConnection(DataSourceImpl.java:102)
at com.metlife.renewal.datasource.RenewalConnection.createConnectionPool(RenewalConnection.java:108)
at com.metlife.renewal.batch.BatchProcess.processRunOnce(BatchProcess.java:159)
at com.metlife.renewal.batch.BatchProcess.startProcess(BatchProcess.java:73)
at com.metlife.renewal.batch.BatchProcess.main(BatchProcess.java:52)

U have any idea what is the problem now.

Regards
Makarand Parab
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic