RMI on HP-UX - application closes after bind

K

Krystian

Hi,

I've got a simple test application of RMI. It's a copy of PerfectTime
application from Thinking in Enterprise Java by Bruce Eckel. I've used
it to test RMI on windows.
Now i've copied it to HP-UX. When i run it, everything seems to be ok,
accept the fact, that after the bind to RMI, applications simply
closes.
On windows it waits for new connections.
I will paste only the last few lines from the main class:

PerfectTime pt = new PerfectTime();
Naming.bind("//localhost/PerfectTime", pt);
System.out.println("Ready to do time");
}
} ///:~

Is there something missing?

Please, help ;)

Best regards,
Krystian
 
T

Tris Orendorff

Hi,

I've got a simple test application of RMI. It's a copy of PerfectTime
application from Thinking in Enterprise Java by Bruce Eckel. I've used
it to test RMI on windows.
Now i've copied it to HP-UX. When i run it, everything seems to be ok,
accept the fact, that after the bind to RMI, applications simply
closes.
On windows it waits for new connections.
I will paste only the last few lines from the main class:

PerfectTime pt = new PerfectTime();
Naming.bind("//localhost/PerfectTime", pt);
System.out.println("Ready to do time");
}
} ///:~

Is there something missing?

Yes! Show us the exception message.just before it closes.

--
Tris Orendorff
[Q: What kind of modem did Jimi Hendrix use?
A: A purple Hayes.]


`
 
K

Krystian

Tris Orendorff napisal(a):
Hi,

I've got a simple test application of RMI. It's a copy of PerfectTime
application from Thinking in Enterprise Java by Bruce Eckel. I've used
it to test RMI on windows.
Now i've copied it to HP-UX. When i run it, everything seems to be ok,
accept the fact, that after the bind to RMI, applications simply
closes.
On windows it waits for new connections.
I will paste only the last few lines from the main class:

PerfectTime pt = new PerfectTime();
Naming.bind("//localhost/PerfectTime", pt);
System.out.println("Ready to do time");
}
} ///:~

Is there something missing?

Yes! Show us the exception message.just before it closes.

--
Tris Orendorff
[Q: What kind of modem did Jimi Hendrix use?
A: A purple Hayes.]


`

There is no exception, no error.
It just closes!
Rmiregistry still has the bind, because when i do Naming.list i get my
entry /but the application is already closed/.

I just don't know why it closes itself after the bind :/
 
K

Krystian

Krystian napisal(a):
Tris Orendorff napisal(a):
Hi,

I've got a simple test application of RMI. It's a copy of PerfectTime
application from Thinking in Enterprise Java by Bruce Eckel. I've used
it to test RMI on windows.
Now i've copied it to HP-UX. When i run it, everything seems to be ok,
accept the fact, that after the bind to RMI, applications simply
closes.
On windows it waits for new connections.
I will paste only the last few lines from the main class:

PerfectTime pt = new PerfectTime();
Naming.bind("//localhost/PerfectTime", pt);
System.out.println("Ready to do time");
}
} ///:~

Is there something missing?

Yes! Show us the exception message.just before it closes.

--
Tris Orendorff
[Q: What kind of modem did Jimi Hendrix use?
A: A purple Hayes.]


`

There is no exception, no error.
It just closes!
Rmiregistry still has the bind, because when i do Naming.list i get my
entry /but the application is already closed/.

I just don't know why it closes itself after the bind :/
From what i have read it might be.. normal.
But my client can't connect to the rmiregistry!
I get:
Exception in thread "main" java.rmi.ConnectException: Connection
refused to host
: 10.13.221.43; nested exception is:
java.net.ConnectException: Connection timed out

But then i check Naming.list i get a list of binds /one exactly/.

What's wrong here?
How come i can check binds but can't connect with client?

My policy:
grant { permission java.security.AllPermission; };

Please, help me with this, it's urgent for me :/
 
N

Nigel Wade

Krystian said:
Tris Orendorff napisal(a):
Hi,

I've got a simple test application of RMI. It's a copy of PerfectTime
application from Thinking in Enterprise Java by Bruce Eckel. I've used
it to test RMI on windows.
Now i've copied it to HP-UX. When i run it, everything seems to be ok,
accept the fact, that after the bind to RMI, applications simply
closes.
On windows it waits for new connections.
I will paste only the last few lines from the main class:

PerfectTime pt = new PerfectTime();
Naming.bind("//localhost/PerfectTime", pt);
System.out.println("Ready to do time");
}
} ///:~

Is there something missing?

Yes! Show us the exception message.just before it closes.

--
Tris Orendorff
[Q: What kind of modem did Jimi Hendrix use?
A: A purple Hayes.]


`

There is no exception, no error.
It just closes!

Your application will exit if there is an exception which isn't caught, or your
code naturally exits. You need to determine which one is happening here.
Rmiregistry still has the bind, because when i do Naming.list i get my
entry /but the application is already closed/.

I just don't know why it closes itself after the bind :/

You have most likely caught the exception and ignored it. Without any code to
examine it's not possible to do anything other than speculate.
 
K

Krystian

Nigel Wade napisal(a):
Krystian said:
Tris Orendorff napisal(a):
"Krystian" <[email protected]> burped up warm pablum in

Hi,

I've got a simple test application of RMI. It's a copy of PerfectTime
application from Thinking in Enterprise Java by Bruce Eckel. I've used
it to test RMI on windows.
Now i've copied it to HP-UX. When i run it, everything seems to be ok,
accept the fact, that after the bind to RMI, applications simply
closes.
On windows it waits for new connections.
I will paste only the last few lines from the main class:

PerfectTime pt = new PerfectTime();
Naming.bind("//localhost/PerfectTime", pt);
System.out.println("Ready to do time");
}
} ///:~

Is there something missing?

Yes! Show us the exception message.just before it closes.

--
Tris Orendorff
[Q: What kind of modem did Jimi Hendrix use?
A: A purple Hayes.]


`

There is no exception, no error.
It just closes!

Your application will exit if there is an exception which isn't caught, or your
code naturally exits. You need to determine which one is happening here.
Rmiregistry still has the bind, because when i do Naming.list i get my
entry /but the application is already closed/.

I just don't know why it closes itself after the bind :/

You have most likely caught the exception and ignored it. Without any code to
examine it's not possible to do anything other than speculate.

I will paste the whole code. It's mostly taken from Chapter 15 of
"Thinking in Enterprise Java" by Bruce Eckel which is available for
free on: http://www.mindview.net/Books
I hope he won't mind.

Here's the interface for rmi:
PerfectTimeI.java:

package c15.rmi;

import java.rmi.*;
public interface PerfectTimeI extends Remote {
long getPerfectTime() throws RemoteException;
}


Server code:
PerfectTime.java:
package c15.rmi;
import java.rmi.*;
import java.rmi.server.*;

public class PerfectTime
extends UnicastRemoteObject
implements PerfectTimeI {
/**
*
*/
private static final long serialVersionUID = 5081148916046413493L;
// Implementation of the interface:
public long getPerfectTime()
throws RemoteException {
return System.currentTimeMillis();
}
// Must implement constructor
// to throw RemoteException:
public PerfectTime() throws RemoteException {
// super(); // Called automatically
}
// Registration for RMI serving. Throw
// exceptions out to the console.
public static void main(String[] args)
throws Exception {
System.setSecurityManager(
new RMISecurityManager());
PerfectTime pt = new PerfectTime();
Naming.rebind(args[0], pt);
System.out.println("Ready to do time");
}
}


Client code:
package c15.rmi;
import java.rmi.*;

public class DisplayPerfectTime {
public static void main(String[] args)
throws Exception {
System.setSecurityManager(
new RMISecurityManager());
PerfectTimeI t =
(PerfectTimeI)Naming.lookup(
args[0]);
for(int i = 0; i < 10; i++)
System.out.println("//localhost/Perfect time = " +
t.getPerfectTime());
}
}

policy:
moje.policy:
grant { permission java.security.AllPermission; };


How i do it:
rmiregistry &
java -Djava.security.policy=moje.policy -Djava.rmi.server.codebase=file:/app/user/szckcenz/java/c15.rmi.jar -cp ./c15.rmi.jar c15.rmi.PerfectTime //localhost/PT
java -Djava.security.policy=moje.policy -cp /app/user/szckcenz/java/c15.rmi.jar c15.rmi.DisplayPerfectTime //localhost/PT

When i start the server, it binds to the rmiregistry and exits /without
any error or exception - as You can see i don't catch any/
When i start the client i get:

Exception in thread "main" java.rmi.ConnectException: Connection
refused to host
: 10.13.221.43; nested exception is:

java.net.ConnectException: Connection timed out

at
sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:567)
at
sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185
)


file moje.policy is in the directory from which i run app. Without
specifying it, it even won't start the server.
On windows it works just fine :/

Best regards,
Krystian
 
K

Krystian

Nigel Wade napisal(a):


Krystian wrote:
Tris Orendorff napisal(a):
"Krystian" <[email protected]> burped up warm pablum in

Hi,
I've got a simple test application of RMI. It's a copy of PerfectTime
application from Thinking in Enterprise Java by Bruce Eckel. I've used
it to test RMI on windows.
Now i've copied it to HP-UX. When i run it, everything seems to be ok,
accept the fact, that after the bind to RMI, applications simply
closes.
On windows it waits for new connections.
I will paste only the last few lines from the main class:
PerfectTime pt = new PerfectTime();
Naming.bind("//localhost/PerfectTime", pt);
System.out.println("Ready to do time");
}
} ///:~
Is there something missing?
Yes! Show us the exception message.just before it closes.
--
Tris Orendorff
[Q: What kind of modem did Jimi Hendrix use?
A: A purple Hayes.]
`
There is no exception, no error.
It just closes!
Your application will exit if there is an exception which isn't caught, or your
code naturally exits. You need to determine which one is happening here.
You have most likely caught the exception and ignored it. Without any code to
examine it's not possible to do anything other than speculate.I will paste the whole code. It's mostly taken from Chapter 15 of
"Thinking in Enterprise Java" by Bruce Eckel which is available for
free on:http://www.mindview.net/Books
I hope he won't mind.

Here's the interface for rmi:
PerfectTimeI.java:

package c15.rmi;

import java.rmi.*;
public interface PerfectTimeI extends Remote {
long getPerfectTime() throws RemoteException;

}Server code:
PerfectTime.java:
package c15.rmi;
import java.rmi.*;
import java.rmi.server.*;

public class PerfectTime
extends UnicastRemoteObject
implements PerfectTimeI {
/**
*
*/
private static final long serialVersionUID = 5081148916046413493L;
// Implementation of the interface:
public long getPerfectTime()
throws RemoteException {
return System.currentTimeMillis();
}
// Must implement constructor
// to throw RemoteException:
public PerfectTime() throws RemoteException {
// super(); // Called automatically
}
// Registration for RMI serving. Throw
// exceptions out to the console.
public static void main(String[] args)
throws Exception {
System.setSecurityManager(
new RMISecurityManager());
PerfectTime pt = new PerfectTime();
Naming.rebind(args[0], pt);
System.out.println("Ready to do time");
}

}Client code:
package c15.rmi;
import java.rmi.*;

public class DisplayPerfectTime {
public static void main(String[] args)
throws Exception {
System.setSecurityManager(
new RMISecurityManager());
PerfectTimeI t =
(PerfectTimeI)Naming.lookup(
args[0]);
for(int i = 0; i < 10; i++)
System.out.println("//localhost/Perfect time = " +
t.getPerfectTime());
}

}policy:
moje.policy:
grant { permission java.security.AllPermission; };

How i do it:
rmiregistry &
java -Djava.security.policy=moje.policy -Djava.rmi.server.codebase=file:/app/user/szckcenz/java/c15.rmi.jar -cp ./c15.rmi.jar c15.rmi.PerfectTime //localhost/PT
java -Djava.security.policy=moje.policy -cp /app/user/szckcenz/java/c15.rmi.jar c15.rmi.DisplayPerfectTime //localhost/PTWhen i start the server, it binds to the rmiregistry and exits /without
any error or exception - as You can see i don't catch any/
When i start the client i get:

Exception in thread "main" java.rmi.ConnectException: Connection
refused to host
: 10.13.221.43; nested exception is:

java.net.ConnectException: Connection timed out

at
sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:567)
at
sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185
)

file moje.policy is in the directory from which i run app. Without
specifying it, it even won't start the server.
On windows it works just fine :/

Best regards,
Krystian


Thanks to ejp from sun developper forums i finally got it to work.

All i needed was to set up the java.rmi.server.hostname to my local ip.

Best regards,
Krystian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top