JAVA RMI register problem  
Author Message
Marzena





PostPosted: 2008-3-29 23:26:00 Top

java-programmer, JAVA RMI register problem Hi
Im making aplication with Java RMI ... everything was working till
yesterday. Today i started to run server and i cant make it :( (once
per 20 times it works)

The way i registering serwer is (im doing this from the folder where i
have my server class and java files + stub ):

start rmiregistry
java -Djava.security.policy=test.policy serwer

Sometimes it works ,sometimes not,espescially when i m starting to run
second diffrent process(serwer)
i got this error:


D:\workspace\serwer2>rmiregistry
java.rmi.server.ExportException: Port already in use: 1099; nested
exception is:

java.net.BindException: Address already in use: JVM_Bind
at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:
310)
at
sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:218
)
at
sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:393)
at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:129)
at
sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:19
0)
at sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:92)
at sun.rmi.registry.RegistryImpl.<init>(RegistryImpl.java:78)
at sun.rmi.registry.RegistryImpl.main(RegistryImpl.java:322)
Caused by: java.net.BindException: Address already in use: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
at java.net.ServerSocket.bind(ServerSocket.java:319)
at java.net.ServerSocket.<init>(ServerSocket.java:185)
at java.net.ServerSocket.<init>(ServerSocket.java:97)
at
sun.rmi.transport.proxy.RMIDirectSocketFactory.createServerSocket(RMI
DirectSocketFactory.java:27)
at
sun.rmi.transport.proxy.RMIMasterSocketFactory.createServerSocket(RMI
MasterSocketFactory.java:333)
at
sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(TCPEndpoint.java:64
9)
at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:
299)
... 7 more

D:\workspace\serwer2>java -Djava.security.policy=test2.policy server
Liczba aktywnych watkow: 1
nazwa watku: main
Usluga druga niezarejestrowana: RemoteException occurred in server
thread; neste
d exception is:
java.rmi.UnmarshalException: error unmarshalling arguments;
nested excep
tion is:
java.lang.ClassNotFoundException: server_Stub

I didnt change anything in my source code...nothing...it just started
doing like this. Lately i was able to run two server process...and
everything was ok.... i was looking for a tip in google...but nothing
help...anybody knows how to fix it?

Tnx .
 
Roedy Green





PostPosted: 2008-3-30 15:24:00 Top

java-programmer >> JAVA RMI register problem On Sat, 29 Mar 2008 08:25:44 -0700 (PDT), Marzena
<email***@***.com> wrote, quoted or indirectly quoted someone
who said :

>Port already in use: 1099

maybe some other app is also using that port. Seems to me there is a
way to configure a different RMI port, or see if you can see what
other app is using 1099 and move it.
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
EJP





PostPosted: 2008-3-31 8:32:00 Top

java-programmer >> JAVA RMI register problem Marzena wrote:
> D:\workspace\serwer2>rmiregistry
> java.rmi.server.ExportException: Port already in use: 1099; nested
> exception is:
>
> java.net.BindException: Address already in use: JVM_Bind

Most probably the registry is already running. netstat will tell you.
 
 
Marzena





PostPosted: 2008-4-2 1:29:00 Top

java-programmer >> JAVA RMI register problem No other app is using the same port as rmiregistry... i checked it...

i mean when i want to register one object its working

i run rmiregistry (start rmiregistry)
and run the serwer (java -Djava.security.policy=test.policy serwer)

then i open next command line and doing the same with second object
start rmiregistry
java -Djava.security.policy=test2.policy server

rmiregistry gave me the error that i pasted before
and mine second method (server) doesnt register :|

im confused cause it was working before ...and stopped...i didnt
change the code...
the code which i use in the app server & serwer is :

if (System.getSecurityManager() == null)
System.setSecurityManager(new RMISecurityManager());
try {
serwer obj = new serwer();
Naming.rebind("pomiar", obj);
System.out.println("Usluga zarejestrowana");

} catch (Exception e) {
System.out.println("Usluga niezarejestrowana: " +
e.getMessage());
}

I would be greatfull for any tip :(
 
 
EJP





PostPosted: 2008-4-2 8:32:00 Top

java-programmer >> JAVA RMI register problem Marzena wrote:
> No other app is using the same port as rmiregistry... i checked it...

On the contrary. *Something* is using it. When you get an error saying
'Port already in use: 1099', it means that port 1099 is already in use.

So how did you check it? Run netstat -an and you'll see that TCP port
1099 is already listening.

As I said before, I suspect you already have the RMI Registry running
and you are trying to start another one. In which case you don't really
have a problem, just ignore the error on the second one.
 
 
Marzena





PostPosted: 2008-4-5 0:50:00 Top

java-programmer >> JAVA RMI register problem Ok i fixed the problem... every server RMI need to be bound in rmi
registry running at diffrent port
it is working when i changed it... but i still dont know how did it
work before,when i was doing everything
in one rmiregistry port...anyway thanks for answer :-))
 
 
EJP





PostPosted: 2008-4-6 18:55:00 Top

java-programmer >> JAVA RMI register problem Marzena wrote:
> Ok i fixed the problem... every server RMI need to be bound in rmi
> registry running at diffrent port

Why? Why can't you have one RMI Registry for the entire application?

> it is working when i changed it... but i still dont know how did it
> work before,when i was doing everything
> in one rmiregistry port...anyway thanks for answer :-))

Why shouldn't that work?

Your problem seems to be that you want to start a new RMI Registry per
server. You don't have to do that. You only need one per server host.
 
 
Nigel Wade





PostPosted: 2008-4-7 16:34:00 Top

java-programmer >> JAVA RMI register problem Marzena wrote:

> Ok i fixed the problem... every server RMI need to be bound in rmi
> registry running at diffrent port

Hmm, no it doesn't. The only reason you would require more than one port is if
you have more than one RMI registry. Every RMI server needs to be bound to a
RMI registry, but that registry does not need a different port for each RMI
server. In fact that would defeat the entire purpose of the RMI registry.

The RMI registry is a "global" repository for multiple servers. The point is
that a client only has to make a request to one RMI registry for any particular
service. There really should be only one rmiregistry on each host, unless there
are exceptional circumstances.

--
Nigel Wade
 
 
Marzena





PostPosted: 2008-4-8 1:24:00 Top

java-programmer >> JAVA RMI register problem I thought the same... but look at my code. Im checking if there is any
rmiregistry if yes i wanna use it...but it doesnt work,i got exception
that smth is already using the port and i cant connect...it was
working before,right now no :( so i used 3 ports to every
application :/


if (System.getSecurityManager() == null)
System.setSecurityManager(
new java.rmi.RMISecurityManager());

java.rmi.registry.Registry reg = null;
try {
reg = java.rmi.registry.LocateRegistry.createRegistry(1099);
System.out.println("Utworzone nowe registry na porcie 1099.");
} catch (Exception e) {
System.out.println("Nie powiodlo sie utworzenie registry.");
System.out.println("Skorzystam z istniejacego.");
}
if (reg == null) {
try {
reg = java.rmi.registry.LocateRegistry.getRegistry();
System.out.println("Skorzystalam z zarejestrowanego registry");
} catch (Exception e) {
System.out.println("Nie moge skorzystac z istniejacego
registry.");
System.exit(0);
}
}
try {
serwer obj = new serwer();
reg.rebind("pomiar", obj);
System.out.println("Us硊ga zarejestrowana.");
}
catch (Exception e) {
e.printStackTrace();
}


 
 
EJP





PostPosted: 2008-4-8 7:00:00 Top

java-programmer >> JAVA RMI register problem Marzena wrote:
> System.out.println("Nie moge skorzystac z istniejacego registry.");

Are you saying that you always get this displayed?
 
 
Nigel Wade





PostPosted: 2008-4-8 17:41:00 Top

java-programmer >> JAVA RMI register problem Marzena wrote:

> I thought the same... but look at my code. Im checking if there is any
> rmiregistry if yes i wanna use it...

You attempt to create a registry first. That will always fail on the second and
subsequent attempts because there is already another registry running on that
port.

You should attempt locate a registry first, and if that fails because there is
none, then create one.

> but it doesnt work,i got exception
> that smth is already using the port and i cant connect...

Your error messages are not in English, so I've no idea what exception you are
actually throwing. You also catch the blanket Exception and don't ever report
what the actual Exception is, or the message it returns, so how can you say
that it reports that something is already using the port? That may be what
*you* are writing to System.out, but it may not bear any relation to the actual
situation. What you need to do is output the actual Exception message and see
what's really going on.

> it was
> working before,right now no :( so i used 3 ports to every
> application :/
>
>
> if (System.getSecurityManager() == null)
> System.setSecurityManager(
> new java.rmi.RMISecurityManager());
>
> java.rmi.registry.Registry reg = null;
> try {
> reg = java.rmi.registry.LocateRegistry.createRegistry(1099);
> System.out.println("Utworzone nowe registry na porcie 1099.");
> } catch (Exception e) {
> System.out.println("Nie powiodlo sie utworzenie registry.");
> System.out.println("Skorzystam z istniejacego.");
> }
> if (reg == null) {
> try {
> reg = java.rmi.registry.LocateRegistry.getRegistry();
> System.out.println("Skorzystalam z zarejestrowanego registry");
> } catch (Exception e) {
> System.out.println("Nie moge skorzystac z istniejacego
> registry.");
> System.exit(0);
> }
> }
> try {
> serwer obj = new serwer();
> reg.rebind("pomiar", obj);
> System.out.println("Us艂uga zarejestrowana.");
> }
> catch (Exception e) {
> e.printStackTrace();
> }

--
Nigel Wade