Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > RMI activatable objects error

Reply
Thread Tools

RMI activatable objects error

 
 
Josh Newman
Guest
Posts: n/a
 
      06-16-2004
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(exampleG roup);

// 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("jav a.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.getInstantiat or(Activation.java:
1244)
at sun.rmi.server.Activation$GroupEntry.activate(Acti vation.java:1126)
at sun.rmi.server.Activation$ActivatorImpl.activate(A ctivation.java:262)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastSe rverRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:1 4
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$ConnectionHandl er.run(TCPTransport
..java:701)
at java.lang.Thread.run(Thread.java:534)
at sun.rmi.transport.StreamRemoteCall.exceptionReceiv edFromServer(Unknow
n Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unk nown
Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at sun.rmi.server.Activation$ActivatorImpl_Stub.activ ate(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.getInstantiat or(Activation.java:
121
at sun.rmi.server.Activation$GroupEntry.activate(Acti vation.java:1126)
at sun.rmi.server.Activation$ActivatorImpl.activate(A ctivation.java:262)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastSe rverRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:1 4
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$ConnectionHandl er.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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
class objects, method objects, function objects 7stud Python 11 03-20-2007 06:05 PM
Why does java.rmi.Naming not implement interface java.rmi.Registry? Jan Schulze Java 1 03-26-2005 07:45 AM
RMI Vs RMI over IIOP JScoobyCed Java 1 01-28-2005 09:54 AM
RMI, JINI or RMI/IIOP Buu Nguyen Java 1 08-25-2004 11:28 AM
RMI activatable objects error Josh Newman Java 0 06-16-2004 06:51 PM



Advertisments