0

clarification:

all three names (I think, will confirm) work when everything is on localhost -- one JVM. None work when the client and Glassfish are on seperate computers.

The answer might very well be correct, it might be a different problem entirely.


What is the correct name to and syntax to lookup MyQueueRemote? When the client does a JNDI lookup on localhost, it runs fine. When the same client does a JNDI lookup on a remote server, a NameNotFoundException is thrown client by the client.

The SingletonQueue deploys and runs, locally, correctly. However, while the EAR deploys remotely (see below), the client cannot correctly lookup and resolve the remote lookup, throwing Root exception is javax.naming.NameNotFoundException: dur.bounceme.net.remote.MyQueueRemote not found.

the client runs correctly against SingletonQueue when deployed to Glassfish as an EAR:

thufir@dur:~$ 
thufir@dur:~$ glassfish-4.1/glassfish/bin/appclient -client NetBeansProjects/SingletonClient/dist/SingletonClient.jar 
Sep 24, 2014 10:44:00 PM net.bounceme.dur.jndi.RemoteJNDI main
INFO: 
Sep 24, 2014 10:44:00 PM net.bounceme.dur.jndi.RemoteJNDI main
INFO: {org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, org.omg.CORBA.ORBInitialHost=localhost, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl}
Sep 24, 2014 10:44:05 PM net.bounceme.dur.jndi.RemoteJNDI main
INFO: id    379
Sep 24, 2014 10:44:05 PM net.bounceme.dur.jndi.RemoteJNDI main
INFO: id    380
Sep 24, 2014 10:44:05 PM net.bounceme.dur.jndi.RemoteJNDI main
INFO: id    381
Sep 24, 2014 10:44:05 PM net.bounceme.dur.jndi.RemoteJNDI main

the remote Glassfish logs showing the JNDI name for MyQueueRemote:

ejb@ix:~$ 
ejb@ix:~$ tail glassfish4/glassfish/domains/domain1/logs/server.log  -n 63
[2014-09-25T01:50:10.470-0400] [glassfish 4.1] [INFO] [jts.startup_msg] [javax.enterprise.system.core.transaction.com.sun.jts.CosTransactions] [tid: _ThreadID=17 _ThreadName=RunLevelControllerThread-1411624177172] [timeMillis: 1411624210470] [levelValue: 800] [[
  JTS5014: Recoverable JTS instance, serverId = [3700]]]

[2014-09-25T01:50:20.028-0400] [glassfish 4.1] [INFO] [AS-EJB-00054] [javax.enterprise.ejb.container] [tid: _ThreadID=17 _ThreadName=RunLevelControllerThread-1411624177172] [timeMillis: 1411624220028] [levelValue: 800] [[
  Portable JNDI names for EJB MyQueue: [java:global/SingletonQueue/SingletonQueue-ejb/MyQueue, java:global/SingletonQueue/SingletonQueue-ejb/MyQueue!dur.bounceme.net.remote.MyQueueRemote]]]

[2014-09-25T01:50:20.030-0400] [glassfish 4.1] [INFO] [AS-EJB-00055] [javax.enterprise.ejb.container] [tid: _ThreadID=17 _ThreadName=RunLevelControllerThread-1411624177172] [timeMillis: 1411624220030] [levelValue: 800] [[
  Glassfish-specific (Non-portable) JNDI names for EJB MyQueue: [dur.bounceme.net.remote.MyQueueRemote#dur.bounceme.net.remote.MyQueueRemote, dur.bounceme.net.remote.MyQueueRemote]]]

the client stacktrace when run against the remote Glassfish server:

thufir@dur:~$ 
thufir@dur:~$ glassfish-4.1/glassfish/bin/appclient -client NetBeansProjects/SingletonClient/dist/SingletonClient.jar 
Sep 24, 2014 10:58:47 PM net.bounceme.dur.jndi.RemoteJNDI main
INFO: 
Sep 24, 2014 10:58:47 PM net.bounceme.dur.jndi.RemoteJNDI main
INFO: {org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, org.omg.CORBA.ORBInitialHost=ix.bounceme.net, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl}
Exception in thread "main" javax.naming.NamingException: Lookup failed for 'dur.bounceme.net.remote.MyQueueRemote' in SerialContext[myEnv={org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, org.omg.CORBA.ORBInitialHost=ix.bounceme.net, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is javax.naming.NameNotFoundException: dur.bounceme.net.remote.MyQueueRemote not found]
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438)
    at javax.naming.InitialContext.lookup(InitialContext.java:411)
    at net.bounceme.dur.jndi.RemoteJNDI.main(RemoteJNDI.java:16)
Caused by: javax.naming.NameNotFoundException: dur.bounceme.net.remote.MyQueueRemote not found
    at com.sun.enterprise.naming.impl.TransientContext.doLookup(TransientContext.java:237)
    at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:204)
    at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:66)
    at com.sun.enterprise.naming.impl.RemoteSerialContextProviderImpl.lookup(RemoteSerialContextProviderImpl.java:109)
    at sun.reflect.GeneratedMethodAccessor92.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie.dispatchToMethod(ReflectiveTie.java:143)
    at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:173)
    at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatchToServant(ServerRequestDispatcherImpl.java:528)
    at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatch(ServerRequestDispatcherImpl.java:199)
    at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequestRequest(MessageMediatorImpl.java:1549)
    at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:1425)
    at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleInput(MessageMediatorImpl.java:930)
    at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:213)
    at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:694)
    at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.dispatch(MessageMediatorImpl.java:496)
    at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.doWork(MessageMediatorImpl.java:2222)
    at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:497)
    at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:540)
thufir@dur:~$ 

client code:

package net.bounceme.dur.jndi;

import dur.bounceme.net.remote.MyQueueRemote;
import java.util.logging.Logger;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class RemoteJNDI {

    private static final Logger log = Logger.getLogger(RemoteJNDI.class.getName());

    public static void main(String... args) throws NamingException {
        InitialContext ctx = new InitialContext();
        log.info(ctx.getNameInNamespace());
        log.info(ctx.getEnvironment().toString());
        Object obj = ctx.lookup("dur.bounceme.net.remote.MyQueueRemote");
        MyQueueRemote queue = (MyQueueRemote) obj;
        while (true) {
            log.info("id\t" + queue.next());
        }
    }
}
Community
  • 1
  • 1
Thufir
  • 8,216
  • 28
  • 125
  • 273

1 Answers1

1
Portable JNDI names for EJB MyQueue: [java:global/SingletonQueue/SingletonQueue-ejb/MyQueue, java:global/SingletonQueue/SingletonQueue-ejb/MyQueue!dur.bounceme.net.remote.MyQueueRemote]

java:global/SingletonQueue/SingletonQueue-ejb/MyQueue
java:global/SingletonQueue/SingletonQueue-ejb/MyQueue!dur.bounceme.net.remote.MyQueueRemote 

Try one of theese two instead of

dur.bounceme.net.remote.MyQueueRemote
B0WSER
  • 104
  • 4
  • **both** of those `java:global/...` work fine **locally**. None work remotely, same `NameNotFoundException`. – Thufir Sep 25 '14 at 11:28
  • What do you mean "remotely"? Both JVMs client and server running on different hosts? If so, perhaps you are running glassfish on local host same time. And how do you configure your initial context? Where do you pass params so it connects to remote glassfish naming service? – B0WSER Sep 25 '14 at 14:47
  • the params are passed from `jndi.properties`, this is what the default constructor for the initial context pulls them from. `localhost` works fine, but the remote address fails as above. – Thufir Oct 01 '14 at 23:28
  • So, you cannot connect to remote naming service.If you are running linux on remote server, maybe because of iptables blocking access? – B0WSER Oct 06 '14 at 07:42
  • the error is `NameNotFound`, and, also, ssh works fine. Assuming your correct, how do you establish that iptables are blocking access? with a ping? or, how is that **disproved**? I don't believe it's a firewall, FWIW -- but how is that established. larger scope question now. I go back to the specific error message, `NameNotFound` -- why isn't it found? – Thufir Oct 06 '14 at 08:24
  • 1
    Sorry. I am understand now, you have NameNotFound for remote glassfish. So you can connect. Can you see that JNDI name in glassfish admin web console? Usually on port 4848 "Server"->"Resources" – B0WSER Oct 08 '14 at 08:21
  • @BOWSER I asked a better question here: http://stackoverflow.com/questions/26322294/corba-lookup-for-javacomp-env-or-javaglobal I'm not sure whether to accept your answer on this question or not. Also, I put my code on github for reference, because it spans several applications. Even if you don't have time to look at the newer question, I appreciate your help. – Thufir Oct 12 '14 at 05:53