Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JNDI lookup across different WebSphere6 profiles, impossible?

891 views
Skip to first unread message

Jaimito

unread,
Oct 9, 2006, 6:29:52 PM10/9/06
to
Hi everybody,

I am experiencing some trouble trying to complete what looked like a very simple task, but got me stuck for days :'(

The thing is:
I have one WebSphere 6 base installation, with two profiles created.
Profile1: (myHostNode01Cell/nodes/myHostNode01/servers/server1; name server port: 2809)
Profile2: (myHostNode02Cell/nodes/myHostNode02/servers/server1; name server port: 2810)

I have an EJB deployed on Profile1's server (myHostCell01/nodes/myHostNode01/servers/server1/ejb/myEjb), and when I try to look it up from Profile2's server, using the following code:

[code]
Hashtable env = new Hashtable();
env.put(Context.PROVIDER_URL, "iiop://myHost:2809");
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
InitialContext ic = new InitialContext(env);
System.out.println("Context starting at: " + ic.getNameInNamespace()); /* Pay attention to this output */
Object o = ic.lookup("ejb/myEJB");
System.out.println("Object bound to ejb/myEJB: " + o);
[/code]

I get the following output:

[code]
[b]Context starting at: myHostNode02Cell/nodes/myHostNode02/servers/server1[/b] (Should be myHostNode01Cell/nodes/myHostNode01/servers/server1!!!)

javax.naming.NameNotFoundException: Context: myHostNode02Cell/nodes/myHostNode02/servers/server1, name: ejb/myEJB: First component in name myEJB not found. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL :o mg.org/CosNaming/NamingContext/NotFound:1.0
at com.ibm.ws.naming.ipcos.WsnOptimizedNamingImpl.do_resolve_complete_info(WsnOptimizedNamingImpl.java:543)
at com.ibm.ws.naming.cosbase.WsnOptimizedNamingImplBase.resolve_complete_info(WsnOptimizedNamingImplBase.java:2213)
at com.ibm.WsnOptimizedNaming._NamingContextStub.resolve_complete_info(Unknown Source)
at com.ibm.ws.naming.jndicos.CNContextImpl.cosResolve(CNContextImpl.java:4043)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1746)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1707)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1412)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1290)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:145)
at javax.naming.InitialContext.lookup(InitialContext.java:361)
at com.ibm._jsp._TestCase.getMyEJB(_TestCase.java:107)
at com.ibm._jsp._TestCase._jspService(_TestCase.java:156)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:91)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1572)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1521)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java(Compiled Code))
at co.com.proteccion.mua.servlet.filter.ValidarSesionFilter.doFilter(ValidarSesionFilter.java:98)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:142)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java(Compiled Code))
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:759)
at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:121)
at com.ibm.ws.jsp.webcontainerext.JSPExtensionServletWrapper.handleRequest(JSPExtensionServletWrapper.java:204)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:89)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1924)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:89)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:472)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:411)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:288)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminaters(NewConnectionInitialReadCallback.java:207)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:109)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))

[/code]

It seems that I cannot instanciate an InitialContext from one profile's server to another.

I have tried corbaname and corbaloc format for the provider url. I have also tried using ejb-ref, configured bindings (CORBA), with no success.


When I run this code from another server (in another machine), it just works fine.

[code]
Context starting at: myHostNode01Cell/nodes/myHostNode01/servers/server1
Object bound to ejb/myEJB: IOR:0000000000000037524d493a636f2e636f6d2e70726f74656363696f6e2e6c6f672e656a622e4c6f67486f6d653a30303030303030303030303030303030000000000001(...)
[/code]


Do you guys know if it is posible to access to a was6 profile's server JNDI namespace from another profile?

Thanks in advance!

Paul Ilechko

unread,
Oct 9, 2006, 7:09:04 PM10/9/06
to
Jaimito wrote:
> Hi everybody,
>
> I am experiencing some trouble trying to complete what looked like a very simple task, but got me stuck for days :'(
>
> The thing is:
> I have one WebSphere 6 base installation, with two profiles created.
> Profile1: (myHostNode01Cell/nodes/myHostNode01/servers/server1; name server port: 2809)
> Profile2: (myHostNode02Cell/nodes/myHostNode02/servers/server1; name server port: 2810)
>
> I have an EJB deployed on Profile1's server (myHostCell01/nodes/myHostNode01/servers/server1/ejb/myEjb), and when I try to look it up from Profile2's server, using the following code:
<snip>

>
> Do you guys know if it is posible to access to a was6 profile's server JNDI namespace from another profile?
>
> Thanks in advance!

I'm not sure if this is supposed to work - you could open a PMR to get a
definitive answer - but as a workaround you could create an indirect
reference by adding a new namespace binding. This is how you would do it
to access a JNDI ref for an EJB in a different ND cell.

Given that you are using WAS 6 Base, not ND, it may be behaving like it
was a remote cell in the ND world, as there is no federation and no
clustering in Base.

adw...@pulpjava.com

unread,
Oct 9, 2006, 11:47:44 PM10/9/06
to

Wo, wo, wo...No PMRs here.

If it is two profiles that are not in a common administrative domain,
then they are two totally separate environment. They could be on the
same machine, or on different planets - they're totally different JNDI
servers. My local WebSphere profile can't connect to your websphere
profile.

Now, if they are in the same administrative domain, then that's another
story. Do they have a common deployment manager? If so, then we need to
use a different naming mechanism:

One way is to use an architectural dependent name. Use this for
confirmation, but not as a long-term solution. Once you've got the
achitecture depended name working, use a reference to the name, set up
in the WAS admin console, NOT the deployment descriptor.

JNDI can be confusing, especially in the federated namespace of
WebSphere 5.1 and WebSphere 6.1 My website explains it all, and my
book, What is WebSphere?, explains it even better. ;)

http://www.technicalfacilitation.com/get.php?link=naming

-Cameron McKenzie www.pulpjava.com

Check out my new certification guides and free mock tests for the new
Sun Certified Java Associate (SCJA) certification from Sun. It's the
new entry level Java certification: www.scja.com

Paul Ilechko

unread,
Oct 10, 2006, 10:00:09 AM10/10/06
to
Jaimito wrote:
> Hi, Paul. Thanks for your answer!

>
>> I'm not sure if this is supposed to work - you could open a PMR to
>> get a definitive answer - but as a workaround you could create an
>> indirect reference by adding a new namespace binding. This is how
>> you would do it to access a JNDI ref for an EJB in a different ND
>> cell.
>>
>> Given that you are using WAS 6 Base, not ND, it may be behaving
>> like it was a remote cell in the ND world, as there is no
>> federation and no clustering in Base.
>
> I already tried using configured bindings (CORBA type), and while it
> seems to succesfully locate the JNDI named objects, it still fails by
> throwing a weird CORBA exception.

Don't have time to look at this in detail right now, but the following
may help:

For a server in a different cell as the ServerCluster hosting the remote
EJB, assuming the remote EJB was bound into "ClusterB" with JNDI name
"ejb/CellBService", then you would create an indirect reference through
the WAS Admin console for the client cell.

The indirect reference would be stored in the cell-persistent area of
the namespace.
From AdminConsole->Environment->Naming->Name Space Bindings -> New(leave
at cell scope)

The properties you would set are:
Binding Type: Indirect
Binding Identifier: My outside cell serviceX
Name in Name Space: "ejb/OutsideCellService" -> this is what the client
bindings use for mapping
Proivder URL: "iiop://cellBHost:2819" where cellBHost is a server in
the outside cell and 2819 is its bootstrap port
JNDI Name: "cell/clusters/ClusterB/ejb/CellBService"

The client EJB reference would be bound to:
"cell/persistent/ejb/OutsideCellService"

The client module(web module or ejb) would have an EJB Reference in its
deployment descriptor.
If the EJB Reference was "ejb/StockService", then the application code
would perform the JNDI lookup using "java:comp/env/ejb/StockService"

Jaimito

unread,
Oct 10, 2006, 9:52:11 AM10/10/06
to
Hi, Paul. Thanks for your answer!

> I'm not sure if this is supposed to work - you could


> open a PMR to get a
> definitive answer - but as a workaround you could
> create an indirect
> reference by adding a new namespace binding. This is
> how you would do it
> to access a JNDI ref for an EJB in a different ND
> cell.
>
> Given that you are using WAS 6 Base, not ND, it may
> be behaving like it
> was a remote cell in the ND world, as there is no
> federation and no
> clustering in Base.

I already tried using configured bindings (CORBA type), and while it seems to succesfully locate the JNDI named objects, it still fails by throwing a weird CORBA exception.

I linked a context named "profile1ServerRootContext" to the Profile1's server root context in the following way.

(In profile2):
Scope: cells/myHostNode02Cell/nodes/myHostNode02/servers/server1
Binding Type: CORBA
Binding Identifier: profile1ServerRootContext
Name in Name Space: profile1ServerRootContext
Corbaname URL: corbaloc:iiop:myHost:2809/NameServiceServerRoot
Federated context: Yes

(In other words:
cells/myHostNode02Cell/nodes/myHostNode02/servers/server1/profile1ServerRootContext -> cells/myHostNode01Cell/nodes/myHostNode01/servers/server1)

Then, when I run this code (in profile2' server):
[code]
InitialContext ic = new InitialContext();
Object o = ic.lookup("profile1ServerRootContext/ejb/myEJB");
System.out.println("Object bound to profile1ServerRootContext/ejb/myEJB: " + o);
[/code]
I get the following stack trace:
[code]
javax.naming.NamingException: Error during resolve. Root exception is org.omg.CORBA.OBJECT_NOT_EXIST: SERVANT_NOT_FOUND (4) for key 0x49454a500200d3e9fd8f077365727(...) vmcid: IBM minor code: C14 completed: No
at com.ibm.rmi.corba.ObjectManager.lookupServant(ObjectManager.java:109)
at com.ibm.CORBA.iiop.ServerDelegate.getServant(ServerDelegate.java:298)
at com.ibm.rmi.iiop.ORB.lookupLocalObject(ORB.java:532)
at com.ibm.CORBA.iiop.ORB.lookupLocalObject(ORB.java:1630)
at com.ibm.rmi.iiop.CDRInputStream.newObjRef(CDRInputStream.java:1106)
at com.ibm.rmi.iiop.CDRInputStream.read_Object(CDRInputStream.java:1083)
at com.ibm.rmi.iiop.CDRInputStream.read_Object(CDRInputStream.java:1018)
at org.omg.CORBA.ObjectHelper.read(ObjectHelper.java:108)
at com.ibm.WsnOptimizedNaming._NamingContextStub.resolve_complete_info(Unknown Source)
at com.ibm.ws.naming.cosbase.WsnOptimizedNamingImplBase.resolve_complete_info(WsnOptimizedNamingImplBase.java:2229)


at com.ibm.WsnOptimizedNaming._NamingContextStub.resolve_complete_info(Unknown Source)
at com.ibm.ws.naming.jndicos.CNContextImpl.cosResolve(CNContextImpl.java:4043)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1746)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1707)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1412)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1290)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:145)

at javax.naming.InitialContext.lookup(InitialContext.java(Compiled Code))


at com.ibm._jsp._TestCase.getMyEJB(_TestCase.java:107)
at com.ibm._jsp._TestCase._jspService(_TestCase.java:156)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:91)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java(Compiled Code))


at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java(Compiled Code))
at co.com.proteccion.mua.servlet.filter.ValidarSesionFilter.doFilter(ValidarSesionFilter.java:98)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:142)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java(Compiled Code))
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:759)
at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:121)
at com.ibm.ws.jsp.webcontainerext.JSPExtensionServletWrapper.handleRequest(JSPExtensionServletWrapper.java:204)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:89)

at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java(Compiled Code))
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java(Compiled Code))


at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
[/code]

When a change the JNDI name for a non-existent one (say, profile1ServerRootContext/ejb/myNonExistentEJB), the stack trace changes as well:
[code]
javax.naming.NameNotFoundException: Context: myHostNode02Cell/nodes/myHostNode02/servers/server1, name: profile1ServerRootContext/ejb/myNonExistentEJB: [b]First component in name myNonExistentEJB not found[/b]. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:85)
at com.ibm.WsnOptimizedNaming._NamingContextStub.resolve_complete_info(Unknown Source)
at com.ibm.ws.naming.cosbase.WsnOptimizedNamingImplBase.resolve_complete_info(WsnOptimizedNamingImplBase.java:2229)


at com.ibm.WsnOptimizedNaming._NamingContextStub.resolve_complete_info(Unknown Source)
at com.ibm.ws.naming.jndicos.CNContextImpl.cosResolve(CNContextImpl.java:4043)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1746)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1707)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1412)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1290)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:145)

at javax.naming.InitialContext.lookup(InitialContext.java(Compiled Code))


at com.ibm._jsp._TestCase.getMyEJB(_TestCase.java:107)
at com.ibm._jsp._TestCase._jspService(_TestCase.java:156)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:91)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java(Compiled Code))


at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java(Compiled Code))
at co.com.proteccion.mua.servlet.filter.ValidarSesionFilter.doFilter(ValidarSesionFilter.java:98)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:142)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java(Compiled Code))
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:759)
at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:121)
at com.ibm.ws.jsp.webcontainerext.JSPExtensionServletWrapper.handleRequest(JSPExtensionServletWrapper.java:204)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:89)

at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java(Compiled Code))
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java(Compiled Code))


at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:288)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminaters(NewConnectionInitialReadCallback.java:207)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:109)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
[/code]

Of course, if the two profiles were federated into a deployment manager cell, I would not be facing this tricky problem, but installing ND is not feasible right now.

0 new messages