Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Datasource lookup

16 views
Skip to first unread message

bra...@yahoo.co.in

unread,
Jul 9, 2007, 3:44:15 AM7/9/07
to
I am trying to do a datasource lookup from a stand alone java client

---------------------------------------------
String jndiName = "jdbc/MyOracleDB";

Properties env = new Properties();
env.put(Context.PROVIDER_URL,"iiop://host:2809");
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
env.put(Context.URL_PKG_PREFIXES,"com.ibm.ws.naming");
env.put("java.naming.corba.orb",org.omg.CORBA.ORB.init((String[])null,null));


InitialContext ctx = new InitialContext(env);
System.out.println("Getting datasource");
DataSource ds = (DataSource)ctx.lookup(jndiName);
---------------------------------------------
Classpath:-

com.ibm.ws.runtime_6.1.0.jar
com.ibm.ws.admin.client_6.1.0.jar
com.ibm.mq.jar
com.ibm.mqjms.jar
dhbcore.jar
sibc.jms.jar
sibc.jndi.jar
sibc.orb.jar
oracle.jar
rsadbutils.jar
rsahelpers.jar

I am getting the below exception

----------------------------------------------
Getting datasource
Jul 9, 2007 12:53:26 PM com.ibm.ws.util.ImplFactory
WARNING: WSVR0072W
Jul 9, 2007 12:53:27 PM com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl
SEVERE: SET_METHOD_EXCP_J2CA0036
Jul 9, 2007 12:53:27 PM com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl
SEVERE: CREATE_MANAGED_CONNECTION_FACTORY_DETAILS_EXCP_J2CA0009
Jul 9, 2007 12:53:27 PM com.ibm.ws.naming.util.Helpers
WARNING: jndiGetObjInstErr
Jul 9, 2007 12:53:27 PM com.ibm.ws.naming.util.Helpers
WARNING: jndiNamingException
com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. [Root exception is java.lang.reflect.InvocationTargetException]
at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookupExt(Helpers.java:1000)
at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookup(Helpers.java:705)
at com.ibm.ws.naming.jndicos.CNContextImpl.processResolveResults(CNContextImpl.java:2093)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1947)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1862)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1552)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1354)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:172)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
Caught Naming Exception!!!
at ProduceMessageWithJNDI.main(ProduceMessageWithJNDI.java:47)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createMCF(ConnectionFactoryBuilderImpl.java:1375)
at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.processObjectInstance(ConnectionFactoryBuilderImpl.java:664)
at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.getObjectInstance(ConnectionFactoryBuilderImpl.java:614)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookupExt(Helpers.java:896)
... 9 more
Caused by: java.lang.NoSuchMethodError: com.ibm.ws.rsadapter.AdapterUtil.isInstance(Lcom/ibm/websphere/rsadapter/DataStoreHelper;Ljava/lang/String;)Z
at com.ibm.ws.rsadapter.spi.WSRdbDataSource.<init>(WSRdbDataSource.java:716)
at com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl.setDataSourceProperties(WSManagedConnectionFactoryImpl.java:1882)
... 18 more
----------------------------------------------


Looks like I am missing some required jars. Which is it and Where do i get these jars from?

Any pointers or help in this regard is appreciated.

--Bharath

Ken Hygh

unread,
Jul 9, 2007, 8:31:21 AM7/9/07
to

By FAR, the easiest way to make sure you have the required jars is to
use the pre-packaged Client install. The WAS CD has installing a WAS
Client as a option.

Ken

Paul Ilechko

unread,
Jul 9, 2007, 9:56:41 AM7/9/07
to
Ken Hygh wrote:

>
> By FAR, the easiest way to make sure you have the required jars is to
> use the pre-packaged Client install. The WAS CD has installing a WAS
> Client as a option.
>


But, it's generally not a good idea to do what you're trying to do. One
of the reasons why we have application servers is to enhance scalability
by providing resource management such as connection pooling to datasources.

Peter Bennett

unread,
Jul 9, 2007, 12:29:32 PM7/9/07
to
Yes, agreed, not the done thing at all, old (java) bean.
Contact a servlet with an HTTP, SOAP or perhaps an XML message through MQ
and let the servlet (using the Model View Controller pattern) contact a data
access object / EJB to do the persistance for you.

Peter Bennett
DSPS.

"Paul Ilechko" <paul.i...@us.ibm.com> wrote in message
news:f6teq9$2ng78$1...@news.boulder.ibm.com...

0 new messages