Hi,
Two points:
(1) You shouldn't exit main() ! One way is just to sleep
forever.
Another way is to wait for stdin after the rebind(),
something
like:
LineNumberReader in = new LineNumberReader( new
InputStreamReader( System.in
));
while( true ) {
try {
StreamTokenizer tokens = new
StreamTokenizer( new StringReader(
in.readLine()));
int tt = tokens.nextToken();
switch( tt ) {
case tokens.TT_EOF:
System.err.println( "TestRMI
running" );
break;
case tokens.TT_WORD:
// parse the tokens and do
something, like shutdown
......
break;
default:
System.err.println( "??" );
}
}
catch( IOException e ) {
}
}
(2) Dont set the security manager - you'll probably get all
sorts of access
exceptions.
RMISecurityManager lives at the client end (if I remember
correctly).
I think there must be an example in the rmi docs which shows
this
being used as you have, because I did the same thing once.
You
can get away with it in 1.1.x, but not 1.2, where security
is changed.
Nick.
Pratip Kar wrote:
> Hi,
>
> Thanks for your reply. This is the code snippet for my server.
>
> public class TestRMI extends UnicastRemoteObject implements ITestRMI
> {
> public static void main(String args[])
> {
> System.setSecurityManager(new RMISecurityManager() );
> try
> {
> TestRMI test = new TestRMI();
> Naming.rebind( "TestRMI", test );
> System.out.println( "TestRMI object bound to registry" );
> }
> catch(Exception e)
> {
> e.printStackTrace();
> }
> }
> }
>
> With that, when I run the server, I get the println() on the screen, and after
> that the server exits.
>
> % java -green -Djava.security.policy=./policy TestRMI
> TestRMI object bound to registry
> %
>
> Pratip
>
> Nick Lawson wrote:
>
> > Hi,
> >
> > Would it help to add some println()s to your rmi server
> > so you could see where it falls out ? Or does the jvm
> > exit from within the rebind() call ?
> >
> > Nick
> >
> > Pratip Kar wrote:
> >
> > > Hi,
> > >
> > > I am running a simple RMI test application. But after doing the
> > > "Naming.rebind(....)" the server simply comes out. There is no exception
> > > or anything. But instead of waiting for the Client connection, it exits
> > > normally after binding to rmiregistry.
> > >
> > > My system has RH6.0 with glibc2.1. I am not able to run the native
> > > thread executables, so I was trying with the green thread ones. Can that
> > > be a problem ?
> > >
> > > Pratip
> > >
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]