dcsimg
How can I access data source by useing JNDI from a standalone client on the same machine with server?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   joshua_cao
Posted On:   Monday, August 14, 2006 10:07 PM

The following NameNotFoundException is encountered when java client is deployed on UAT based on WAS, however it works successfully on WSAD of my pc. I browse the properties of the target object in the administrative console, and verify that the JNDI name on WAS matches the JNDI name my client is using. From the searching result on internet , it seems as if there are the below reason: 1> WSAD context is application level, and WAS context is server level. Default namespaceroot on WAS is "serverroot", so initial context on UAT is "chncitodmg02network/nodes/CHNCITOWASUAT04/servers/nodeagent". I attempt to put the parameter    More>>


The following NameNotFoundException is encountered when java client is deployed on UAT based on WAS, however it works successfully on WSAD of my pc.



I browse the properties of the target object in the administrative console, and verify that the JNDI name on WAS matches the JNDI name my client is using.



From the searching result on internet , it seems as if there are the below reason:



1> WSAD context is application level, and WAS context is server level.



Default namespaceroot on WAS is "serverroot", so initial context on UAT is
"chncitodmg02network/nodes/CHNCITOWASUAT04/servers/nodeagent".

I attempt to put the parameter "com.ibm.websphere.naming.namespaceroot" to hashtable object and set the value "cellroot", then initial context changed to "chncitodmg02network".But NameNotFoundException still occurs.



2> Some configure files need to add a resource-refs section located jndi name , such as "web.xml", "ejb-jar.xml" etc.



My client is only a standalone java client, not a J2EE application, so I don't know where to find those config files.



3> Use the fully-qualified JNDI name .



"If access is from a standalone client, it might be that the object you are attempting access is on a server different from the server from which you obtained the initial context. "

So I change ctx.lookup("cell/nodes/CHNCITOWASUAT04/servers/nodeagent/jdbc/ChnsmsSouthDataSource"),but
the exception exists as of old.



Is there any mistake on the direction of my solveing problem?



Code:
.....
Hashtable parms = new Hashtable();


parms.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");


parms.put(Context.PROVIDER_URL, "iiop:///");


//parms.put("com.ibm.websphere.naming.namespaceroot","cellroot");


InitialContext ctx = new InitialContext(parms);


JDBCConnectionSpec spec = WSRRAFactory.createJDBCConnectionSpec();


spec.setCatalog("UniOper_Data"); // set db name


WSDataSource wsds = (WSDataSource) ctx.lookup("jdbc/ChnsmsSouthDataSource");


//WSDataSource wsds = (WSDataSource)
ctx.lookup("cell/nodes/CHNCITOWASUAT04/servers/nodeagent/jdbc/ChnsmsSouthDataSource");
.....    <<Less
About | Sitemap | Contact