RMI classpath
Hello
I'm trying to start RMI application in a dynamic-classloading environment.
More precisely: Application load additional classes from non classpath libraries (which include remote interfaces, implementations and generated stubs) thrugh custom URLClassLoader. Then it attempts to bind one of loaded classes to RMI registry via Naming.bind()... But it doesn't work. It crashes with ClassNotFoundExcetpion, indicating that it can't find remote interface for binding class.
Is it any way to bind new classes to RMI at runtime?
Thank you
Alexander Godin
If I understand your problem correctly, I think what you need to do is set your -Djava.rmi.server.codebase property on the JVM which is doing the exporting.
Theres a good guide to this here:
http://java.sun.com/j2se/1.4.2/docs/guide/rmi/codebase.html
Similar Messages
-
Hi folks,
Using this tutorial;
http://java.sun.com/j2se/1.5.0/docs/guide/rmi/hello/hello-world.html
I was able to get the example working when I had all of my classes in the same directory as I ran it. E.g.
$pwd
/home/jmcparla/RMI2/server
$ ls
Hello.class Server.class
$rmiregistry 2000 &
$ java Server
Server ready
$ pwd
/home/jmcparla/RMI2/client
$ ls
Client.class Hello.class
$ java Client
response: Hello, world!So I decided to bundle the code into two Jars, Server.jar (containing Hello.class and Server.class) and Client.jar (Hello.class and Client.class). However this time when I went to start the Server;
$ pwd
/home/jmcparla/RMI2
$ ls
Server.jar bin client policy server src
$ rmiregistry 2000 &
[1] 2848
$ java -jar Server.jarI got these exceptions;
Server exception: java.rmi.ServerException: RemoteException occurred in server t
hread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
tion is:
java.lang.ClassNotFoundException: Hello
java.rmi.ServerException: RemoteException occurred in server thread; nested exce
ption is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
tion is:
java.lang.ClassNotFoundException: Hello
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:396
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:5
35)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTranspor
t.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908)
at java.lang.Thread.run(Thread.java:619)
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.registry.RegistryImpl_Stub.bind(Unknown Source)
at Server.main(Server.java:22)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested ex
ception is:
java.lang.ClassNotFoundException: Hello
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:386
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:5
35)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTranspor
t.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: Hello
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at sun.rmi.server.LoaderHandler.loadProxyInterfaces(LoaderHandler.java:7
11)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:655)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:592)
at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:6
28)
at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:294
at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStrea
m.java:238)
at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1531)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1493)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1
732)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
... 12 moreIt seems to be that it cannot find the Hello class file but this is bundled in Server.jar. Putting Server.jar on the classpath makes no difference.
Any ideas?Cheers, using createRegistry(int) did the trick (along with a few other bits and pieces).
For the sake of aiding others with this kind of problem here's what I did. Remember most of it came from the Sun Java 5 RMI tutorial (http://java.sun.com/j2se/1.5.0/docs/guide/rmi/hello/hello-world.html).
1. Download and compile SUN's class file server (http://java.sun.com/javase/technologies/core/basic/rmi/class-server.zip). You'll need this to serve up the classes. Place this in a different directory to the one your going to use for the RMI tutorial.
2. Download the source files for the tutorial.
3. Use this directory structure (relative to /home/<username>)
| RMI/
| src/
| example/
| hello/
| bin/4. Change the server to the following. The main points to note are the registry is now created (rather than located) and the port number used.
package example.hello;
import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
public class Server implements Hello {
public Server() {}
public String sayHello() {
return "Hello, world!";
public static void main(String args[]) {
try {
System.out.println("Starting Server");
Server obj = new Server();
Registry registry = LocateRegistry.createRegistry(2000);
System.out.println("Created registry");
Hello stub = (Hello) UnicastRemoteObject.exportObject(obj, 0);
System.out.println("Exported Server");
// Bind the remote object's stub in the registry
registry.rebind("Hello", stub);
System.out.println("Bound Server to \"Hello\"");
System.out.println("Server ready");
} catch (Exception e) {
System.err.println("Server exception: " + e.toString());
e.printStackTrace();
}5. In the src dir compile with the following;
javac -d ../bin example/hello/*.java6. In the bin dir create the server jar with the following;
jar cvfe Server.jar example.hello.Server example/hello/Server* example/hello/Hello*7. In the bin dir create the client jar with the following;
jar cvfe Client.jar example.hello.Client example/hello/Client* example/hello/Hello*8. Move both Jars out of the bin directory to the parent one (e.g. /home/<username>RMI/) (to prevent the rmi registry / server using the current dir in the classpath if you've set it up that way).
9. Create the policy file in the RMI directory (see above directory structure);
grant codeBase * {
permission java.security.AllPermission;
permission java.net.SocketPermission "*", "accept, connect, listen, resolve";
};10. Start the class file server (read the notes that come with it) in its own directory. Note the port number used (different from RMI registry) and the Jar file on the end of the path.
java ClassFileServer 2001 /home/<username>/RMI/Server.jar11. If this has worked you should be able to visit the URL http://localhost:2001 and get a blank page (as opposed to a broken link notification).
12. Start the RMI server in the bin dir. Note the port is the same as the one used to launch the class file server.
java -Djava.security.policy=policy -Djava.rmi.codebase=http://localhost:2001/ -jar Server.jar13. You should see the following output;
Starting Server
Created registry
Exported Server
Bound Server to "Hello"
Server ready14. Start the client
java -jar Client.jar15. You should see the following output;
response: Hello, world! -
Not able to call BPEL web service using RMI call from different machine
Hi,
1. I have created a smiple Helloworld asynchoronous BPEL process
2. I am able to call that BPEL process using java program (RMI call) which I have written in JDeveloper 10.1.3.3 and the java program is running in the embeded OCJ4 instance of JDeveloper sucessfully.
3. Now I am trying to run the same Java program in my unix machine where oracle application is installed.
4. I have set all the CLASSPATH for required jars which I have used in JDeveloper and also kept the jar file in Unix machine.
5. The java codes are complied successfully.
6. But when I am trying to run it , getting the following exception:
bash-3.00$ java HelloworldAsyn
name is Debkanta
property file data are: {java.naming.provider.url=opmn:ormi://172.18.19.169:6003:home/orabpel, java.naming.factory.initial=com.evermind.server.rmi.RMIInitialContextFactory, orabpel.platform=ias_10g, java.naming.security.principal=oc4jadmin, java.naming.security.credentials=welcome1}
hello3
java.lang.Exception: Failed to create "ejb/collaxa/system/DeliveryBean" bean; exception reported is: "javax.naming.NameNotFoundException: ejb/collaxa/system/DeliveryBean not found
at com.evermind.server.rmi.RMIClientContext.lookup(RMIClientContext.java:52)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at com.oracle.bpel.client.util.BeanRegistry.lookupDeliveryBean(BeanRegistry.java:279)
at com.oracle.bpel.client.delivery.DeliveryService.getDeliveryBean(DeliveryService.java:250)
at com.oracle.bpel.client.delivery.DeliveryService.post(DeliveryService.java:174)
at com.oracle.bpel.client.delivery.DeliveryService.post(DeliveryService.java:149)
at HelloworldAsyn.main(HelloworldAsyn.java:64)
at com.oracle.bpel.client.util.BeanRegistry.lookupDeliveryBean(BeanRegistry.java:293)
at com.oracle.bpel.client.delivery.DeliveryService.getDeliveryBean(DeliveryService.java:250)
at com.oracle.bpel.client.delivery.DeliveryService.post(DeliveryService.java:174)
at com.oracle.bpel.client.delivery.DeliveryService.post(DeliveryService.java:149)
at HelloworldAsyn.main(HelloworldAsyn.java:64)
bash-3.00$
I need to solve it urgently. Can anyone please help me.
Is it relaed to some user access issue in unix?
Thanks & Regards
Deb
Message was edited by:
user587916actually , I have laready given print stataement for the data in the context property file that you can see in the output. Today I am also able to call the bpel process using the same java program from my DOS command promt(cmd). Don't understand why the problem is occuring in unix.
please help. -
Not able to run a simple RMI server
I am running an RMI program like follwing
import java.rmi.* ;
import java.rmi.registry.* ;
import java.rmi.server.* ;
public class CallBeanServer extends UnicastRemoteObject implements ICallBeanServer
//main
public static void main(String args[]) throws Exception
int port = 1000 ;
Registry reg = null ;
if( args[0].equals("true"))
reg = LocateRegistry.createRegistry(port) ;
System.out.println("Successfully created registry") ;
else
reg = LocateRegistry.getRegistry(port) ;
System.out.println("Connected to existing registry") ;
CallBeanServer callBeanServer = new CallBeanServer(reg) ;
}//main
//constructor
public CallBeanServer(Registry reg) throws Exception, RemoteException
super() ;
reg.rebind("CallBeanServer",this) ;
System.out.println("CallBeanServer Object bound") ;
//my public method
public String callBeanServer() throws RemoteException
{ return "Success" ;
I have run the rmiregistry at port no 1000 like
rmiregistry 1000
I have compiled ICallBeanServer also and run rmic also over CallBeanServer like
rmic CallBeanServer
when I run this program using
java CallBeanServer false
it gives the follwoing errors
Connected to existing registry
Exception in thread "main" java.rmi.ServerException: Server RemoteException; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: CallBeanServer_Stub
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: CallBeanServer_Stub
java.lang.ClassNotFoundException: CallBeanServer_Stub
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at CallBeanServer.<init>(CallBeanServer.java:38)
at CallBeanServer.main(CallBeanServer.java:30)
Can you please tell me what is the error?
Thanks
Prashant GuptaAdd the classes (the stubs included) to the classpath when you start the registry.
-
Java.rmi.ServerException:
I am new to RMI concept
i stuck with the below problem
when i execute
E:\MyProjects\StockRMI>java -Djava.security.policy=policy.all StockMarketServerStockMarketServer is as shown below
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
import SimpleStocks.*;
public class StockMarketServer {
public static void main(String[] args) throws Exception {
if(System.getSecurityManager() == null) {
System.setSecurityManager( new RMISecurityManager() );
StockMarketImpl myObject = new StockMarketImpl( "NASDAQ" );
System.out.println( "RMI StockMarketServer ready..." );
} i got the following error
java.rmi.ServerException: RemoteException occurred in server thread; nested exce
ption is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
tion is:
java.lang.ClassNotFoundException: SimpleStocks.StockMarketImpl_Stub
RMI StockMarketServer ready...Interface class, Interface implementation class and stub all reside in MyProjects\StockRMI\SimpleStocks directory
where as Server class(StockMarkerServer) is in MyProjects\StockRMI
even i place the stub in MyProjects\StockRMI directory i got the same error.
Can any one please save me out of this problemhurry!
Thank u First of all
I got it.. finally after 2 days
The error is in CLASSPATH only , i set it
Thanks once again -
Weird classpath issue in EAR.Some classes can access jars that others cant!
Hi,
I'm experiencing a very frustrating problem that's proving to be a bit of a show stopper for me. I would really appreciate some help...
I have an EAR deployed successfully on Sun Appserver 8 which passes the tests from the sun EAR verifier tool. The ear contains a jar file that I built which has a stateless session bean, home, remote interfaces and rmi stubs, deployment descriptors, as well as some utility classes. The EAR also contains some third-party jars such as Hibernate, Log4-j, apache-commons etc etc. The jar I built has in it's manifest file, the classpath information to reference the other jars in the ear.
The problem I am having is that one of the classes in a third-party jar (hibernate3.jar) cannot see a class in another of the third party jars (log4j-1.2.8.jar) and as a result is throwing a NoClassDefFoundError for org/apache/log4j/Layout while trying to initialise - the two jars are at the root of the EAR.
Furthermore, my utility classes can access and use Log4j classes without any problem and logging command from those classes is output successfully to the server console. However, my session bean, which is packaged in the same jar as the utility classes, fails to log anything even though it uses exactly the same logger and log configuration as the utility classses.
I have tried adding classpath information to the manifest of the EAR so that the third-party jars can pick it up but this makes no difference. Also, according to the EAR verifier tool, you are not allowed to put any classpath information in the EAR manifest.
I have also tried deploying this in weblogic but am experiencing the same problem.
If anyone can offer any advice or solutions I would greatly appreciate it.
:)what´s type error have you?
perhaps external libraries (located in classpath) invoke opsCommon.jar and config-3.0.jar classes. then, classnotfound is normal.
and... why separate external libraries (opsCommon.jar and config-3.0.jar inside ear, and other in classpath)? -
Classpath issues when executing from a jar
I have a jar that I built for an RMI server that has a need to access another jar. (log4j). I run the jar from the command line using:
java -jar -Djava.rmi.server.codebase=my.jar my.jar
and the code runs fine but when I try to add in the log4j.jar I can't find it. I have placed it in my.jar in a lib directory within my.jar, I have placed it in the current directory, I have placed it in other directories I know are on the classpath, I have done all kinds of variations with the -classpath switch on the command line and nothing works.
How do I package, configure and/or call such that the Logger class in log4j.jar can be found by my RMI server when I execute my.jar?
ThanksRunning from the jar-file ignores the CLASSPATH. See Bug #4459663
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4459663
You have a few options:
First, you can unjar all of the jars you depend on and rejar 'em up with your jar. This is the simplest solution.
Second, you can skip running "from the jar" and just put that jar in your CLASSPATH.
Third, you can put jars you depend on in the $JAVA_HOME/jre/lib/ext directory.
Fourth, you can modify the manifest to specify a classpath, and then put the libraries you depend on at the places specified.
And, if you think There Ought To Be A Better Way, vote for the RFE! -
Error in trying dynamic class loading in sun rmi tutorila
Hi,
I am trying the sun rmi tutorial http://java.sun.com/docs/books/tutorial/rmi/. I am not able to download the stub class from the codebase to client. The server is running in a linux box while the client in a w2k box.
Linux box (server)
==================
web server setting
Alias /rmi_codebase /home/wing/try/java/rmi
rmiregistry setting
unset CLASSPATH
rmiregistry
rmi server
classses
/home/wing/try/java/rmi/client/ComputePi.class
/home/wing/try/java/rmi/client/Pi.class
/home/wing/try/java/rmi/compute/Compute.class
/home/wing/try/java/rmi/compute/Task.class
/home/wing/try/java/rmi/compute/ComputeEngine.class
/home/wing/try/java/rmi/compute/ComputeEngine_Skel.class
/home/wing/try/java/rmi/compute/ComputeEngine_Stub.class
java.policy
grant {
permission java.security.AllPermission;
startup with script as follows
java -cp /home/wing/try/java/rmi -Djava.rmi.server.codebase=http://localhost/rmi_codebase/ -Djava.rmi.server.hostname=man82.air.com.hk -Djava.security.policy=/home/wing/try/java/rmi/java.policy
engine.ComputeEngine
(the server is started happyily)
W2k box (client)
================
class the same as server except removing the stub (ComputeEngine_Stub).
java.policy
grant {
permission java.security.AllPermission;
startup script
java -Djava.rmi.server.codebase=http://man82/rmi_codebase/ -Djava.security.policy=java.policy clientComputePi man82 20
The error encounter is
ComputePi exception: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: engine.ComputeEngine_Stub
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: engine.ComputeEngine_Stub
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:83)
at client.ComputePi.main(ComputePi.java:14)
Caused by: java.lang.ClassNotFoundException: engine.ComputeEngine_Stub
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
Is this problem related to codebase setting or security?
BTW, I have tried to put the stub to the client as well, it works.
Thanks in advance of any ideas or input.
WingBased on my previous post, I have performed some more testings of the tutorial code and find that the java.rmi.server.codebase could not be specified in the client side.
Instead, the client follows the codebase set in the server, and thus, the localhost could not used in the server when the client is in separate machine.
This is a bit different from the tutorial, please enlighten me if you have any comments.
To make the dynamic download works,
server side
change the codebase property from http://localhost/rmi-codebase/ to http://man82/rmi_codebase/
client side
remove the codebase property http://man82/rmi_codebase/
It is funny that if I add the codebase property when start up the client, it won't work.
Thanks in advance for any ideas and input.
Wing -
How to change the classpath in rmiregistry
I am storing remote object stubs in an RMI registry as part of my application. When I try to bind my objects to the rmiregistry started by the kxs process on port 1099, I get class def not found errors because that rmiregistry does not have my classes in the classpath. My classes are in the iAS classpath because I added them through the registry.
When I start my own rmiregistry on a different port and set the classpath environment variable to include my classes, then I have no problems.
Does anyone know how to change the classpath for the rmiregistry started by the kxs process?
I am running iAS sp3 on Windows 2000 adn Solaris
Thanks,
MarkHi,
I would like to help, but could you kindly clarify what rmiregistry
means ?
Regards
Raj
Mark Priest wrote:
I am storing remote object stubs in an RMI registry as part of my
application. When I try to bind my objects to the rmiregistry started
by the kxs process on port 1099, I get class def not found errors
because that rmiregistry does not have my classes in the classpath.
My classes are in the iAS classpath because I added them through the
registry.
When I start my own rmiregistry on a different port and set the
classpath environment variable to include my classes, then I have no
problems.
Does anyone know how to change the classpath for the rmiregistry
started by the kxs process?
I am running iAS sp3 on Windows 2000 adn Solaris
Thanks,
Mark
Try our New Web Based Forum at http://softwareforum.sun.com
Includes Access to our Product Knowledge Base! -
I have write RMI program the problem it's that I don't now how to start it
This is my Interface
import java.rmi.*;
import java.rmi.Remote;
public interface DataInterface extends Remote {
public String testRemote() throws RemoteException ;
This is my server
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
public class DataServer extends UnicastRemoteObject implements DataInterface {
DataServer() throws RemoteException{
super();
public String testRemote() throws RemoteException{
return "Merge obiectul remote";
public static void main(String[] args) {
System.setSecurityManager(new RMISecurityManager());
try{
//LocateRegistry.createRegistry(1099);
DataServer testServer = new DataServer();
Naming.rebind("//localhost/SERVER", testServer);
}catch(Exception e){
e.printStackTrace();
This is my client
import java.rmi.*;
import java.rmi.registry.*;
import java.rmi.server.*;
public class DataClient {
public static void main(String[] args) {
System.setSecurityManager(new RMISecurityManager());
try{
Remote remoteServer = Naming.lookup("//localhost/SERVER");
DataServer server = (DataServer)remoteServer;
System.out.println(server.testRemote());
} catch(Exception e){
e.printStackTrace();
And this is my policy file
grant {
permission java.net.SocketPermission "*:1024-65535",
"connect,accept";
permission java.net.SocketPermission "*:80", "connect";
All this files are in c:\temp and this directory is in my PATH variable. I've compilated the interface, server, client with
javac -classpath file.java
After that I generate with rmic the stub skel file in c:\temp. In this point I have all the files that I need. If is somebody kind to tell me from now what do I have to do to make this program work :)). Thanks for any help.so..u have everything ready..
open cmd prompt and say 'start rmiregistry' - >this opens a new cmd prompt for rmi registry.let it run
now first run ur server by saying 'java DataServer' // include options as u like. this should be running without terminating.
now open new cmd prompt for ur client and say 'java DataClient '.
thats all.
if you want to run the client from a different machine, then try copying the client file into another m/c after changing the code from 'localhost' to the ip address of the server m/c. then just say 'java DataClient '
hope this works fine! -
RMI Problem with rebind()
created files as below. All compiled successfully.
ran <rmic -v1.1 -d %cp% -classpath %cp% server.TempServerImpl> from command window.
this generated a stub file called TempServerImpl_Stub.class
I launched the rmiRegistry
To make the remote object available to recieve mathod calls from clients I run TempServerImpl.class
But ..... when I run TempServerImpl I get the exception "java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: "
AND..... my stub class is deleted without any warning!!!
if I comment out the line "Naming.rebind( serverObjectName, tempServer );" after I generate the stub class then TempServerImpl runs without throwing any exception but this must be included to bind my remote server object to the RMI registry.
Any ideas what Im missing?
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.net.URL;
import java.rmi.Remote;
import java.rmi.Naming;
public class TempServerImpl extends UnicastRemoteObject implements TempServer{
public TempServerImpl() throws RemoteException {
super();
public Info getInfo() throws RemoteException{
return new Info("some temperature data returned");
public static void main( String args [] ) throws Exception{
TempServerImpl tempServer = new TempServerImpl();
String serverObjectName = "//localhost/TempServer";
Naming.rebind( serverObjectName, tempServer );
//************ Remote Interface
import java.rmi.*;
import java.rmi.RemoteException;
public interface TempServer extends Remote {
public Info getInfo() throws RemoteException;
import java.io.Serializable;
public class Info implements Serializable{
private String data;
public Info(String data){
this.data = data;
public String toString(){
return this.data;
[\code]Are you sure that the stub is being deleted, or is it just that the exception message says it can't be found. If it's the latter it might be that the stub is not in the class path of either the commandline running the rmi registry or the commandline running the TempServerImpl. However as you are running this i assume it ok.
The code looks fine, The problem is something to do with classpaths ect. -
RMI problem with weblogic.jar
We have a pure Java client that connects to the Weblogic server.
While trying to connect we receive the error message below.
I have unjarred the weblogic.jar file and discovered that the
Stub.class is actually in weblogic/rmi/extensions/server/
while it expects it to be in weblogic/rmi/extensions .
Is there a fix for this as we are trying to upgrade from a previous version of weblogic and go live in Jan.
Thanks
Dave F
java.lang.NoClassDefFoundError: weblogic/rmi/extensions/Stub(I'd suggest that you run the vm with the debug flag (-verbose) and see where the classes are being loaded; and examine the classpath to determine where the old jar or classes are occurring.
Rita wrote:
We have re-jarred the Stub.class and put it under weblogic/rmi/extensions, but when the java app runs, it still tries to look in weblogic/rmi/extensions/server. So, I think somewhere in the weblogic.jar, the path specified is still weblogic/rmi/extensions. Do you know what need to be done?
Thanks,
Rita
Eduardo Ceballos <[email protected]> wrote:
Yes, please regenerate your stub classes. That is, re-run rmic or ejbc.
David Furlong wrote:
We have a pure Java client that connects to the Weblogic server.
While trying to connect we receive the error message below.
I have unjarred the weblogic.jar file and discovered that the
Stub.class is actually in weblogic/rmi/extensions/server/
while it expects it to be in weblogic/rmi/extensions .
Is there a fix for this as we are trying to upgrade from a previous version of weblogic and go live in Jan.
Thanks
Dave F
java.lang.NoClassDefFoundError: weblogic/rmi/extensions/Stub( -
Beginner running RMI example problem
I am trying to test this RMI code from Thinking in java and it is giving this error
Exception in thread "main" java.lang.NoClassDefFoundError: DispatchPerfectTime (
wrong name: project3/rmi/DispatchPerfectTime)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:488)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:10
6)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:243)
at java.net.URLClassLoader.access$100(URLClassLoader.java:51)
at java.net.URLClassLoader$1.run(URLClassLoader.java:190)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:183)
at java.lang.ClassLoader.loadClass(ClassLoader.java:294)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:281)
at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:310)
I compiled the 3 files below and also called rmic and created a stub and skeleton..... Only it doesnt run..
Any ideas why ?
INTERFACE
package project3.rmi;
import java.rmi.*;
interface PerfectTimeI extends Remote
long getPerfectTime() throws RemoteException;
}Implementation of Remote interface
package project3.rmi;
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
import java.net.*;
public class PerfectTime extends UnicastRemoteObject implements PerfectTimeI
public long getPerfectTime() throws RemoteException
return System.currentTimeMillis();
//constructor to throw remote exceptions
public PerfectTime() throws RemoteException
//super(); called automatically
//register for rmi server
public static void main(String args[]) throws Exception
LocateRegistry.createRegistry(2005);
System.setSecurityManager(new RMISecurityManager());
PerfectTime pt = new PerfectTime();
Naming.rebind("//200.23.23.2:2005/PerfectTime",pt); //I put dummy IP instead of my real IP
System.out.println("Ready to do time");
}USING REMOTE OBJECT
/**Using the remote object**/
package project3.rmi;
import java.rmi.*;
public class DispatchPerfectTime
public static void main(String args[]) throws Exception
System.setSecurityManager(new RMISecurityManager());
PerfectTimeI t = (PerfectTime)Naming.lookup("//200.23.23.2:2005/PerfectTime");
for(int i =0;i<10;i++)
System.out.println("Perfect Time is "+t.getPerfectTime());
}I am just using another RMI example from class now...
All files are compiling but this is error.....
C:\>java -classpath c:\ RMIServer
Starting Server
Started Server...
Binding to RMI Registry
Error RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
tion is:
java.lang.ClassNotFoundException: RMIServer_Stub
I doono if my host is correct...... I donno what to write in place of test... its some service??
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
public class RMIServer extends UnicastRemoteObject implements RMIInterface
static String host = "rmi://IPAddress/test";
static String data[] = {"c","c++","java"};
public RMIServer() throws RemoteException
super();
//implement methods
public int getNumData() throws RemoteException
return data.length;
public String getData(int index) throws RemoteException
if(index>=0 && index<data.length)
return data[index];
else
return "N/A";
public static void main(String args[])
RMIServer server;
try{
System.out.println("Starting Server");
server = new RMIServer();
System.out.println("Started Server...");
System.out.println("Binding to RMI Registry");
Naming.rebind(host,server);
System.out.println("Remote methods registered successfully");
catch(Exception e){
System.out.println("Error "+e.getMessage());
}//main
} //class -
InitialContext and javax.rmi.PortableRemoteObject
I've been trying to locate a very annoying problem that I get when I try to bind remote objects in JNDI. I have now located the problem but I have no idea why this causes a problem or how to fix it. It seems that creating an InitialContext has different effects depending whether I create an instance of javax.rmi.PortableRemoteObject before.
Here's what I am doing...
1:Context ctx = new InitialContext(); //Create Initial context
2://Instantiate remote object (extends PortableRemoteObject and stubs gen with rmic with -iiop flag)
3:Hello hello = new HelloImpl();
4:ctx.rebind("hello", hello); //Bind to JNDI
5:System.out.println("Object bound!!!!!");
This code works fine. The problem occurs when I try to instantiate the remote object before creating the InitialContext for the first time (I.e. I move line 3 to the top) I then get the following exception:
2007-aug-13 09:32:26 com.sun.corba.ee.impl.util.Utility autoConnect
VARNING: "IOP00511403: (INV_OBJREF) Class rmi.HelloImpl not exported, or else is actually a JRMP stub"
org.omg.CORBA.INV_OBJREF: vmcid: SUN minor code: 1403 completed: No
at com.sun.corba.ee.impl.logging.UtilSystemException.objectNotExported(UtilSystemException.java:569)
at com.sun.corba.ee.impl.logging.UtilSystemException.objectNotExported(UtilSystemException.java:592)
at com.sun.corba.ee.impl.util.Utility.autoConnect(Utility.java:147)
at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.writeAny(Util.java:323)
at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl$10.write(DynamicMethodMarshallerImpl.java:256)
at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl.writeArguments(DynamicMethodMarshallerImpl.java:407)
at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:157)
at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:119)
at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(BCELStubBase.java:197)
at com.sun.enterprise.naming._SerialContextProvider_DynamicStub.rebind(_SerialContextProvider_DynamicStub.java)
at com.sun.enterprise.naming.SerialContext.rebind(SerialContext.java:403)
at javax.naming.InitialContext.rebind(Unknown Source)
at parlayxws.usecases.ejb.px_spec_v2_1.RunEjb.main(RunEjb.java:43)
Exception in thread "main" javax.naming.CommunicationException: java.rmi.NoSuchObjectException: CORBA INV_OBJREF 1398080891 No; nested exception is:
org.omg.CORBA.INV_OBJREF: vmcid: SUN minor code: 1403 completed: No
at com.sun.enterprise.naming.SerialContext.rebind(SerialContext.java:405)
at javax.naming.InitialContext.rebind(Unknown Source)
at parlayxws.usecases.ejb.px_spec_v2_1.RunEjb.main(RunEjb.java:43)
I assume the problem is in the javax.rmi.PortableRemoteObject's (HelloImpl's) constructor since that is the only code that's beeing executed. But how could that effect the instantiation of the InitialContext? I should also say that it seems that it is only the first time that an InitialContext is created that is critical. If I create on instance of it before instantiating the first PortableRemoteObject, all subsequently created instances of InitialContext succeed in binding remote (RMI-IIOP) objects.
Can someone help me understand why this happens and how to avoid it? I don't want to have to create an InitialContext the first thing I do in the code. It seems the PortableRemoteObject constructor somehow changes the configuration in a way that makes the bindings fail... How? Why? Can I prevent it from happening?
Any input appreciated!
Kristofermy bean is running in my EJBServer, and I have it in the classpath of the RmiRegistry (which runs as part of my server). The RmiRegistry is an actual ".bat" file that starts an RMI Registry (I assume).
The client is not a bean and is run like this:
java com.titan.cabin.Client_1
All it does is create a cabin and then read it back. It works, it not only gets the context, but also creates, persists and reads that cabin bean.
Is it because java automatically finds all RmiRegistries running on the computer? This makes sense, but I read on java.sun.com that you need a stub class for your clients. And if it is true, then how does it get the context and remote/home interface of a bean on another server? -
when i try to compile my server i get the following errors
D:\JAVA_P~1\SIMPLE~1>javac -classpath . PhoneDirServer.java
PhoneDirServer.java:6: package PhoneDirectory does not exist
import PhoneDirectory.PhoneDirImpl;
^
.\PhoneDirImpl.java:34: class, interface, or enum expected
^
.\PhoneDirImpl.java:12: cannot find symbol
symbol: class PhoneDirInterface
implements PhoneDirInterface {
^
PhoneDirServer.java:29: cannot access PhoneDirImpl
bad class file: .\PhoneDirImpl.java
file does not contain class PhoneDirImpl
Please remove or make sure it appears in the correct subdirectory of the classpa
th.
PhoneDirImpl myObject = new PhoneDirImpl();
^
4 errors
here is my server code
import java.util.Properties;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import PhoneDirectory.PhoneDirImpl;
* Creates a Server and binds the RMI Servant with the IIOP Registry
public class PhoneDirServer {
static final String CONTEXT_NAME = "java.naming.factory.initial";
static final String IIOP_STRING = "com.sun.jndi.cosnaming.CNCtxFactory";
static final String URL_NAME = "java.naming.provider.url";
static final String IIOP_URL_STRING = "iiop://localhost:1000";
* Entry Point to this application
public static void main(String[] args) {
try {
// Create the Object
PhoneDirImpl myObject = new PhoneDirImpl();
// Create the IIOP Initial Context
Properties iiopProperties = new Properties();
iiopProperties.put( PhoneDirServer.CONTEXT_NAME,
PhoneDirServer.IIOP_STRING );
iiopProperties.put( PhoneDirServer.URL_NAME,
PhoneDirServer.IIOP_URL_STRING );
InitialContext iiopContext = new InitialContext( iiopProperties );
// Bind the object to the IIOP registry
iiopContext.rebind( "Phone Directory", myObject );
System.out.println( "Hello from server, ready for action..." );
catch ( Exception exception ) {
exception.printStackTrace ();
}they are all in the same directory ..
PhoneDirImpl.java
PhoneDirInterface.java
PhoneDirServer.javasorry the code is
import java.rmi.*;
import java.rmi.server.*;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.HashMap;
import java.util.Map;
public class PhoneDirServer extends UnicastRemoteObject
implements PhoneDirInterface {
private Map pbMap = new HashMap();
public PhoneDirServer () throws RemoteException
super();
try {
BufferedReader br = new BufferedReader(new FileReader("numbers.txt"));
String line;
while ((line = br.readLine()) != null)
String[] info = line.split(":", 2);
pbMap.put(info[0], info[1]);
catch (Exception exc) {
exc.printStackTrace();
System.exit(1); }
public String getPhoneNumber(String name) {
return (String) pbMap.get(name); }
public boolean addPhoneNumber(String name, String num) {
if (pbMap.containsKey(name)) return false;
pbMap.put(name, num); return true; }
public boolean replacePhoneNumber(String name, String num) {
if (!pbMap.containsKey(name)) return false;
pbMap.put(name, num); return true;
public static void main ( String args[] ) throws Exception
// Assign a security manager, in the event that dynamic
// classes are loaded
if (System.getSecurityManager() == null)
System.setSecurityManager ( new RMISecurityManager() );
// Create an instance of our service server ...
PhoneDirServer server = new PhoneDirServer();
// ... and bind it with the RMI Registry
Naming.bind ("PhoneBook",server);
System.out.println ("Service bound....");
}and the interface is
import java.rmi.Remote;
import java.rmi.RemoteException;
* This is an interface to a component that looks up
public interface PhoneDirInterface extends Remote {
public String getPhoneNumber(String name) throws RemoteException;
public boolean addPhoneNumber(String name, String num) throws RemoteException;
public boolean replacePhoneNumber(String name, String num)throws RemoteException;
}
Maybe you are looking for
-
Weather Widget bug: doesn't display full city name initially
I have a brand-new Mac Mini. The weather widget is configured incorrectly if you go through the default set-up process for Philadelphia. I went through the standard Mac OS X first-time setup, telling it my location (Philadelphia, USA). This pre-confi
-
How to place attribute at column in query designer
Hi Experts, I have to place attribute in column panel, but it is not possible. Is there any solution for this problem. Attribute is already created. please help me to solve this.
-
Hello, as I read, WLS provides the possibility to slow down message producers when certain paging thresholds are exceeded. I'm not quite sure, if the slow down of a producer is tied to it's session lifecycle, i.e. if the producer is slowed
-
Hi guys I am trying to cancel my subscription
Can anyone help me cancel my subscription?
-
Hi, I got this under SQL 2000: Table_a.x =CASE WHEN (IsNull(mnt,0)+IsNull(mnt_2,0))= IsNull(mnt_sum,0) THEN 'Cool' ELSE table_b.x so I'm trying something like: Table_a.x = DECODE('1',DECODE(NVL(mnt, 0) + NVL(mnt_2, 0), NVL(mnt_sum,0),'1',0)),'1','Coo