RMI activatable objects error

J

Josh Newman

Hi,
I'm having a problem with a RMI test program that I'm trying to
run. I've started the rmiregistry using simply, "rmiregistry". I've
started the rmi daemon using -

rmid -J-Djava.security.policy=E:/projects/RMI_Activatable_Objects/policy

where the "policy" file contains the following -

grant {
// Allow everything for now
permission java.security.AllPermission;
};


I then run a setup program that contains the following code -

// This class registers information about the
ActivatableImplementation
// class with rmid and the rmiregistry
//
public static void main(String[] args) throws Exception {

System.setSecurityManager(new RMISecurityManager());

// Because of the 1.2 security model, a security policy should
// be specified for the ActivationGroup VM. The first argument
// to the Properties put method, inherited from Hashtable, is
// the key and the second is the value

//The security policy file location
Properties props = new Properties();
props.put("java.security.policy",
"E:/projects/RMI_Activatable_Objects/policy");

ActivationGroupDesc.CommandEnvironment ace = null;
ActivationGroupDesc exampleGroup = new
ActivationGroupDesc(props, ace);

// Once the ActivationGroupDesc has been created, register it
// with the activation system to obtain its ID
//
ActivationGroupID agi =
ActivationGroup.getSystem().registerGroup(exampleGroup);

// The "location" String specifies a URL from where the class
// definition will come when this object is requested (activated).
// Don't forget the trailing slash at the end of the URL
// or your classes won't be found.
//
String location = "file:E:/projects/RMI_Activatable_Objects/";

// Create the rest of the parameters that will be passed to
// the ActivationDesc constructor
//
MarshalledObject data = null;

// The location argument to the ActivationDesc constructor
will be used
// to uniquely identify this class; it's location is relative
to the
// URL-formatted String, location.
//
ActivationDesc desc = new ActivationDesc
(agi, "examples.activation.ActivatableImplementation",
location, data);

// Register with rmid
//
MyRemoteInterface mri =
(MyRemoteInterface)Activatable.register(desc);
System.out.println("Got the stub for the ActivatableImplementation");

// Bind the stub to a name in the registry running on 1099
//
Naming.rebind("ActivatableImplementation", mri);
System.out.println("Exported ActivatableImplementation");

System.exit(0);
}

where "ActivatableImplementation" is the name of the remote
object, and "RemoteInterface" is the name of the remote interface it
implements that can be seen by the client.

To run this program I use -

java -Djava.security.policy=E:/projects/RMI_Activatable_Objects/policy
-Djava.rmi.server.codebase=file:E:/projects/RMI_Activatable_Objects/
examples.activation.Setup

where "Setup" is the name of the above class, the first -D
parameter is the location of the same policy file used to start the
RMI daemon, and the second -D parameter is the location of my class
files, including the stubs for "ActivatableImplementation".

I then attempt to run the Client program (remember that this is
all on the same box) using -

java -Djava.security.policy=E:/projects/RMI_Activatable_Objects/policy
examples.activation.Client sfs26

where "sfs26" is the name of my machine, the file path is the path to
that same policy file again and "Client" contains the following code -


public static void main(String args[]) {

String server = "localhost";
if (args.length < 1) {
System.out.println ("Usage: java Client <rmihost>");
System.exit(1);
} else {
server = args[0];
}

// Set a security manager so that the client can
// download the activatable object's stub
//
System.setSecurityManager(new RMISecurityManager());

try {

String location = "rmi://" + server +
"/ActivatableImplementation";

// Since you can't create an instance of an interface, what we
get
// back from the lookup method is a remote reference to an object
// that implements MyRemoteInterface.
//
// Then we cast the remote reference (serialized stub instance)
// returned from Naming.lookup to a "MyRemoteInterface" so we can
// call the interface method(s).
//
MyRemoteInterface mri =
(MyRemoteInterface)Naming.lookup(location);
System.out.println("Got a remote reference to the object that" +
" extends Activatable.");

// The String "result" will be changed to "Success" by the remote
// method call
//
String result = "failure";
System.out.println("Making remote call to the server");
System.out.println(System.getProperties().get("java.home"));

result = (String)mri.callMeRemotely();
System.out.println("Returned from remote call");
System.out.println("Result: " + result);

All this remote object does is return a string, as you can see above.
When I try and run this I get the following error -





Got a remote reference to the object that extends Activatable.
Making remote call to the server
D:\Program Files\Java\j2re1.4.2_04
java.rmi.activation.ActivateFailedException: failed to activate
object; nested e
xception is:
java.rmi.activation.ActivationException: unable to create
activation gro
up; nested exception is:
java.io.IOException: CreateProcess:
d:\j2sdk1.4.2_04\jre\bin\java -Djava
..security.policy=E:/projects/RMI_Activatable_Objects/policy
sun.rmi.server.Activ
ationGroupInit error=193
at sun.rmi.server.ActivatableRef.activate(Unknown Source)
at sun.rmi.server.ActivatableRef.invoke(Unknown Source)
at examples.activation.ActivatableImplementation_Stub.callMeRemotely(Unk
nown Source)
at examples.activation.Client.main(Client.java:82)
Caused by: java.rmi.activation.ActivationException: unable to create
activation
group; nested exception is:
java.io.IOException: CreateProcess:
d:\j2sdk1.4.2_04\jre\bin\java -Djava
..security.policy=E:/projects/RMI_Activatable_Objects/policy
sun.rmi.server.Activ
ationGroupInit error=193
at sun.rmi.server.Activation$GroupEntry.getInstantiator(Activation.java:
1244)
at sun.rmi.server.Activation$GroupEntry.activate(Activation.java:1126)
at sun.rmi.server.Activation$ActivatorImpl.activate(Activation.java:262)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
60)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
..java:701)
at java.lang.Thread.run(Thread.java:534)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknow
n Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown
Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at sun.rmi.server.Activation$ActivatorImpl_Stub.activate(Unknown
Source)

at java.rmi.activation.ActivationID.activate(Unknown Source)
... 4 more
Caused by: java.io.IOException: CreateProcess:
d:\j2sdk1.4.2_04\jre\bin\java -Dj
ava.security.policy=E:/projects/RMI_Activatable_Objects/policy
sun.rmi.server.Ac
tivationGroupInit error=193
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Win32Process.java:66)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:566)
at java.lang.Runtime.exec(Runtime.java:491)
at java.lang.Runtime.exec(Runtime.java:457)
at sun.rmi.server.Activation$GroupEntry.getInstantiator(Activation.java:
1218)
at sun.rmi.server.Activation$GroupEntry.activate(Activation.java:1126)
at sun.rmi.server.Activation$ActivatorImpl.activate(Activation.java:262)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
60)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
..java:701)
at java.lang.Thread.run(Thread.java:534)





So it falls over at the point where the remote call is made. The

"Caused by: java.io.IOException: CreateProcess:
d:\j2sdk1.4.2_04\jre\bin\java
-Djava.security.policy=E:/projects/RMI_Activatable_Objects/policy
sun.rmi.server.ActivationGroupInit error=193"

towards the bottom of the stack is the original cause and is the same
error you get if you try and run a process using Runtime.getExec(
"command" ), and "command" is of a syntax the JVM doesn't like. We
tried calling

"d:\j2sdk1.4.2_04\jre\bin\java
-Djava.security.policy=E:/projects/RMI_Activatable_Objects/policy
HelloWorld"

using Runtime.getExec and did indeed get this error. If we replaced
"...bin\java" with "...bin\java.exe" it worked. Can the rmi daemon be
changed to use "java.exe", or are we barking up the wrong tree and
doing something else completely wrong? Any help would be much
appreciated, as I had this working a few days ago and can't understand
why it's now giving me errors!



Many Thanks



Josh Newman
 

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,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top