blogger templates blogger widgets
This is part of a list of blog posts.
To browse the contents go to

JNDI namespace in websphere


JNDI namespaces available within Websphere:

java: namespace

The java: name space of a J2EE application is accessible only by that application. It is not accessible outside of that application.

You need to invoke a NameServer MBean (from websphere scripting tool) to dump the java: name space for any J2EE application running in that same server process. Look here and here


local: namespace

This name space has the URL scheme of local: and is used by the container to bind objects locally instead of through the name server. The local: name space contains references to enterprise beans with local interfaces. There is only one local: name space in a server process. You can dump the local: name space by invoking the NameServer MBean associated with that server process. Look here and here


server: namespace

It is possible to dump the server namespace using NameServer MBean as described here

But there are 3 different ways this could be accessed.

  1. Invoking the name space dump tool
    For more look here
  2. Invoking the com.ibm.websphere.naming.DumpNameSpace programmatically
  3. try {
     Context initctx = new InitialContext();
     DumpNameSpace dump = new DumpNameSpace();
     dump.generateDump(initctx);
    } catch (NamingException e) {
     e.printStackTrace();
    }
    
    Output:
    4/14 19:56:57:878 IST] 000008a0 SystemOut     O =============================================================================
    [7/4/14 19:56:57:878 IST] 000008a0 SystemOut     O Name Space Dump
    [7/4/14 19:56:57:879 IST] 000008a0 SystemOut     O    Starting context: (top)=WIN-RANE51IRK16Node01Cell/nodes/WIN-RANE51IRK16Node01/servers/server1
    [7/4/14 19:56:57:879 IST] 000008a0 SystemOut     O    Time of dump: Fri Jul 04 19:56:57 IST 2014
    [7/4/14 19:56:57:879 IST] 000008a0 SystemOut     O =============================================================================
    [7/4/14 19:56:57:879 IST] 000008a0 SystemOut     O  
    [7/4/14 19:56:57:879 IST] 000008a0 SystemOut     O  
    [7/4/14 19:56:57:879 IST] 000008a0 SystemOut     O =============================================================================
    [7/4/14 19:56:57:879 IST] 000008a0 SystemOut     O Beginning of Name Space Dump
    [7/4/14 19:56:57:879 IST] 000008a0 SystemOut     O =============================================================================
    [7/4/14 19:56:57:879 IST] 000008a0 SystemOut     O  
    [7/4/14 19:56:57:879 IST] 000008a0 SystemOut     O     1 (top)                                              
    [7/4/14 19:57:00:438 IST] 000008a0 SystemOut     O     2 (top)/jta                                          javax.naming.Context
    [7/4/14 19:57:00:439 IST] 000008a0 SystemOut     O     3 (top)/jta/usertransaction                          java.lang.Object
    [7/4/14 19:57:00:439 IST] 000008a0 SystemOut     O     4 (top)/cell                                         javax.naming.Context
    [7/4/14 19:57:00:439 IST] 000008a0 SystemOut     O     5 (top)/Increment                                    com.ibm.defaultapplication.IncrementHome
    [7/4/14 19:57:00:439 IST] 000008a0 SystemOut     O     6 (top)/tm                                           javax.naming.Context
    [7/4/14 19:57:00:440 IST] 000008a0 SystemOut     O ASYN0069E: TimerManager default is being looked up without using resource reference. 
    [7/4/14 19:57:00:440 IST] 000008a0 TimerManagerF E   ASYN0069E: TimerManager default is being looked up without using resource reference. 
    [7/4/14 19:57:00:444 IST] 000008a0 SystemOut     O     7 (top)/tm/default                                   com.ibm.ws.asynchbeans.timer.TimerManagerImpl
    [7/4/14 19:57:00:444 IST] 000008a0 SystemOut     O     8 (top)/eis                                          javax.naming.Context
    [7/4/14 19:57:00:446 IST] 000008a0 SystemOut     O     9 (top)/eis/DefaultDatasource_CMP                    javax.resource.cci.ConnectionFactory
    [7/4/14 19:57:00:447 IST] 000008a0 SystemOut     O    10 (top)/servername                                   java.lang.String
    [7/4/14 19:57:00:447 IST] 000008a0 SystemOut     O    11 (top)/UserRegistry                                 com.ibm.websphere.security._UserRegistry_Stub
    [7/4/14 19:57:00:447 IST] 000008a0 SystemOut     O    12 (top)/AdminUserRegistry                            com.ibm.websphere.security._UserRegistry_Stub
    [7/4/14 19:57:00:447 IST] 000008a0 SystemOut     O    13 (top)/thisNode                                     javax.naming.Context
    [7/4/14 19:57:00:447 IST] 000008a0 SystemOut     O    14 (top)/services                                     javax.naming.Context
    [7/4/14 19:57:00:447 IST] 000008a0 SystemOut     O    15 (top)/services/cache                               javax.naming.Context
    [7/4/14 19:57:00:448 IST] 000008a0 SystemOut     O    16 (top)/services/cache/distributedmap                com.ibm.websphere.cache.DistributedObjectCache
    [7/4/14 19:57:00:448 IST] 000008a0 SystemOut     O    17 (top)/services/extensionregistry                   javax.naming.Context
    [7/4/14 19:57:00:449 IST] 000008a0 SystemOut     O    18 (top)/services/extensionregistry/global            com.ibm.wkplc.extensionregistry.ExtensionRegistryProxy
    [7/4/14 19:57:00:449 IST] 000008a0 SystemOut     O    19 (top)/com                                          javax.naming.Context
    [7/4/14 19:57:00:449 IST] 000008a0 SystemOut     O    20 (top)/com/ibm                                      javax.naming.Context
    [7/4/14 19:57:00:450 IST] 000008a0 SystemOut     O    21 (top)/com/ibm/websphere                            javax.naming.Context
    [7/4/14 19:57:00:450 IST] 000008a0 SystemOut     O    22 (top)/com/ibm/websphere/ejbquery                   javax.naming.Context
    [7/4/14 19:57:00:451 IST] 000008a0 SystemOut     O    23 (top)/com/ibm/websphere/ejbquery/Query             com.ibm.websphere.ejbquery.QueryHome
    [7/4/14 19:57:00:451 IST] 000008a0 SystemOut     O    24 (top)/com/ibm/websphere/scheduler                  javax.naming.Context
    [7/4/14 19:57:00:451 IST] 000008a0 SystemOut     O    25 (top)/com/ibm/websphere/scheduler/calendar         javax.naming.Context
    [7/4/14 19:57:00:451 IST] 000008a0 SystemOut     O    26 (top)/com/ibm/websphere/scheduler/calendar/DefaultUserCalendarHome
    [7/4/14 19:57:00:452 IST] 000008a0 SystemOut     O    26                                                    com.ibm.websphere.scheduler.UserCalendarHome
    [7/4/14 19:57:00:452 IST] 000008a0 SystemOut     O    27 (top)/jdbc                                         javax.naming.Context
    [7/4/14 19:57:00:454 IST] 000008a0 SystemOut     O    28 (top)/jdbc/DefaultEJBTimerDataSource               javax.resource.cci.ConnectionFactory
    [7/4/14 19:57:00:454 IST] 000008a0 SystemOut     O    29 (top)/wm                                           javax.naming.Context
    [7/4/14 19:57:00:460 IST] 000008a0 SystemOut     O    30 (top)/wm/ard                                       com.ibm.websphere.asynchbeans.WorkManager
    [7/4/14 19:57:00:460 IST] 000008a0 SystemOut     O    31 (top)/wm/default                                   com.ibm.websphere.asynchbeans.WorkManager
    [7/4/14 19:57:00:460 IST] 000008a0 SystemOut     O    32 (top)/DefaultDatasource                            javax.resource.cci.ConnectionFactory
    [7/4/14 19:57:00:460 IST] 000008a0 SystemOut     O    33 (top)/com.ibm.websphere.ejbcontainer               javax.naming.Context
    [7/4/14 19:57:00:461 IST] 000008a0 SystemOut     O    34 (top)/com.ibm.websphere.ejbcontainer/DefaultApplication
    [7/4/14 19:57:00:461 IST] 000008a0 SystemOut     O    34                                                    javax.naming.Context
    [7/4/14 19:57:00:462 IST] 000008a0 SystemOut     O    35 (top)/com.ibm.websphere.ejbcontainer/DefaultApplication/Increment.jar
    [7/4/14 19:57:00:462 IST] 000008a0 SystemOut     O    35                                                    javax.naming.Context
    [7/4/14 19:57:00:462 IST] 000008a0 SystemOut     O    36 (top)/com.ibm.websphere.ejbcontainer/DefaultApplication/Increment.jar/EJBFactory
    [7/4/14 19:57:00:462 IST] 000008a0 SystemOut     O    36                                                    com.ibm.websphere.ejbcontainer.EJBFactory
    [7/4/14 19:57:00:462 IST] 000008a0 SystemOut     O    37 (top)/com.ibm.websphere.ejbcontainer/DefaultApplication/EJBFactory
    [7/4/14 19:57:00:462 IST] 000008a0 SystemOut     O    37                                                    com.ibm.websphere.ejbcontainer.EJBFactory
    [7/4/14 19:57:00:462 IST] 000008a0 SystemOut     O    38 (top)/com.ibm.websphere.ejbcontainer/ivtApp        javax.naming.Context
    [7/4/14 19:57:00:463 IST] 000008a0 SystemOut     O    39 (top)/com.ibm.websphere.ejbcontainer/ivtApp/EJBFactory
    [7/4/14 19:57:00:463 IST] 000008a0 SystemOut     O    39                                                    com.ibm.websphere.ejbcontainer.EJBFactory
    [7/4/14 19:57:00:463 IST] 000008a0 SystemOut     O    40 (top)/com.ibm.websphere.ejbcontainer/ivtApp/ivtEJB.jar
    [7/4/14 19:57:00:463 IST] 000008a0 SystemOut     O    40                                                    javax.naming.Context
    [7/4/14 19:57:00:463 IST] 000008a0 SystemOut     O    41 (top)/com.ibm.websphere.ejbcontainer/ivtApp/ivtEJB.jar/EJBFactory
    [7/4/14 19:57:00:464 IST] 000008a0 SystemOut     O    41                                                    com.ibm.websphere.ejbcontainer.EJBFactory
    [7/4/14 19:57:00:464 IST] 000008a0 SystemOut     O    42 (top)/com.ibm.websphere.ejbcontainer/SchedulerCalendars
    [7/4/14 19:57:00:464 IST] 000008a0 SystemOut     O    42                                                    javax.naming.Context
    [7/4/14 19:57:00:464 IST] 000008a0 SystemOut     O    43 (top)/com.ibm.websphere.ejbcontainer/SchedulerCalendars/EJBFactory
    [7/4/14 19:57:00:464 IST] 000008a0 SystemOut     O    43                                                    com.ibm.websphere.ejbcontainer.EJBFactory
    [7/4/14 19:57:00:464 IST] 000008a0 SystemOut     O    44 (top)/com.ibm.websphere.ejbcontainer/SchedulerCalendars/Calendars.jar
    [7/4/14 19:57:00:464 IST] 000008a0 SystemOut     O    44                                                    javax.naming.Context
    [7/4/14 19:57:00:464 IST] 000008a0 SystemOut     O    45 (top)/com.ibm.websphere.ejbcontainer/SchedulerCalendars/Calendars.jar/EJBFactory
    [7/4/14 19:57:00:464 IST] 000008a0 SystemOut     O    45                                                    com.ibm.websphere.ejbcontainer.EJBFactory
    [7/4/14 19:57:00:465 IST] 000008a0 SystemOut     O    46 (top)/com.ibm.websphere.ejbcontainer/ManagementEJB javax.naming.Context
    [7/4/14 19:57:00:465 IST] 000008a0 SystemOut     O    47 (top)/com.ibm.websphere.ejbcontainer/ManagementEJB/mejb.jar
    [7/4/14 19:57:00:465 IST] 000008a0 SystemOut     O    47                                                    javax.naming.Context
    [7/4/14 19:57:00:465 IST] 000008a0 SystemOut     O    48 (top)/com.ibm.websphere.ejbcontainer/ManagementEJB/mejb.jar/EJBFactory
    [7/4/14 19:57:00:465 IST] 000008a0 SystemOut     O    48                                                    com.ibm.websphere.ejbcontainer.EJBFactory
    [7/4/14 19:57:00:465 IST] 000008a0 SystemOut     O    49 (top)/com.ibm.websphere.ejbcontainer/ManagementEJB/EJBFactory
    [7/4/14 19:57:00:466 IST] 000008a0 SystemOut     O    49                                                    com.ibm.websphere.ejbcontainer.EJBFactory
    [7/4/14 19:57:00:466 IST] 000008a0 SystemOut     O    50 (top)/com.ibm.websphere.ejbcontainer/query         javax.naming.Context
    [7/4/14 19:57:00:466 IST] 000008a0 SystemOut     O    51 (top)/com.ibm.websphere.ejbcontainer/query/querybean.jar
    [7/4/14 19:57:00:466 IST] 000008a0 SystemOut     O    51                                                    javax.naming.Context
    [7/4/14 19:57:00:467 IST] 000008a0 SystemOut     O    52 (top)/com.ibm.websphere.ejbcontainer/query/querybean.jar/EJBFactory
    [7/4/14 19:57:00:467 IST] 000008a0 SystemOut     O    52                                                    com.ibm.websphere.ejbcontainer.EJBFactory
    [7/4/14 19:57:00:467 IST] 000008a0 SystemOut     O    53 (top)/com.ibm.websphere.ejbcontainer/query/EJBFactory
    [7/4/14 19:57:00:467 IST] 000008a0 SystemOut     O    53                                                    com.ibm.websphere.ejbcontainer.EJBFactory
    [7/4/14 19:57:00:467 IST] 000008a0 SystemOut     O    54 (top)/SecurityServer                               com.ibm.ws.security.server._SecurityServer_Stub
    [7/4/14 19:57:00:467 IST] 000008a0 SystemOut     O    55 (top)/ejb                                          javax.naming.Context
    [7/4/14 19:57:00:467 IST] 000008a0 SystemOut     O    56 (top)/ejb/ivtEJBObject                             com.ibm.websphere.ivt.ivtEJB.ivtEJBHome
    [7/4/14 19:57:00:467 IST] 000008a0 SystemOut     O    57 (top)/ejb/mgmt                                     javax.naming.Context
    [7/4/14 19:57:00:468 IST] 000008a0 SystemOut     O    58 (top)/ejb/mgmt/MEJB                                javax.management.j2ee.ManagementHome
    [7/4/14 19:57:00:468 IST] 000008a0 SystemOut     O  
    [7/4/14 19:57:00:468 IST] 000008a0 SystemOut     O =============================================================================
    [7/4/14 19:57:00:468 IST] 000008a0 SystemOut     O End of Name Space Dump
    [7/4/14 19:57:00:468 IST] 000008a0 SystemOut     O =============================================================================
    [7/4/14 19:57:00:468 IST] 000008a0 SystemOut     O  
    
  4. Programmatically traverse the whole namespace.
  5. The previous method only displays the top level objects. Note that some to these objects are again sub-contexts(objects of type Context) that means it again as a hierarchy beneath it. To get the whole hierarchy,
    private static String previousPath="";
    
    protected void doGet(HttpServletRequest request,
      HttpServletResponse response) throws ServletException, IOException {
     try {
      Context initctx = new InitialContext();
      printBindings(initctx.listBindings(""));
     } catch (NamingException e) {
      e.printStackTrace();
     }
    
    }
    
    static void printBindings(NamingEnumeration bl) {
     if (bl == null)
      System.out.println("No items in list");
     else {
      try {
       while (bl.hasMore()) { 
        try {
         Binding b = (Binding) bl.next();
         System.out.println(b.getName() + "=: " + b.getObject());
         Context subContext = (b.getObject() instanceof Context ? (Context)b.getObject() : null); 
         if(subContext!=null) {
          findSubContexts(subContext, b.getName());
          System.out.println();
         }
        } catch(NameNotFoundException e){
         System.out.println("No names bound under this");
         System.out.println();
        }
       }
      
      }catch (NamingException e) {
       e.printStackTrace();
      } 
     }
    }
    
    static void findSubContexts(Context context, String name) {
     NameClassPair ncp = null;
     try {
      NamingEnumeration ne = context.list(name);
      while (ne.hasMoreElements()) {
       ncp = (NameClassPair) ne.nextElement();
       System.out.println(name + " ::: " + ncp.getName());
       if(previousPath.contains("/"+ncp.getName())){
                                    //this is needed as there are cross references within the tree and would cause indefinite loops
        System.out.println(">> Loop found");
        continue;
       }
       previousPath = name + "/" + ncp.getName();
       findSubContexts(context, name + "/" + ncp.getName());
      }
     } catch (NamingException e) {
      System.out.println("No names bound under : " + name);
      System.out.println();
     }
    }
    
    [7/6/14 13:47:38:616 IST] 00000023 SystemOut     O (top) UserRegistry == IOR:00bdbdbd0000003d524d493a636f6d2e69626d2....
    [7/6/14 13:47:38:616 IST] 00000023 SystemOut     O (top) tm == com.ibm.ws.naming.jndicos.CNContextImpl@2be85387[WIN-RANE51IRK16Node01Cell/nodes/WIN-RANE51IRK16Node01/servers/server1/tm]
    [7/6/14 13:47:38:616 IST] 00000023 SystemOut     O Fetching subContexts:
    [7/6/14 13:47:38:616 IST] 00000023 SystemOut     O No names bound under : tm
    [7/6/14 13:47:38:616 IST] 00000023 SystemOut     O 
    [7/6/14 13:47:38:616 IST] 00000023 SystemOut     O 
    [7/6/14 13:47:38:616 IST] 00000023 SystemOut     O (top) jta == com.ibm.ws.naming.jndicos.CNContextImpl@4f2d096e[WIN-RANE51IRK16Node01Cell/nodes/WIN-RANE51IRK16Node01/servers/server1/jta]
    [7/6/14 13:47:38:616 IST] 00000023 SystemOut     O Fetching subContexts:
    [7/6/14 13:47:38:617 IST] 00000023 SystemOut     O No names bound under : jta
    [7/6/14 13:47:38:617 IST] 00000023 SystemOut     O 
    [7/6/14 13:47:38:617 IST] 00000023 SystemOut     O 
    [7/6/14 13:47:38:617 IST] 00000023 SystemOut     O (top) AdminUserRegistry == IOR:00bdbdbd0000003d524d493a636f6d2e6962....
    [7/6/14 13:47:38:617 IST] 00000023 SystemOut     O (top) eis == com.ibm.ws.naming.jndicos.CNContextImpl@a06625f9[WIN-RANE51IRK16Node01Cell/nodes/WIN-RANE51IRK16Node01/servers/server1/eis]
    [7/6/14 13:47:38:617 IST] 00000023 SystemOut     O Fetching subContexts:
    [7/6/14 13:47:38:617 IST] 00000023 SystemOut     O No names bound under : eis
    [7/6/14 13:47:38:617 IST] 00000023 SystemOut     O 
    [7/6/14 13:47:38:617 IST] 00000023 SystemOut     O 
    [7/6/14 13:47:38:617 IST] 00000023 SystemOut     O (top) services == com.ibm.ws.naming.jndicos.CNContextImpl@aa4fd79b[WIN-RANE51IRK16Node01Cell/nodes/WIN-RANE51IRK16Node01/servers/server1/services]
    [7/6/14 13:47:38:618 IST] 00000023 SystemOut     O Fetching subContexts:
    [7/6/14 13:47:38:618 IST] 00000023 SystemOut     O No names bound under : services
    [7/6/14 13:47:38:618 IST] 00000023 SystemOut     O 
    [7/6/14 13:47:38:618 IST] 00000023 SystemOut     O 
    [7/6/14 13:47:38:618 IST] 00000023 SystemOut     O (top) servername == server1
    [7/6/14 13:47:38:618 IST] 00000023 SystemOut     O (top) jdbc == com.ibm.ws.naming.jndicos.CNContextImpl@258db8cf[WIN-RANE51IRK16Node01Cell/nodes/WIN-RANE51IRK16Node01/servers/server1/jdbc]
    [7/6/14 13:47:38:618 IST] 00000023 SystemOut     O Fetching subContexts:
    [7/6/14 13:47:38:618 IST] 00000023 SystemOut     O No names bound under : jdbc
    [7/6/14 13:47:38:618 IST] 00000023 SystemOut     O 
    [7/6/14 13:47:38:619 IST] 00000023 SystemOut     O 
    [7/6/14 13:47:38:619 IST] 00000023 SystemOut     O (top) ejb == com.ibm.ws.naming.jndicos.CNContextImpl@64856169[WIN-RANE51IRK16Node01Cell/nodes/WIN-RANE51IRK16Node01/servers/server1/ejb]
    [7/6/14 13:47:38:619 IST] 00000023 SystemOut     O Fetching subContexts:
    [7/6/14 13:47:38:619 IST] 00000023 SystemOut     O No names bound under : ejb
    ....
    this goes on for another 4000 lines.
    ....
    

Continue reading:Configure and lookup wrapper objects using env-entry (websphere)

No comments:

Post a Comment