Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / June 2004

Tip: Looking for answers? Try searching our database.

Remote EJB/JNDI calling

Thread view: 
Chris - 17 Jun 2004 00:32 GMT
How's everyone doing today.. Good. :)

well my problem is driving me crazy, so I hope someone can help me
figure out why this is doing what it's doing.. i'm probably just doing
something "stupid"

I'm trying to call a remote stateless session bean from a different
physical box.

what i have working:  i have a ear file w/ the war + ejb.jar all
enclosed and that is working beautifully.  now i'm trying to
distribute out the processes.  have a "client" either tomcat or a java
application sitting on one box, and the ejb container w/ my session
facades on the other box.

my environment:  jboss 3.2.2-tomcat 4.1.24 bundle, linux redhat.

I've been monkeying around with the configuration and have gotten two
different errors.

1st error:  java application (see source below) on box one trying to
connect to box 2 jndi but saying connection refused to 127.0.0.1.  I
have also even removed (commented out) the localhost references to
/etc/hosts.

this is trying to do a simple listBindings.

java source:

import javax.naming.*;
import java.util.*;
import javax.rmi.PortableRemoteObject;

public class TestClient3 {

 public static void main(String[] args){
    try{
           
    String sInitialContextFactory =
"org.jnp.interfaces.NamingContextFactory";
    String sProviderUrl = "jnp://192.168.0.100:1099";  
    String sFactoryUrl = "java.naming.factory.url.pkgs";              
// also tried sInterface org.jboss.naming:org.jnp.interface
String sInterface = "org.jboss.naming.client:org.jnp.interfaces";            

    Hashtable env  = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, sInitialContextFactory);
    env.put(Context.PROVIDER_URL, sProviderUrl);
    env.put(sFactoryUrl, sInterface);

           
    InitialContext initialContext = new InitialContext(env);
                      System.out.println(initialContext.getEnvironment().toString());
  NamingEnumeration enum = initialContext.listBindings("");
  System.out.println(enum.toString());

  while (enum.hasMoreElements()) {
      System.out.println(enum.next().toString());
  }
}catch(Exception e){
  e.printStackTrace(System.err);
}
}
}

// my box ip i'm running this from is 192.168.0.194 and here's the
output results:

{java.naming.provider.url=192.168.0.100:1099,
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory,
java.naming.factory.url.pkgs=org.jboss.naming.client:org.jnp.interfaces}
javax.naming.CommunicationException [Root exception is
java.rmi.ConnectException: Connection refused to host: 127.0.0.1;
nested exception is:
    java.net.ConnectException: Connection refused]
    at org.jnp.interfaces.NamingContext.listBindings(NamingContext.java:796)
    at org.jnp.interfaces.NamingContext.listBindings(NamingContext.java:735)
    at javax.naming.InitialContext.listBindings(InitialContext.java:396)
    at xxx.xxx.xxx.xxx.client.TestClient3.main(TestClient3.java:48)
Caused by: java.rmi.ConnectException: Connection refused to host:
127.0.0.1; nested exception is:
    java.net.ConnectException: Connection refused
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:567)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:101)
    at org.jnp.server.NamingServer_Stub.listBindings(Unknown Source)
    at org.jnp.interfaces.NamingContext.listBindings(NamingContext.java:747)
    ... 3 more

Any Ideas?

Problem two.  I got the jndi connecting properly but when i try to a
lookup w/ the same string name i'm using through jndi on the bundled
process it's coming up w/

javax.naming.CommunicationException [Root exception is
java.rmi.NoSuchObjectException: no such object in table]
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:647)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
    at javax.naming.InitialContext.lookup(InitialContext.java:347)
    at xxx.xxx.xxx.client.TestClient2.main(TestClient2.java:48)
Caused by: java.rmi.NoSuchObjectException: no such object in table
    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
    at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:528)
    ... 3 more

source:
        public static void main(String args[]){
           
            try{
           
            String sInitialContextFactory =
"org.jnp.interfaces.NamingContextFactory";
            String sProviderUrl = "jnp://zodiac:1099";
// zodiac is 192.168.0.100
            String sFactoryUrl = "java.naming.factory.url.pkgs";
            String sInterface = "org.jboss.naming:org.jnp.interfaces";
               
               
            Hashtable env  = new Hashtable();

            env.put(Context.INITIAL_CONTEXT_FACTORY, sInitialContextFactory);
            env.put(Context.PROVIDER_URL, sProviderUrl);
            env.put(sFactoryUrl, sInterface);

            InitialContext ctx = new InitialContext(env);   

            Object jndi = ctx.lookup("zodiac_facade/BusinessService");           
                    Object portable = PortableRemoteObject.narrow(jndi,
getEJBClassRef(nServiceId));

            }catch(Exception e){
                e.printStackTrace(System.err);
            }

        }

and the jndi lookup string works inside the web container on the same
box... I even got it working through the client application on the
same box.... apparently the problem is just when it's on a remote box.
 there is no firewall i've turned off /etc/init.d/iptables.sh stop

i'm baffled,

someone please give me some pointers.

Chris
Marek Lange - 18 Jun 2004 13:11 GMT
> How's everyone doing today.. Good. :)
>
[quoted text clipped - 4 lines]
> I'm trying to call a remote stateless session bean from a different
> physical box.

Do you have a file called jndi.properties included in your application?

-marek
Chris - 18 Jun 2004 20:17 GMT
Marek,

Thank you for posting.  No I am not bundling a jndi.properties file..
I'm including a hashtable into my InitialContext constructor.  so
theoretically that should overwite the jndi.properties settings
anyways... I'm not jndi expert so I could very easily be wrong on
that.

Chris

> > How's everyone doing today.. Good. :)
> >
[quoted text clipped - 8 lines]
>
> -marek


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.