Skip to main content

JNDI properties for remote lookup

9 replies [Last post]
tomkri
Offline
Joined: 2008-06-20

What are the correct JNDI properties for accessing a EJB on a remote Glassfish server? According to the Glassfish FAQs im using the following properties within a tomcat

<br />
Properties properties = new Properties();<br />
properties.put("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");<br />
properties.put("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");<br />
properties.put("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");</p>
<p>properties.put("org.omg.CORBA.ORBInitialHost", "workplace");<br />
properties.put("org.omg.CORBA.ORBInitialPort", "19437");</p>
<p>Context context = new InitialContext(properties);<br />
Object object = context.lookup("at.grz.jp.samples.tomcat.SimpleService");<br />

During the lookup I get the following exception

<br />
07.05.2009 13:50:42 com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl<br />
WARNUNG: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 127.0.0.1; port: 19437"<br />
org.omg.CORBA.COMM_FAILURE:   vmcid: SUN  minor code: 201  completed: No<br />
	at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2690)<br />
	at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2711)<br />
	at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.(SocketOrChannelConnectionImpl.java:261)<br />
	at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.(SocketOrChannelConnectionImpl.java:274)<br />
	at com.sun.corba.ee.impl.transport.SocketOrChannelContactInfoImpl.createConnection(SocketOrChannelContactInfoImpl.java:130)<br />
	at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:192)<br />
	at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:181)<br />
	at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.is_a(CorbaClientDelegateImpl.java:325)<br />
	at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl.java:112)<br />
	at org.omg.CosNaming.NamingContextHelper.narrow(NamingContextHelper.java:69)<br />
	at com.sun.enterprise.naming.SerialContext.narrowProvider(SerialContext.java:134)<br />
	at com.sun.enterprise.naming.SerialContext.getRemoteProvider(SerialContext.java:220)<br />
	at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.java:159)<br />
	at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:409)<br />
	at javax.naming.InitialContext.lookup(InitialContext.java:392)<br />
	at at.grz.jp.samples.tomcat.LookupTest.testLookup(LookupTest.java:26)<br />
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br />
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br />
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br />
	at java.lang.reflect.Method.invoke(Method.java:597)<br />
	at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)<br />
	at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)<br />
	at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)<br />
	at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)<br />
	at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)<br />
	at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)<br />
	at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)<br />
	at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)<br />
	at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)<br />
	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)<br />
	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)<br />
	at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)<br />
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)<br />
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)<br />
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)<br />
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)<br />
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)<br />
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)<br />
Caused by: java.lang.RuntimeException: java.net.ConnectException: Connection refused: connect<br />
	at com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:347)<br />
	at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.(SocketOrChannelConnectionImpl.java:244)<br />
	... 35 more<br />
Caused by: java.net.ConnectException: Connection refused: connect<br />
	at sun.nio.ch.Net.connect(Native Method)<br />
	at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:507)<br />
	at com.sun.corba.ee.impl.orbutil.ORBUtility.openSocketChannel(ORBUtility.java:105)<br />
	at com.sun.enterprise.iiop.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:332)<br />
	... 36 more<br />

Where does the hostname 127.0.0.1 come from? As the connection could not be established, the port number is incremented automatically (e.g. 19438, 19439, ...).

Thanks,
Thomas

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
matterbury
Offline
Joined: 2008-05-01

> A question concerning the IIOP listeners configuration. Do I have to provide the IP address 10.18.9.43 instead of 0.0.0.0?

If you use 10.18.9.43 it should/will only listen to connections from that IP address.
If you use 0.0.0.0 it should/will listen to connections from any IP address.

(assuming I understand your question and that IIOP listeners are just normal TCP/IP listeners).

matterbury
Offline
Joined: 2008-05-01

Also check the IP address(es) of the server running GF ("workplace" ?). It could have a bogus mapping for "workplace" to 127.0.0.1

vkoniecz
Offline
Joined: 2008-11-14

Hi,

Is workplace a canonical host name ?
Have you checked whether GlassFish is listening on workplace:19438 or not ?
Are you using developer or cluster setups ?

Looks like GlassFish v2 has very surprising difficulties to handle hostnames or hosts with several IP addresses.
In a different thread, I have asked about any other people having difficulties with configurations like these. You may be.
It may be a good idea for you to describe further your own architecture so that we can see whether this may be the same problem again.

Bye

tomkri
Offline
Joined: 2008-06-20

> Is workplace a canonical host name ?

yes

> Have you checked whether GlassFish is listening on
> workplace:19438 or not ?

GlassFish is listening on the following IIOP ports:
* SLL (Listener Port: 14938, Network Address: 0.0.0.0)
* orb-listener-1 (Listener Port: 14937, Network Address: 0.0.0.0)
* SSL_MUTUALAUTH (Listener Port: 14939, Network Address: 0.0.0.0)

I have checked the ports with netstat on the server

> Are you using developer or cluster setups ?
I'm using developer setup

> Looks like GlassFish v2 has very surprising
> difficulties to handle hostnames or hosts with
> several IP addresses.

The server has two IP addresses; 10.18.9.43 is resolved via "nslookup workplace"; 10.18.9.45 is a virtual one (according to our companies system administrator)

> In a different thread, I have asked about any other
> people having difficulties with configurations like
> these. You may be.
> It may be a good idea for you to describe further
> your own architecture so that we can see whether this
> may be the same problem again.

Some notes to our architecture:
We are using an JEE container for providing a set of EJB services, that should be accessed by several web-applications; the EJB services are deployed on a test environment (RedHat Linux). The development is done on Windows XP; tomcat is used as local web-container while developing the web-applications. Therefore, we need a remote lookup to access the EJBs running on the test environment (GlassFish on workplace).

A question concerning the IIOP listeners configuration. Do I have to provide the IP address 10.18.9.43 instead of 0.0.0.0?

Thanks,
Thomas

matterbury
Offline
Joined: 2008-05-01

So, is the discrepancy between 19437 (your original post) and 14937 (your last post) just a typo, or is it really that simple?

tomkri
Offline
Joined: 2008-06-20

only a typo - 19437 is the correct port number; What a pity, I have to do further investigations ;-)

matterbury
Offline
Joined: 2008-05-01

Firstly, add this property: java.naming.provider.url=iiop://localhost:19437

If that doesn't work, remove the 3 initial java.naming properties you're setting (I have never had to set these).

If that still doesn't work, check what "workplace" maps to on the machine performing the lookup.

tomkri
Offline
Joined: 2008-06-20

Now I have replaced the server name with the IP address

[code]
properties.put("java.naming.provider.url","iiop://10.18.9.43:19437");
properties.put("org.omg.CORBA.ORBInitialHost", "10.18.9.43");
properties.put("org.omg.CORBA.ORBInitialPort", "19437");
[/code]

But connecting still fails and the exception message still points to the host-name 127.0.0.1 (see exception message above);

To be more detailed:
* Glassfish 2.1.0 libraries (javaee.jar, appserv-deployment-client.jar, appserv-ext.jar, appserv-rt.jar)
* JDK 1.6.0_13
* Simple JUnit test with JNDI-lookup

matterbury
Offline
Joined: 2008-05-01

What operating system are you using?
What is the hostname of the client making the request (where your JUnit program is running)?
What is its IP address(es)?

For example, if you're using *nix, check /etc/hosts and see if there's an entry in there for your hostname that (wrongly) maps it to 127.0.0.1.

And "dig " or "nslookup " should list the IP address(es) for .