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
==============================================================================

No comments:

Post a Comment