Thanks.
http://e-docs.bea.com/wls/docs61/notes/migrate.html#1071425
The following tips are for users migrating to WebLogic Server 6.1 who used RMI
in their previous version of WebLogic Server:
Re-run the WebLogic RMI compiler, weblogic.rmic, on any existing code to regenerate
the wrapper classes so they are compatible with WebLogic Server 6.1.
Use java.rmi.Remote to tag interfaces as remote. Do not use weblogic.rmi.Remote.
Use java.rmi.*Exception (e.g., import java.rmiRemoteException;). Do not use weblogic.rmi.*Exception.
Use JNDI instead of *.rmi.Naming.
Use weblogic.rmic to generate stubs and skeletons.
Use weblogic.rmi.server.UnicastRemoteObject.exportObject() to get a stub instance.
The RMI examples have not currently been updated to use java.rmi.* and JNDI. The
examples will be revised to reflect java.rmi.* and JNDI in a future release.
Thanks,
Daniel
-Don
I followed the indications that Roger Lee posted (Thanks!), but I still have
some problems with RMI and WL61.
- I'm trying to instantiate an object in an Applet that is registered in Weblogic.
It was registered using JNDI as sugested, and it worked fine (it doesn't throw
any exception). But when I try to get a reference to it in my Applet, I get the
following exception:
"javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory.
Root exception is java.lang.ClassNotFoundException: java.io.IOException: open
HTTP connection failed."
followed by some more AccessControlExceptions. Here is the code that I use to
try to get a remote reference in the Applet:
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, "t3://" + getCodeBase().getHost() + ':' + port);
Context ctx = new InitialContext(env);
Object o = ctx.lookup("HelloServer");
Hello hello = (Hello) o;
And here is the registration code used in the Server class:
HelloImpl obj = new HelloImpl();
Context ctx = new InitialContext(null);
ctx.bind("HelloServer", obj);
Am I doing something wrong ???
Some other quick doubts:
- The method that Roger Lee mentioned (java.rmi.server.UnicastRemoteObject.exportObject(obj))
is used for what? It's used as an alternative way for register an RemoteObject,
or I need to register in JNDI the stub returned by this method ??
- weblogic.rmic is totally useless if I'm not working with IIOP, is that right?
I'm asking it because I've got a little confused with all the posts about it
that I've found. I weren't able to generate any stubs nor skeletons with it. Only
an idl.
Thanks a lot for the incoming Help!!
RGB
I did the same example with Applet and RMI using JNDI, like you.
The message that appear to me was
java.lang.ClassCastException: weblogic.rmi.internal.StubInfo
at RmiApplet.init(RmiApplet.java:62)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.security.AccessControlException: access denied (java.lang.RuntimePermission
exitVM)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkExit(Unknown Source)
at java.lang.Runtime.exit(Unknown Source)
at java.lang.System.exit(Unknown Source)
at RmiApplet.init(RmiApplet.java:70)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
To solve this I create a java.policy with this lines:
grant {
permission java.security.AllPermission;
};
And chaged this file at workstation's plugin directory.
Fabio Tassinari