Saturday 4 April 2015

JNDI and Naming Problems -MS

Troubleshooting naming and JNDI problems using the WebSphere Application and  Deployment Manager.

Steps to help resolve common naming lookup problems
Which methods are you using , corbaloc / corbaname, for direct lookups or Java for indirect lookups.
e.g: WebSphere _AppServer_Root/bin>dumpNameSpace.[sh/bat] -host myhost.mycompany.com -port 901
  OR 
WebSphere _AppServer_Root/bin>dumpNameSpace.[sh/bat] url corbaloc:iiop:myhost.mycompany.com:901

Example

example using corbaloc provider URL and lookup:

env.put(Context.PROVIDER_URL," corbaloc::server.aust.in.ibm.com:9809");
ctx=new InitialContext(env);
Object obj = ctx.lookup("jdbc/PlantsByWebSphereDataSource")

The following is how the object is seen in the dumpNameSpace output:

Install_Root\bin> dumpNameSpace -url corbaloc::server.austin.ibm.com:9809

the output is get is as follows
.......
.......
.......
39  (top) /nodes/server/servers/server1jdbc/petstore/PetStoreDB  PetStoreDB
40  (top) /nodes/server/servers/server1jdbc/petstore/PlantsByWebSpehereDataSource  PLANTSDB
41  (top) /nodes/server/servers/server1jdbc/petstore/CatalogDB  CatalogDB
.......
.......
.......

Now You can able to see the object int he namespace
if  YES:
         -->check for spelling mistakes on lookup code versus what is seen in namespace.
        --> Confirm you are connecting to the namespace of the proper server,see the provider URL
        -->  If Provider URL or ctx.lookup values are pickedup from the properties file,print out the variable values to SystemOut to confirm the correct values are provided.
       --> If This does not resolve the problem , then go to what to do next.
if NO:
         Use the administrative console to verify that:
      --> The server hosting the target resource is started.
      --> The Web module or EJB container, if applicable, hosting the target resource is running.
      -->The JNDI name of the target resource is correct and updated.
      --> If the problem resource is remote , that is , not on the same node as the Name Server node, that the JNDI name is fully qualified, including the host name. This is especially applicable to Network Deployment Configurations.
If Still Problem not Resolved

  If you are using the java:lookup method, you cannot use dumpNameSpace to see the lookup Object. This is because the object is in the application's own namespace.
                   
1.Check your configuration against the following example of a java: namespace lookup. this shows the mapping from the sample code with the resource.xml, the resource .xml with the ibm-resource-bnd.xmi, and finally with the object as seen in the namespace.(where resource =web,application,appclient or ejbjar)

Code sample:
       ctx = new InitialContext();
       Object obj = ctx.lookup("java:comp/env/plantsby/PlantsDS");

NOTE: Mapping is configuring between the resource.xml and ibm-resource-bnd.xmi files.

web.xml:
                <resource-ref id="ResouceRef_1">
                             <res-ref-name>plantsby/PlantsDS</res-ref-name>
                             <res-type>javax.sql.DataSorce</res-type>
                             <res-auth> Container</res-auth>
                 </resource-ref>
ibm-web-bnd.xmi:
                     <resRefBindings xmi:id="ResourceRefBinding_1" jndiName = "jdbc/PlantsByWebSphereData                                   Source">
                      <bindingResourceRef href="WEB-INF/web.xml#ResourceRef_1"/>
                     </resRefBindings>

2. The dumpNameSpace utility can Still be used to show the real object in the namespace as defined in the binding file. This is different from that of the java:'s namespace.
output of dumpNameSpace Output:

.......
.......
.......
39  (top) /nodes/server/servers/server1jdbc/petstore/PetStoreDB  PetStoreDB
40  (top) /nodes/server/servers/server1jdbc/petstore/PlantsByWebSpehereDataSource  PLANTSDB
41  (top) /nodes/server/servers/server1jdbc/petstore/CatalogDB  CatalogDB
.......
.......
.......
If the configuration looks to be setup properly, when compared with the preceding sample, then get a dump of the applications,java: namespace using the wsadmin utility.

No comments:

Post a Comment