Has anybody successfully gotten RMI to work with Jrun on Solaris 2.5? I've been
spending the last day and a half trying to get this working to no avail - though
it did work on Apache Jserv on linux with no problem.
Here's the setup:
JDK for Solaris 1.1.7
Jrun 2.31
NES 3.62
I start up rmiregistry, and then start up my server program with:
java -Djava.rmi.server.codebase=/path/to/server/classes server.Server
Server.class basically just has a remote method implementation of a method which
just takes a String and then println's it to System.out.
Then, I have a Sender.class servlet which takes a String, and then instantiates
the remote server, and then call's the remote method. If run my Sender class
from the command line,
java Sender "text string"
[argv[0] is the string that is passed to my remote method]
it works fine, the text string shows up on the Server. However, when I try to
do it in Jrun's JVM, IE, post a request to the Sender servlet, here's the
stacktrace:
Sender exception:security.checkConnect: To my.server.ip.number:1099
java.rmi.RMISecurityException: security.checkConnect: To
my.server.ip.number:1099
at java.lang.Throwable.(Compiled Code)
at java.lang.Exception.(Compiled Code)
at java.lang.RuntimeException.(Compiled Code)
at java.lang.SecurityException.(Compiled Code)
at java.rmi.RMISecurityException.(Compiled Code)
at java.rmi.RMISecurityManager.checkConnect(Compiled Code)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Compiled Code)
at sun.rmi.transport.ConnectionInputStream.done(Compiled Code)
at sun.rmi.transport.StreamRemoteCall.releaseInputStream(Compiled Code)
at sun.rmi.transport.StreamRemoteCall.done(Compiled Code)
at sun.rmi.server.UnicastRef.done(Compiled Code)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Compiled Code)
at java.rmi.Naming.lookup(Compiled Code)
at Sender.doGet(Compiled Code)
at Sender.doPost(Compiled Code)
at javax.servlet.http.HttpServlet.service(Compiled Code)
at javax.servlet.http.HttpServlet.service(Compiled Code)
at com.livesoftware.jrun.JRun.runServlet(Compiled Code)
at com.livesoftware.jrun.JRunGeneric.handleConnection(Compiled Code)
at com.livesoftware.jrun.JRunGeneric.handleProxyConnection(Compiled
Code)
at
com.livesoftware.jrun.service.proxy.JRunProxyServiceHandler.handleRequest(Compil
ed Code)
at com.livesoftware.jrun.service.ThreadConfigHandler.run(Compiled Code)
Like I said, I've been able to get this to work on Apache 1.3.6 + Jserv no
problem. Also, the stub classes are in Jrun's JVM's classpath. I've also tried
passing the "-Djava.security.policy=java.policy" argument to the Jrun JVM, which
didn't affect anything. the java.policy file looked like:
grant {
permission java.net.SocketPermission "*:1024-65535",
"connect,accept";
permission java.net.SocketPermission "*:80", "connect";
};
I figure it must be something within how Jrun sets up the JVM, because the
Server.class file being bound in the rmiregistry and running doesn't make a
difference; I still get the above stacktrace.
Here's my Java files:
MessageReceiver.java: --------------------------
package msg;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface MessageReceiver extends Remote {
boolean takeMessage(String s) throws RemoteException;
}
server/Server.java: ------------------------------
package server;
import java.rmi.*;
import java.rmi.server.*;
import msg.*;
public class Server extends UnicastRemoteObject implements MessageReceiver {
public Server() throws RemoteException {
super();
}
public boolean takeMessage(String m) throws RemoteException {
System.out.println(m);
return true;
}
public static void main (String[] args) {
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
String name = "test";
try {
MessageReceiver server = new Server();
Naming.rebind(name, server);
System.out.println("Server bound");
} catch (Exception e) {
System.err.println("Server exception: " + e.getMessage());
e.printStackTrace();
}
}
}
Sender.java: ---------------------------------------------------
mport java.rmi.*;
import msg.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Sender extends HttpServlet {
private static String remote = "test";
public void doPost (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
doGet(req, res);
}
public void doGet (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
String msg = req.getParameter("msg");
if (System.getSecurityManager() == null) {
System.setSecurityManager( new RMISecurityManager() );
}
if(msg != null && msg.length() > 0) {
out.println("sending <b>" + msg + "</b>");
try {
MessageReceiver server = (MessageReceiver)
Naming.lookup(remote);
server.takeMessage(msg);
} catch (Exception e) {
out.println("<pre>");
out.println("Sender exception:" + e.getMessage());
e.printStackTrace(out);
out.println("</pre>");
}
} else {
out.println("msg is null");
}
out.println("<hr>");
out.println("<form action='" + req.getServletPath() + "' method=post>");
out.println("<input type='text' name='msg'>");
out.println("<input type='submit' value='Submit!'>");
out.println("</form>");
out.close();
}
public static void main (String[] args) {
if (System.getSecurityManager() == null) {
System.setSecurityManager( new RMISecurityManager() );
}
try {
MessageReceiver server = (MessageReceiver) Naming.lookup(remote);
for (int i = 0; i < args.length; i ++) {
server.takeMessage(args[i]);
}
} catch (Exception e) {
System.out.println("ACCCCCKKKKK");
System.out.println("Sender exception:" + e.getMessage());
e.printStackTrace();
}
}
}
If anybody could help me out, I'd be most appreciative.
Thanks,
Rich Yumul
-------------------------
Richard M. Yumul
mailto:[EMAIL PROTECTED]
DTAI Incorporated
http://www.dtai.com
(619)542-1700 � fax:(619)542-8675
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html