Forum Stats

  • 3,758,931 Users
  • 2,251,475 Discussions
  • 7,870,440 Comments

Discussions

Cannot remotely find JNDI resources using InitialContext

Charles Lee
Charles Lee Member Posts: 10
edited Oct 23, 2012 5:53AM in Java Message Service (JMS)
I've got 2 laptops here, running next to eachother, connected to the same network switch. One is running an almost default instance of glassfish 3x, the other is running a client OUTSIDE of the container comprised of only a few lines of code to get a connectionFactory from the Glassfish server.
Running both on the same machine works like a charm, but when ran on different machines it refuses to connect, and my head-ache is now getting worse by the minute...

Server side:
============
Running inside Netbeans IDE 7.2

GlassFish Server version: 3+
JMS Service Type: LOCAL (instead of EMBEDDED)
Created javax.jms.QueueConnectionFactory named "TapServiceConnectionFactory" under JMS Resources.

Glassfish configuration is otherwise untouched (I've fooled around lots, so created a clean glassfish instance for this example):

Startup log:

Launching GlassFish on Felix platform
INFO: Running GlassFish Version: GlassFish Server Open Source Edition 3.1.2.2 (build 5)
INFO: Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for persistence-type = replicated in BackingStoreFactoryRegistry
INFO: Grizzly Framework 1.9.50 started in: 69ms - bound to [0.0.0.0:8080]
INFO: Grizzly Framework 1.9.50 started in: 21ms - bound to [0.0.0.0:4848]
INFO: Grizzly Framework 1.9.50 started in: 36ms - bound to [0.0.0.0:8181]
INFO: Grizzly Framework 1.9.50 started in: 24ms - bound to [0.0.0.0:3700]
INFO: The Admin Console is already installed, but not yet loaded.
INFO: GlassFish Server Open Source Edition 3.1.2.2 (5) startup time : Felix (3,007ms), startup services(1,486ms), total(4,493ms)
INFO: HV000001: Hibernate Validator 4.3.0.Final
INFO: Grizzly Framework 1.9.50 started in: 12ms - bound to [0.0.0.0:8080]
INFO: JMS010: ADDRESSLIST in setJmsServiceProvider: mq://localhost:7676/
INFO: JMS08: JMS Service Connection URL is : mq://localhost:7676/
INFO: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter: Version: 4.5.2 Patch 1 (Build 3-d) Compile: Thu Jun 7 10:46:15 PDT 2012
INFO: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter starting: broker is LOCAL, connection mode is TCP
INFO: Grizzly Framework 1.9.50 started in: 11ms - bound to [0.0.0.0:8181]
INFO: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter Started:LOCAL
INFO: Created EjbThreadPoolExecutor with thread-core-pool-size 16 thread-max-pool-size 32 thread-keep-alive-seconds 60 thread-queue-capacity 2147483647 allow-core-thread-timeout false
INFO: Initiating Jersey application, version 'Jersey: 1.11.1 03/31/2012 06:49 PM'
INFO: REST00001: Listening to REST requests at context: /management/domain
INFO: The Admin Console is already installed, but not yet loaded.
INFO: The Admin Console is starting. Please wait.
INFO: JMX005: JMXStartupService had Started JMXConnector on JMXService URL service:jmx:rmi://localhost:8686/jndi/rmi://localhost:8686/jmxrmi
INFO: WEB0169: Created HTTP listener [http-listener-1] on host/port [0.0.0.0:8080]
INFO: WEB0169: Created HTTP listener [http-listener-2] on host/port [0.0.0.0:8181]
INFO: WEB0169: Created HTTP listener [admin-listener] on host/port [0.0.0.0:4848]
INFO: WEB0171: Created virtual server [server]
INFO: WEB0171: Created virtual server [__asadmin]
INFO: WEB0172: Virtual server [server] loaded default web module []
INFO: SEC1002: Security Manager is OFF.
INFO: SEC1010: Entering Security Startup Service
INFO: SEC1143: Loading policy provider com.sun.enterprise.security.provider.PolicyWrapper.
INFO: SEC1115: Realm [admin-realm] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
INFO: SEC1115: Realm [file] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
INFO: SEC1115: Realm [certificate] of classtype [com.sun.enterprise.security.auth.realm.certificate.CertificateRealm] successfully created.
INFO: SEC1011: Security Service(s) Started Successfully
INFO: Initializing Mojarra 2.1.6 (SNAPSHOT 20111206) for context ''
INFO: WEB0671: Loading application [__admingui] at []
INFO: CORE10010: Loading application __admingui done in 8,732 ms
INFO: The Admin Console application is loaded.


ClientSide:
===========

Simple maven application containing 1 class with a main-method:


import com.sun.enterprise.naming.SerialInitContextFactory;
import java.util.Hashtable;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;

/**
* The SimpleClient class sends several messages to a
* destination.
*/
public class SimpleClient {

/**
* Main method.
*/
public static void main(String[] args) {

Context jndiContext = null;
ConnectionFactory connectionFactory = null;
Connection connection = null;
Session session = null;
Queue queue = null;
MessageProducer messageProducer = null;

try
{
Hashtable properties = new Hashtable(2);

properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
properties.put(Context.PROVIDER_URL, "iiop://172.19.1.25:7676"); // vm://localhost:
properties.put("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
properties.put("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");


jndiContext = new InitialContext(properties);

connectionFactory = (ConnectionFactory) jndiContext.lookup("TapServiceConnectionFactory");

// Lookup queue
// get MessageProducer
// Send TextMessage
}
catch(Exception ex)
{
System.out.println("Error: " + ex );
}


finally
{
if(connection !=null)
{
try
{
connection.close();
}
catch(JMSException e)
{
System.out.println("Error: " + e );
}
}
}
}
}


POM.XML:

<repositories>
<repository>
<id>Java.Net</id>
<url>http://download.java.net/maven/2/</url>
</repository>
</repositories>


<dependencies>
<dependency>
<groupId>org.glassfish.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>3.1.1</version>
<type>jar</type>
</dependency>
</dependencies>


This is what happens if my glassfish server is running and the client is started:

=============
run:
org.omg.CORBA.COMM_FAILURE: FINE: IOP00410001: Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: localhost; port: 3700 vmcid: OMG minor code: 1 completed: No
at sun.reflect.GeneratedConstructorAccessor27.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at com.sun.corba.ee.spi.orbutil.logex.corba.CorbaExtension.makeException(CorbaExtension.java:248)
at com.sun.corba.ee.spi.orbutil.logex.corba.CorbaExtension.makeException(CorbaExtension.java:95)TapServiceConnectionFactory
at com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator.handleFullLogging(WrapperGenerator.java:387)
at com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator.access$400(WrapperGenerator.java:107)
at com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator$2.invoke(WrapperGenerator.java:511)
at com.sun.corba.ee.spi.orbutil.proxy.CompositeInvocationHandlerImpl.invoke(CompositeInvocationHandlerImpl.java:99)
at $Proxy26.connectFailure(Unknown Source)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:257)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:270)
at com.sun.corba.ee.impl.transport.SocketOrChannelContactInfoImpl.createConnection(SocketOrChannelContactInfoImpl.java:129)
at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:223)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:228)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.is_a(CorbaClientDelegateImpl.java:393)
at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl.java:130)
at org.omg.CosNaming.NamingContextHelper.narrow(NamingContextHelper.java:69)
at com.sun.enterprise.naming.impl.SerialContext$ProviderCacheKey.getNameService(SerialContext.java:1241)
at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:411)
at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:347)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:504)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at nl.tap.service.client.jupiterclientnextgen.SimpleClient.main(SimpleClient.java:71)
Caused by: java.lang.RuntimeException: java.net.ConnectException: Connection refused: connect
at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:339)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:242)
... 14 more
Caused by: java.net.ConnectException: Connection refused: connect
at sun.nio.ch.Net.connect0(Native Method)
at sun.nio.ch.Net.connect(Net.java:364)
at sun.nio.ch.Net.connect(Net.java:356)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:623)
at com.sun.corba.ee.impl.orbutil.ORBUtility.openSocketChannel(ORBUtility.java:110)
at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:324)
... 15 more
Error: javax.naming.NamingException: Lookup failed for 'TapServiceConnectionFactory' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory, java.naming.provider.url=iiop://172.19.1.25:7676, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory, java.naming.provider.url=iiop://172.19.1.25:7676, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is org.omg.CORBA.COMM_FAILURE: FINE: IOP00410001: Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: localhost; port: 3700 vmcid: OMG minor code: 1 completed: No]]

=============

Also not very sure which port to use, 3700 (JMS) or 7676 (IIOPS), however, I've tried both, but both fail.
I'm out of ideas :/

Edited by: 964095 on Oct 9, 2012 5:33 AM
Tagged:

Answers

  • 964095 wrote:

    Also not very sure which port to use, 3700 (JMS) or 7676 (IIOPS), however, I've tried both, but both fail.
    Other way round. 3700 is for IIOP, 7676 is for JMS. Note that you're not using JMS at this point, just JNDI, so you don't want 7676.
    I'm out of ideas :/
    The Oracle GlassFish Server documentation for what you are trying to do is here:
    http://docs.oracle.com/cd/E26576_01/doc.312/e24930/java-clients.htm#gkuqa

    If you have problems, ask in the GlassFish forum at
    http://www.java.net/forums/glassfish/glassfish

    (since this isn't a JMS issue, it's a GlassFish JNDI issue)

    Nigel
  • Charles Lee
    Charles Lee Member Posts: 10
    Thanx for your reply Nigel.
    It has been a true bitch to get to work, but using:
            
    properties.put("org.omg.CORBA.ORBInitialHost", "<IP>");
    properties.put("org.omg.CORBA.ORBInitialPort", "3700");
    ... instead of Context.PROVIDER_URL seemed to have done the trick eventually.
This discussion has been closed.