The Artima Developer Community
Sponsored Link

Jini Forum
JINI client connection

10 replies on 1 page. Most recent reply: Mar 31, 2004 1:08 AM by ug

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 10 replies on 1 page
Cristi

Posts: 9
Nickname: cristiand
Registered: Feb, 2002

JINI client connection Posted: Feb 28, 2002 7:27 AM
Reply to this message Reply
Advertisement
I'm trying to run the following code from host nessie (where no JINI service is running, and all necessary classes are in the CLASSPATH) in order to access the list of all JINI services at the host javaspace on which a http server, rmid, lookup manager, are present and running. The code is:

....
public static void main(String[] args)
      throws RemoteException, IOException, ClassNotFoundExceptionM
   {
      System.setSecurityManager(new RMISecurityManager());
        LookupLocator lookup = null;
        Entry[] entries = null;
        ServiceRegistrar registrar = null;
 
        System.out.println("One");
        lookup = new LookupLocator("jini://javaspace");
        System.out.println("Two");
        registrar = lookup.getRegistrar(); 
        System.out.println("Three");
 
        entries = new Entry[] {};
        ServiceMatches sm = registrar.lookup(
            new ServiceTemplate(null,null, entries),
            10);
        System.out.println("Four");
.....   }
.....


and get the following output:

One
Two
Three
Exception in thread "main" java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
        java.net.ConnectException: Connection refused
java.net.ConnectException: Connection refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:320)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:133)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:120)
        at java.net.Socket.<init>(Socket.java:273)
        at java.net.Socket.<init>(Socket.java:100)
        at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:25)
        at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:120)
        at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:499)
        at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:190)
        at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:174)
        at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:83)
        at sun.rmi.server.Activation$ActivatorImpl_Stub.activate(Unknown Source)
        at java.rmi.activation.ActivationID.activate(ActivationID.java:89)
        at sun.rmi.server.ActivatableRef.activate(ActivatableRef.java:250)
        at sun.rmi.server.ActivatableRef.invoke(ActivatableRef.java:187)
        at com.sun.jini.reggie.RegistrarImpl_Stub.lookup(Unknown Source)
        at com.sun.jini.reggie.RegistrarProxy.lookup(RegistrarProxy.java:102)
        at ExempluJavaSpaces.main(ExempluJavaSpaces.java:54)


What's localhost got to do with all of the above? I mention only the other host name(javaspace) in my code. Should I run some of the JINI tools on the machine (nessie)? The network connections are OK and specifying the entire name (with domain) of the machines is useless. Running the code on the javaspace machine works fine. It's not a firewall problem, either.

And by the way, how can a firewall be set up on a machine that is running JINI services in order to leave only the minimum number of ports open to the exterior? Which are the numbers of these ports?

I'll appreciate any help. Thank you.


Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Re: JINI client connection Posted: Mar 14, 2002 10:31 AM
Reply to this message Reply
I wonder if your problem is the codebase annotation of classes that nessie is attempting to download from javaspace as a result of the lookup. If that codebase annotation is localhost, then it would work OK on javaspace but not nessie.

Cristi

Posts: 9
Nickname: cristiand
Registered: Feb, 2002

Re: JINI client connection Posted: Mar 21, 2002 9:03 AM
Reply to this message Reply
Thank you for the answer, but, unfortunately it is not as simple as that.

The problem is not in the codebase property, which is set correctly on the command line when running the application - anyway, all classes that are needed by the client application are on the local CLASSPATH.

The strangest thing is that running a similar client (with the same settings) in order to list all JINI services running on host stranger (other than javaspace), with, again, all services configured exactly the same as on the javaspace machine, works fine.

It is not a firewall problem, either, the javaspace machine and the client do not have firewall rules. I have tried from more client machines, and get the same result. When the services run on machine stranger, everything is OK.

javaspace and stranger are Linux machines running RedHat7.2.

Any suggestions for what a client application would want to access on the localhost? And why?

Thank you.

Cristi

Posts: 9
Nickname: cristiand
Registered: Feb, 2002

Re: JINI client connection Posted: Mar 25, 2002 10:47 PM
Reply to this message Reply
Problem solved!

The problem was the /etc/hosts file on the javaspace machine, which looked something like this:

127.0.0.1 javaspace localhost

and made rmid translate the javaspace name to 127.0.0.1, which led to the client's attempt to connect to its localhost, where no services where runnning.It seems other programs have this problem also.

My new (correct) /etc/hosts file is:

127.0.0.1 localhost
realIP javaspace

where realIP is the real IP of the javaspace machine.

Steve Dodge

Posts: 1
Nickname: atreides
Registered: Jun, 2002

Re: JINI client connection Posted: Jun 23, 2002 2:26 PM
Reply to this message Reply
Cristi,

Thanks for following up on you own post. This information helped me fix the exact same error but in the context of simple java RMI communication.

My remote machine's name is jack so I had this in /etc/hosts
127.0.0.1   localhost jack

changed it to
127.0.0.1   localhost
xxx.x.x.xxx  jack


RMI is fine now.

I'm operating on a rogue network which I did the network configuration. Just goes to show its easy to miss little things like my hosts file.


Thanks!

Brian

Posts: 1
Nickname: zerosleep
Registered: Aug, 2002

Re: JINI client connection Posted: Aug 9, 2002 12:32 PM
Reply to this message Reply
Yup, this fixed my problem too. Thanks Cristi.

I didn't have this problem until I moved my server behind a firewall/router. Guess it pays to pay attention or re-write to your hosts file in linux.

Andrew

Posts: 1
Nickname: ee7arh
Registered: Sep, 2002

Re: JINI client connection Posted: Sep 3, 2002 7:43 AM
Reply to this message Reply
Thanks from me too. Lufthansa and BMI's booking engine owes you one, our new servers were configured incorrectly and this was driving us up the wall.

Ta

Nicolas Carranza

Posts: 1
Nickname: nicarran
Registered: Sep, 2002

Re: JINI client connection Posted: Sep 24, 2002 3:29 AM
Reply to this message Reply
Gracias mano!

Zhu Xiaoming

Posts: 1
Nickname: ricky
Registered: Dec, 2002

Re: JINI client connection Posted: Dec 10, 2002 1:16 AM
Reply to this message Reply
Thanks, Cristi.

ug

Posts: 3
Nickname: uuy
Registered: Mar, 2004

Re: JINI client connection Posted: Mar 31, 2004 12:57 AM
Reply to this message Reply
I 'm learning jini ... i tried the first HellWorldServer and HelloWorldClient program...

console 1 :
rmid -J-Dsun.rmi.activation.execPolicy=none

console 2:
java -jar \files\jini1_2_1\lib\tools.jar -port 8080 -
dir \files\jini1_2_1\lib -verbose
and the output was
reggie-dl.jar requested from 127.0.0.1:1660

console 3:
java -jar \files\jini1_2_1\lib\tools.jar -port 8085 -
dir \files\serv -verbose
output was :
corejini/chapter5/HelloWorldServiceProxy.class requested from 127.0.0.1:1362
corejini/chapter5/HelloWorldServiceProxy.class not found

console 4:
java -cp \files\jini1_2_1\lib\jini-core.jar;\files\ji
ni1_2_1\lib\jini-ext.jar;\files\ji ni1_2_1\sun-util.jar;\files\service -Djava.rmi
.server.codebase=http://localhost:8085/ -Djava.security.policy=\files\policy co
rejini.chapter5.HelloWorldService
output was :
discovered a lookup service!
Set serviceID to 6201567a-d1b1-4602-bd63-c56d980cdc7a

i get the following error when i run the jini client..
console 5:
java -cp \files\jini1_2_1\lib\jini-core.jar;\files\ji
ni1_2_1\lib\jini-ext.jar;\files\ji ni1_2_1\lib\sun-util.jar;\files\client -Djava.
security.policy=\files\policy corejini.chapter5.HelloWorldClient
Error doing lookup: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: corejini.chapter5.HelloWorldServiceProxy

can anyone suggest a solution to this problem.

ug

Posts: 3
Nickname: uuy
Registered: Mar, 2004

Re: JINI client connection Posted: Mar 31, 2004 1:08 AM
Reply to this message Reply
I 'm learning jini ... i tried the first HellWorldServer and HelloWorldClient program...

console 1 :
rmid -J-Dsun.rmi.activation.execPolicy=none

console 2:
java -jar \files\jini1_2_1\lib\tools.jar -port 8080 -
dir \files\jini1_2_1\lib -verbose
and the output was
reggie-dl.jar requested from 127.0.0.1:1660

console 3:
java -Djava.security.policy=/files/jini1_2_1/example/
lookup/policy -jar /files/jini1_2_1/lib/reggie.jar http://localhost:8080/reggie-
dl.jar /files/jini1_2_1/example/lookup/policy /tmp/reggie_log public
outout was:
using absolute policy path: E:\files\jini1_2_1\example\lookup\policy
using absolute logdir path: E:\tmp\reggie_log


console 4:
java -jar \files\jini1_2_1\lib\tools.jar -port 8085 -
dir \files\serv -verbose
output was :
corejini/chapter5/HelloWorldServiceProxy.class requested from 127.0.0.1:1362
corejini/chapter5/HelloWorldServiceProxy.class not found

console 5:
java -cp \files\jini1_2_1\lib\jini-core.jar;\files\ji
ni1_2_1\lib\jini-ext.jar;\files\ji ni1_2_1\sun-util.jar;\files\service -Djava.rmi
.server.codebase=http://localhost:8085/ -Djava.security.policy=\files\policy co
rejini.chapter5.HelloWorldService
output was :
discovered a lookup service!
Set serviceID to 6201567a-d1b1-4602-bd63-c56d980cdc7a

i get the following error when i run the jini client..
console 6:
java -cp \files\jini1_2_1\lib\jini-core.jar;\files\ji
ni1_2_1\lib\jini-ext.jar;\files\ji ni1_2_1\lib\sun-util.jar;\files\client -Djava.
security.policy=\files\policy corejini.chapter5.HelloWorldClient
Error doing lookup: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: corejini.chapter5.HelloWorldServiceProxy

can anyone suggest a solution to this problem.

Flat View: This topic has 10 replies on 1 page
Topic: Reggie problem-URGENT Previous Topic   Next Topic Topic: Jini and RMI-backend

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use