Skip to main content

[TROUBLE] glassfish can not resolve JNDI name properly

4 replies [Last post]
L00kian
Offline
Joined: 2011-08-05

Hello,

I got one trouble while i've trying to get my EJB from EAR via corbaname:iiop
My glassfish is of version 3.1;

Information from server logs: Portable JNDI names for EJB ServerUtils :

[java:global/MailServer/ServerLogic/ServerUtils!serverlogic.ejb.logic.ServerUtilsRemote,
java:global/MailServer/ServerLogic/ServerUtils]

I've tried to resolve that name using the following code:

new InitialContext()
.lookup(&quot;corbaname:iiop:127.0.0.1:3700#java:global/MailServer/ServerLogic/ServerUtils&quot;);<br type="_moz" />

and that gives me following exception:

javax.naming.NameNotFoundException 
[Root exception is org.omg.CosNaming.NamingContextPackage.NotFound:
IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]
        at com.sun.jndi.cosnaming.ExceptionMapper.mapException(Unknown Source)
        at com.sun.jndi.cosnaming.CNCtx.callResolve(Unknown Source)
        at com.sun.jndi.cosnaming.CNCtx.lookup(Unknown Source)
        at com.sun.jndi.toolkit.url.GenericURLContext.lookup(Unknown Source)
        at javax.naming.InitialContext.lookup(Unknown Source)
        at consoleserver.Application.&lt;init&gt;(Application.java:17)
        at consoleserver.Main.main(Main.java:6)
Caused by: org.omg.CosNaming.NamingContextPackage.NotFound:
IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
        at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(Unknown Source)
        at org.omg.CosNaming._NamingContextStub.resolve(Unknown Source)<br />
Meanwhile my attempt to resolve "corbaname:iiop:127.0.0.1:3700#java:global/MailServer/ServerLogic/" gaves me this context.
Does anybody knows what to do?
Thanks,
Ilya

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
cf126330
Offline
Joined: 2005-03-29

You can inject the ejb-ref with @EJB into the calling component, and map the it in glassfish-web.xml to

corbaname:iiop:127.0.0.1:3700#java:global/MailServer/ServerLogic/ServerUtils

Another option without using @EJB injection is to declare the ejb-ref in the descriptor of the calling component, e.g., web.xml, application-client.xml, and map it in glassfish-web.xml or glassfish-application-client.xml. Your client can then look up the portable name of the ejb-ref ("java:comp/env/ejb/xxx");

L00kian
Offline
Joined: 2011-08-05

Sorry, i had to precise, my calling component is a stand-alone console client.

That thing had been worked when i was using the gf-client.jar library, but i need to get rid of it

cf126330
Offline
Joined: 2005-03-29

You can look up java:global/MailServer/ServerLogic/ServerUtils in java code, and pass the host & port in command line:

-Dorg.omg.CORBA.ORBInitialHost=xxx -Dorg.omg.CORBA.ORBInitialPort=xxxx

When running standalone java client, you will need gf-client.jar, which consists of all glassfish jars needed by java client. It may have more jars than is actually needed by your app, but it's safe and flexible to use gf-client.jar than to pick and choose jars to include in client classpath.

L00kian
Offline
Joined: 2011-08-05

Got it.

Thank you very much)