Hi,
I am trying to do jndi look up a datasource which is created and tested from Websphere Administration Console. Here is the
test client.
/**
* @author crvashi
*
* To change the template for this generated type comment go to
* Window>Preferences>
Java>Code Generation>Code and Comments
*/
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.ConnectionEvent;
import java.util.*;
public class Test1 {
public static void main(
String[] args) {
try {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
env.put(Context.PROVIDER_URL, "iiop://localhost:2809");
Context initialContext = new InitialContext(env);
javax.sql.DataSource ds = (javax.sql.DataSource)initialContext.lookup("ContractDS");
}
catch(Exception e) {
e.printStackTrace();
}
}
}
But when i run this class as an application it gives an error. The stack trace is :
javax.naming.NamingException: The JNDI operation "lookup"on the context "localhost/nodes/localhost/servers/server1" with the name "ContractDS" failed. Please get the root cause Throwable contained in this NamingException for more information. Root exception is java.lang.IncompatibleClassChangeError: class com.ibm.ejs.jts.jts.CurrentSet does not implement interface org.omg.CosTransactions.CurrentOperations
at com.ibm.ws.naming.jndicos.CNContextImpl.suspendTransaction(CNContextImpl.java:4070)
at com.ibm.ws.naming.jndicos.CNContextImpl.cosResolve(CNContextImpl.java:3521)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1565)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1525)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1225)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:132)
at javax.naming.InitialContext.lookup(InitialContext.java:359)
at net.sf.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:45)
at net.sf.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:83)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:153)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:627)
at com.bunge.bgm.common.domain.BrokerMain.configure(BrokerMain.java:20)
at com.bunge.bgm.common.domain.BrokerMain.main(BrokerMain.java:155)
rethrown as net.sf.hibernate.HibernateException: Could not find datasource: The JNDI operation "lookup"on the context "localhost/nodes/localhost/servers/server1" with the name "ContractDS" failed. Please get the root cause Throwable contained in this NamingException for more information.
at net.sf.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:49)
at net.sf.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:83)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:153)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:627)
at com.bunge.bgm.common.domain.BrokerMain.configure(BrokerMain.java:20)
at com.bunge.bgm.common.domain.BrokerMain.main(BrokerMain.java:155)
Please reply if someone has fixed this problem.
Thanks in advance.