Showing posts with label nameservicemanagement. Show all posts
Showing posts with label nameservicemanagement. Show all posts

Accessing local: namespace

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 invoke the NameServer MBean associated with that server process to dump the local: name space.

When you execute dumpNameSpace utility, it wont list out the references bound in local namespace in order to get those references you will have to use the following wsadmin script


def printLocalNameSpace(processname):
print "Printing Local name space for " + processname
nameserver =AdminControl.queryNames("*:*,type=NameServer,process="+processname)
print AdminControl.invoke(nameserver,"dumpLocalNameSpace",'["-report long"]')

printLocalNameSpace('server2')


The printLocalNameSpace function takes one argument, which is name of the server process and prints out the local name space on that server.

I do have only one EJB that has local interface, so when i tried executing the script i got this output


WASX7209I: Connected to process "dmgr" on node dmgrCellManager01 using SOAP connector; The type of process is: DeploymentManager
Printing Local name space for server2
==============================================================================
Name Space Dump
Starting context: (top)=local:
Time of dump: Tue Sep 08 19:25:11 PDT 2009
==============================================================================
==============================================================================
Beginning of Name Space Dump
==============================================================================
1 (top)
1 Bound Java type:
1 Local Java type: com.ibm.ws.naming.urlns.genericURLContextRoot
1 Corba binding type: org.omg.CosNaming.BindingType.ncontext
1 Context unique ID: ROOT CONTEXT
1 String representation: com.ibm.ws.naming.urlns.genericURLContextRoot(local:)
2 (top)/ejb
2 Bound Java type: javax.naming.Context
2 Local Java type: com.ibm.ws.naming.urlns.genericURLContext
2 Corba binding type: org.omg.CosNaming.BindingType.ncontext
2 Context unique ID: 9c02fd68-0123-ea43-3286-c0a8026baa77
2 String representation: com.ibm.ws.naming.urlns.genericURLContext(local:ejb)
3 (top)/ejb/ejb
3 Bound Java type: javax.naming.Context
3 Local Java type: com.ibm.ws.naming.urlns.genericURLContext
3 Corba binding type: org.omg.CosNaming.BindingType.ncontext
3 Context unique ID: 9c9a91b8-0123-ea76-4936-c0a8026baa77
3 String representation: com.ibm.ws.naming.urlns.genericURLContext(local:ejb/ejb)
4 (top)/ejb/ejb/ejbs
4 Bound Java type: javax.naming.Context
4 Local Java type: com.ibm.ws.naming.urlns.genericURLContext
4 Corba binding type: org.omg.CosNaming.BindingType.ncontext
4 Context unique ID: 9c9a91b9-0123-eb89-5cb4-c0a8026baa77
4 String representation: com.ibm.ws.naming.urlns.genericURLContext(local:ejb/ejb/ejbs)
5 (top)/ejb/ejb/ejbs/NameSpaceHome
5 Bound Java type: ejbs.EJSLocalStatelessNameSpaceHome_05679dcd
5 Local Java type: ejbs.EJSLocalStatelessNameSpaceHome_05679dcd
5 String representation: ejbs.EJSLocalStatelessNameSpaceHome_05679dcd@6df66df6(BeanId(__homeOfHomes#__homeOfHomes#__homeOfHomes, NameSpace#NameSpaceEJB.jar#NameSpace))
==============================================================================
End of Name Space Dump
==============================================================================
code>

As you can see the local Home interface for my EJB is bound to /ejb/ejb/ejbs/NameSpaceHome and the local namespace only has bindings related to it

Accessing java: namespace

As per J2EE specification you should not directly reference objects from JNDI instead developer should use reference in the code and then administrator will take care of mapping the reference to actual JNDI resource.

The dumpNameSpace utility can be used to dump global name space for managed process so it wont include java: namespace. The java: name space of a J2EE application is accessible only by that application. You can invoke a NameServer MBean to dump the java: name space for any J2EE application running in the same server process.

You can use the following wsadmin script to print the java: name space for a module. The printJavaNameSpace() module takes name of the enterprise application and the module name, which you can find from the application.xml


def printJavaNameSpace(processname,appname,modulename):
print 'Dumping Java Name space for ' + appname
nameserver =AdminControl.queryNames("*:*,type=NameServer,process="+processname)
print AdminControl.invoke(nameserver,"dumpJavaNameSpace", '['+appname +' ' + modulename +' Increment, "-report long"]' )

printJavaNameSpace('server2','HelloWorld',"HelloWorldWeb.war")


I tried this function on HelloWorld.war file and this is how the reference section of
HelloWorld.war looks like


<ejb-ref id="EjbRef_1252108343393">
<description id="Description_1252113864562">
</description>
<ejb-ref-name>ejb/HelloWorld</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>ejbs.HelloWorldHome</home>
<remote>ejbs.HelloWorld</remote>
<ejb-link>HelloWorldEJB.jar#HelloWorld</ejb-link>
</ejb-ref>
<resource-ref id="ResourceRef_1252109263105">
<description id="Description_1252113864311">
Data Source for connecting to HelloWorld DB</description>
<res-ref-name>jdbc/helloworlddb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>


As you can see the web.xml has two references one to is EJB reference and other is resource reference to jdbc data source

I get this output, as you can see the java: name space has quite a few bindings in addition to the bindings declared in the references, in addition to that it also has information of how the java: reference is mapped to the global name in JNDI tree


WASX7209I: Connected to process "dmgr" on node dmgrCellManager01 using SOAP connector; The type of process is: DeploymentManager
Dumping Java Name space for HelloWorld
==============================================================================
Name Space Dump
Starting context: (top)=java:
Time of dump: Tue Sep 08 17:56:45 PDT 2009
==============================================================================
==============================================================================
Beginning of Name Space Dump
==============================================================================
1 (top)
1 Bound Java type:
1 Local Java type: javax.naming.InitialContext
1 Corba binding type: org.omg.CosNaming.BindingType.ncontext
1 String representation: javax.naming.InitialContext@1aca1aca
2 (top)/comp
2 Bound Java type: com.ibm.ws.naming.java.javaURLContextImpl
2 Local Java type: com.ibm.ws.naming.java.javaURLContextImpl
2 Corba binding type: org.omg.CosNaming.BindingType.ncontext
2 Context unique ID: 9c02fe62-0123-f8d1-1e52-c0a8026baa77
2 String representation: com.ibm.ws.naming.java.javaURLContextImpl(java:comp)
3 (top)/comp/websphere
3 Bound Java type: javax.naming.Context
3 Local Java type: com.ibm.ws.naming.java.javaURLContextImpl
3 Corba binding type: org.omg.CosNaming.BindingType.ncontext
3 Context unique ID: 9c02fe82-0123-e81b-3890-c0a8026baa77
3 String representation: com.ibm.ws.naming.java.javaURLContextImpl(java:comp/websphere)
4 (top)/comp/websphere/ExtendedJTATransaction
4 Bound Java type: java.lang.Object
4 Local Java type: com.ibm.ws.jtaextensions.ExtendedJTATransactionImpl
4 String representation: com.ibm.ws.jtaextensions.ExtendedJTATransactionImpl@56265626
4 Source object is a javax.naming.Reference.
4 Reference factory class name: com.ibm.ws.jtaextensions.ExtendedJTATransactionFactory
5 (top)/comp/websphere/WorkAreaPartitionManager
5 Bound Java type: com.ibm.websphere.workarea.WorkAreaPartitionManager
5 Local Java type: com.ibm.ws.workarea.WorkAreaPartitionManagerImpl
5 String representation: com.ibm.ws.workarea.WorkAreaPartitionManagerImpl@7f967f96
5 Source object is a javax.naming.Reference.
5 Reference factory class name: com.ibm.ws.workarea.WorkAreaPartitionManagerFactory
6 (top)/comp/websphere/ApplicationNotificationService
6 Bound Java type: com.ibm.ws.asynchbeans.EventSourceImpl
6 Local Java type: com.ibm.ws.asynchbeans.EventSourceImpl
6 String representation: com.ibm.ws.asynchbeans.EventSourceImpl@3ea03ea
7 (top)/comp/websphere/UOWSynchronizationRegistry
7 Bound Java type: java.lang.Object
7 Local Java type: com.ibm.ws.uow.UOWManagerImpl
7 String representation: com.ibm.ws.uow.UOWManagerImpl@404a404a
7 Source object is a javax.naming.Reference.
7 Reference factory class name: com.ibm.ws.uow.jndi.UOWManagerJNDIFactory
8 (top)/comp/websphere/UOWManager
8 Bound Java type: java.lang.Object
8 Local Java type: com.ibm.ws.uow.UOWManagerImpl
8 String representation: com.ibm.ws.uow.UOWManagerImpl@404a404a
8 Source object is a javax.naming.Reference.
8 Reference factory class name: com.ibm.ws.uow.jndi.UOWManagerJNDIFactory
9 (top)/comp/websphere/AppProfile
9 Bound Java type: javax.naming.Context
9 Local Java type: com.ibm.ws.naming.java.javaURLContextImpl
9 Corba binding type: org.omg.CosNaming.BindingType.ncontext
9 Context unique ID: 9c02fe91-0123-fa23-28f6-c0a8026baa77
9 String representation: com.ibm.ws.naming.java.javaURLContextImpl(java:comp/websphere/AppProfile)
10 (top)/comp/websphere/AppProfile/TaskNameManager
10 Bound Java type: com.ibm.websphere.appprofile.TaskNameManager
10 Local Java type: com.ibm.ws.appprofile.TaskNameManagerImpl
10 String representation: com.ibm.ws.appprofile.TaskNameManagerImpl@65626562
10 Source object is a javax.naming.Reference.
10 Reference factory class name: com.ibm.ws.appprofile.AppProfileJavaColonFactory
11 (top)/comp/HandleDelegate
11 Bound Java type: java.lang.Object
11 Local Java type: com.ibm.ejs.csi.HandleDelegateImpl
11 String representation: com.ibm.ejs.csi.HandleDelegateImpl@6b406b40
11 Source object is a javax.naming.Reference.
11 Reference factory class name: com.ibm.ejs.csi.HandleDelegateFactory
12 (top)/comp/UserTransaction
12 Bound Java type: java.lang.Object
12 Local Java type: com.ibm.ws.Transaction.JTA.UserTransactionImpl
12 String representation: com.ibm.ws.Transaction.JTA.UserTransactionImpl@5be25be2
12 Source object is a javax.naming.Reference.
12 Reference factory class name: com.ibm.ws.Transaction.JTA.UtxJNDIFactory
13 (top)/comp/ORB
13 Bound Java type: java.lang.Object
13 Local Java type: com.ibm.CORBA.iiop.ORB
13 String representation: com.ibm.CORBA.iiop.ORB@51585158
13 Source object is a javax.naming.Reference.
13 Reference factory class name: com.ibm.ejs.oa.EJSORBFactory
14 (top)/comp/env
14 Bound Java type: com.ibm.ws.naming.java.javaURLContextImpl
14 Local Java type: com.ibm.ws.naming.java.javaURLContextImpl
14 Corba binding type: org.omg.CosNaming.BindingType.ncontext
14 Context unique ID: 9c02fe63-0123-f9e4-2a3c-c0a8026baa77
14 String representation: com.ibm.ws.naming.java.javaURLContextImpl(java:comp/env)
15 (top)/comp/env/ejb
15 Bound Java type: javax.naming.Context
15 Local Java type: com.ibm.ws.naming.java.javaURLContextImpl
15 Corba binding type: org.omg.CosNaming.BindingType.ncontext
15 Context unique ID: 9c02fe64-0123-ff44-5f3c-c0a8026baa77
15 String representation: com.ibm.ws.naming.java.javaURLContextImpl(java:comp/env/ejb)
16 (top)/comp/env/ejb/HelloWorld
16 Bound Java type: java.lang.Object
16 Local Java type: org.omg.stub.javax.ejb._EJBHome_Stub
16 String representation: IOR:00bdbdbd00000029524d493a656a62732e48656c6c6f576f726c64486f6d653a3030303030303030303030303030303000bdbdbd000000010000000000000934000102bd00000018646d67722e7765627370686572656e6f7465732e636f6d00238dbdbd0000009b4a4d42490000001203691e7538376531303336393165373530303232000000240000007749454a500201c4759d7908636c75737465723103454a420000005cacac0002000100290000005f5f686f6d654f66486f6d6573235f5f686f6d654f66486f6d6573235f5f686f6d654f66486f6d65730848656c6c6f576f726c642348656c6c6f576f726c64454a422e6a61722348656c6c6f576f726c64bd00000013000000010000001400bdbdbd0501000100000000000101000000000049424d0a0000000800bd00011500000200000026000000020002bdbd49424d04000000050005020102bdbdbd0000001f0000000400bd0003000000200000000400bd000100000021000002b80001bdbd000000040002bdbd000000240000002a00bd00260002bdbd0000000100000018646d67722e7765627370686572656e6f7465732e636f6d0024be00400000bdbd0000000806062b1200021e02000000280401000806062b1200021e020000001864656661756c7457494d46696c6542617365645265616c6d0000000000000001494210ce0000001d0000001964656661756c7457494d46696c6542617365645265616c6d00bdbdbd00000000000000000042bdbd000000240000002a00bd00660042bdbd0000000100000018646d67722e7765627370686572656e6f7465732e636f6d0024bd00400000bdbd0000000806062b1200021e02000000280401000806062b1200021e020000001864656661756c7457494d46696c6542617365645265616c6d0000000000000001494210ce0000001d0000001964656661756c7457494d46696c6542617365645265616c6d00bdbdbd00000000000000000002bdbd000000240000002a00bd00260002bdbd0000000100000018646d67722e7765627370686572656e6f7465732e636f6d0024be00400000bdbd000000080606678102010101000000280401000806066781020101010000001864656661756c7457494d46696c6542617365645265616c6d0000000000000001494210ce0000001d0000001964656661756c7457494d46696c6542617365645265616c6d00bdbdbd00000000000000000042bdbd000000240000002a00bd00660042bdbd0000000100000018646d67722e7765627370686572656e6f7465732e636f6d0024bd00400000bdbd000000080606678102010101000000280401000806066781020101010000001864656661756c7457494d46696c6542617365645265616c6d0000000000000001494210ce0000001d0000001964656661756c7457494d46696c6542617365645265616c6d00bdbdbd000000000000000049424d21000000a700bd00010001bdbd00000007435553544f4d00bd0000002649424d20576562537068657265204170706c69636174696f6e20536572766572202d204e4400bdbd00000009362e312e302e323500bdbdbd00000007362f312f303900bd0000000c63663235303932322e303600000000372863656c6c293a646d677243656c6c30313a286e6f6465293a646d67724e6f646530313a28736572766572293a6e6f64656167656e7400bd000000140000000800bd007e000124bd49424d0b0000008700000004000a646d677243656c6c30310008636c7573746572310000000223f123f224be24bd000873756e706174696c26ac0017646d67722e7765627370686572656e6f7465732e636f6d238d000000320000000002000b434c55535445524e414d450008636c757374657231000843454c4c4e414d45000a646d677243656c6c303100000000bd000000030000001400bdbdbd0000000973756e706174696c00bd26ac000000030000002200bdbdbd00000018646d67722e7765627370686572656e6f7465732e636f6d00238dbdbd49424d04000000050005020102bdbdbd0000001f0000000400bd0003000000200000000400bd0001000000250000000400bd000300000021000002b80001bdbd000000040002bdbd000000240000002a00bd00260002bdbd0000000100000018646d67722e7765627370686572656e6f7465732e636f6d0024c300400000bdbd0000000806062b1200021e02000000280401000806062b1200021e020000001864656661756c7457494d46696c6542617365645265616c6d0000000000000001494210ce0000001d0000001964656661756c7457494d46696c6542617365645265616c6d00bdbdbd00000000000000000042bdbd000000240000002a00bd00660042bdbd0000000100000018646d67722e7765627370686572656e6f7465732e636f6d0024c400400000bdbd0000000806062b1200021e02000000280401000806062b1200021e020000001864656661756c7457494d46696c6542617365645265616c6d0000000000000001494210ce0000001d0000001964656661756c7457494d46696c6542617365645265616c6d00bdbdbd00000000000000000002bdbd000000240000002a00bd00260002bdbd0000000100000018646d67722e7765627370686572656e6f7465732e636f6d0024c300400000bdbd000000080606678102010101000000280401000806066781020101010000001864656661756c7457494d46696c6542617365645265616c6d0000000000000001494210ce0000001d0000001964656661756c7457494d46696c6542617365645265616c6d00bdbdbd00000000000000000042bdbd000000240000002a00bd00660042bdbd0000000100000018646d67722e7765627370686572656e6f7465732e636f6d0024c400400000bdbd000000080606678102010101000000280401000806066781020101010000001864656661756c7457494d46696c6542617365645265616c6d0000000000000001494210ce0000001d0000001964656661756c7457494d46696c6542617365645265616c6d00bdbdbd000000000000000049424d21000000a500bd00010001bdbd00000007435553544f4d00bd0000002649424d20576562537068657265204170706c69636174696f6e20536572766572202d204e4400bdbd00000009362e312e302e323500bdbdbd00000007362f312f303900bd0000000c63663235303932322e303600000000352863656c6c293a646d677243656c6c30313a286e6f6465293a646d67724e6f646530313a28736572766572293a7365727665723200bdbdbd000000140000000800bd007e000124c4
16 Source object is a javax.naming.Reference.
16 Reference factory class name: com.ibm.ws.naming.util.IndirectJndiLookupObjectFactory
16 RefAddr[0]: Type: JndiLookupInfo
Content: JndiLookupInfo: jndiName="ejb/ejbs/HelloWorldHome"; providerURL=""; initialContextFactory=""
17 (top)/comp/env/jdbc
17 Bound Java type: javax.naming.Context
17 Local Java type: com.ibm.ws.naming.java.javaURLContextImpl
17 Corba binding type: org.omg.CosNaming.BindingType.ncontext
17 Context unique ID: 9c02fe81-0123-eb54-45fa-c0a8026baa77
17 String representation: com.ibm.ws.naming.java.javaURLContextImpl(java:comp/env/jdbc)
18 (top)/comp/env/jdbc/helloworlddb
18 ERROR: Could not instantiate a bound object.
18 Bound Java type: java.lang.Object
18 Local Java type: NULL
18 String representation:
18 Source object is a javax.naming.Reference.
18 Reference factory class name: com.ibm.ws.util.ResRefJndiLookupObjectFactory
18 RefAddr[0]: Type: ResRefJndiLookupInfo
Content: com.ibm.ws.util.ResRefJndiLookupInfo@32c632c6 ResRefJndiLookupInfo: Look up Name="jdbc/helloworlddb";JndiLookupInfo: jndiName="jdbc/helloworlddb "; providerURL=""; initialContextFactory=""
==============================================================================
End of Name Space Dump
==============================================================================

Naming service feature

The following are features of a WebSphere Application Server V6 name space
that remain unchanged from WebSphere Application Server V5:

    
  • Distributed name space: For additional scalability, the name space for a cell is distributed among the various servers. The deployment manager, node agent, and application server processes all host a name server. The default initial context for a server is its server root. System artifacts, such as EJB homes and resources, are bound to the server root of the server with which they are associated.

  • Transient and persistent partitions: The name space is partitioned into transient areas and persistent areas. Server roots are transient. System-bound artifacts such as EJB homes and resources are bound under server roots. There is a cell persistent root, which can be used for cell-scoped persistent bindings, and a node persistent root, which can be used to bind objects with a node scope.

  • Federated name space structure: A name space is a collection of all names bound to a particular name server. A name space can contain naming context bindings to contexts located in other servers. If this is the case, the name space is said to be a federated name space, because it is a collection of name spaces from multiple servers. The name spaces link together to cooperatively form a single logical name
    space.
    The name space for the WebSphere Application Server V6 cell is federated among the deployment manager, node agents, and application servers of the cell. Every server process hosts a name server. All name servers provide the same logical view of the cell name space, with the various server roots and persistent partitions of the name space being interconnected by means of the single logical name space.


  • Configured bindings: Administrators can configure bindings into the name space. A configured binding is different from a programmatic binding in that the system creates the binding every time a server is started, even if the target context is in a transient partition.

  • Support for CORBA Interoperable Naming Service (INS) object URLs WebSphere Application Server contains support for CORBA object URLs (corbaloc and corbaname) as JNDI provider URLs and lookup names

WebSphere Naming architecture

WebSphere Application Server name servers are an implementation of the CORBA CosNaming interface. WebSphere Application Server provides a JNDI implementation that you can use to access CosNaming name servers through the JNDI interface. CosNaming provides the server-side implementation and is where the name space is stored. JNDI essentially provides a client-side wrapper of the name space stored in CosNaming, and interacts with the CosNaming server on behalf of the client.

I copied this diagram from System Management Handbook red book, that explains the Naming service architecture