Avatar billede ramic Nybegynder
22. april 2003 - 21:11 Der er 5 kommentarer

RMI on Apache web server

Hello SUN Forum

I have a question regarding RMI. I have created a small chatprogram "applet" which runs on an Apache web server. In order to test this program i have modified the java.policy to receave all incoming requests "java.security.AllPermission".

This is a sample of the servercode:
//create registry on port 5050
Registry registry = LocateRegistry.createRegistry(5050);
registry.rebind("ChatServerImpl", chatServer);

This is a sample of the client code:
//lookup the server's remote object
chatServer = (ChatServer)
Naming.lookup ("rmi://localhost:5050/ChatServerImpl");

Now!! The above code runs fine. The problem is when a change the host "localhost" to run on my own registred domain, and deploy it on my own apache webserver I get the following error:

java.rmi.ConnectException: Connection refused to host: 80.62.99.224; nested exception is:
java.net.ConnectException: Connection refused: connect
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Unknown Source)
at dk.chatrmi.ChatImpl.registerChatter(ChatImpl.java:82)
at dk.chatrmi.ChatImpl.init(ChatImpl.java:67)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

The web server actually starts the applet, but when the client "lookup" is performed it throws the above mentioned exception.

Could it maybe have anything to do with the fact, that I have not informed the server which host to bind the service to? All I have done which the server is to create a registry on port 5050. This works fine on "localhost", but might in fact cause problems on other hosts. What do you think?

Please help a frustrated developer

regards

Ralph
Avatar billede arne_v Ekspert
22. april 2003 - 21:21 #1
The web-server only send the applet class-file to the browser.

It does not run it.

And is rather irrelevant for the problem.
Avatar billede arne_v Ekspert
22. april 2003 - 21:23 #2
The error says that the client can not connect to the server.

Two best explanations is:

1)  the server is rnot running

2)  there are a firewall that is blocking the relevant ports
Avatar billede ramic Nybegynder
22. april 2003 - 21:30 #3
Thanks for your reply..

The server is running, and in fact the client browser starts the applet, but when the RMI service lookup is performed, the exception as mentioned is thrown. Very strange...
If I run it on localhost, I do not have any problems!!
Avatar billede arne_v Ekspert
22. april 2003 - 21:36 #4
The applet is served by the web-server, so if the applet
is arriving at the browser then teh web-server is running.

But that does not guarantee that the RMI server application
is running.

And the web-server is running on port 80 which is commonly open
through firewalls.

The TMI registry is using port 5050 which is sually
closed in firewalls.
Avatar billede ramic Nybegynder
22. april 2003 - 22:55 #5
That's correct. How ever if I change the host to localhost still running on port 5050 it works fine, of course only if I run everything on the same mashine "both server and client". This is used only for testing...
I have zonealarm running as a firewall, but I don't think this should cause any problems.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester