File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes rmic and ClassNotFoundException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "rmic and ClassNotFoundException" Watch "rmic and ClassNotFoundException" New topic
Author

rmic and ClassNotFoundException

John Deal
Greenhorn

Joined: Sep 07, 2006
Posts: 20
This seems such a brain-dead issue but I have spent several hours trying to figure this out. Please excuse me if this is not apporporate for this forum.

I have my RemoteData class that implements a remote interface that extends Remote (named RemoteDataInterface). All my DB classes are in the same package at suncertify.db in the code directory. I then cd to the code directory and type: "rmic suncertify.db.RemoteData" and this produces the file RemoteData_Stub.class in the suncertify.db directory.

When my program runs I do a UnicastRemoteObject.exportObject() to a instance of RemoteDataInterface called remoteDataStub. After obtaining the registry reference via LocalRegistry.getRegistry() and verifying it is there with a list() call, I do a rebind(Name, remoteDataStub) call. This results in a "java.lang.ClassNotFoundException: suncertify.db.RemoteData_Stub" exception even though there is a suncertify.db.RemoteData_Stub.class file.

Reading through Sun's rmic documentation, it states there should be a RemoteData_Skel.class file produced. It is my understanding that this is the server-side linkage to the remote interface. This file does not seem to be produced by my rmic command.

Any ideas? Thanks!


SCJP 1.4, SCJD 1.5
Mark Smyth
Ranch Hand

Joined: Feb 04, 2004
Posts: 288
Originally posted by John Deal:
This seems such a brain-dead issue but I have spent several hours trying to figure this out. Please excuse me if this is not apporporate for this forum.

I have my RemoteData class that implements a remote interface that extends Remote (named RemoteDataInterface). All my DB classes are in the same package at suncertify.db in the code directory. I then cd to the code directory and type: "rmic suncertify.db.RemoteData" and this produces the file RemoteData_Stub.class in the suncertify.db directory.

When my program runs I do a UnicastRemoteObject.exportObject() to a instance of RemoteDataInterface called remoteDataStub. After obtaining the registry reference via LocalRegistry.getRegistry() and verifying it is there with a list() call, I do a rebind(Name, remoteDataStub) call. This results in a "java.lang.ClassNotFoundException: suncertify.db.RemoteData_Stub" exception even though there is a suncertify.db.RemoteData_Stub.class file.

Reading through Sun's rmic documentation, it states there should be a RemoteData_Skel.class file produced. It is my understanding that this is the server-side linkage to the remote interface. This file does not seem to be produced by my rmic command.

Any ideas? Thanks!


The skeleton is not produced by the rmic command since java 1.2 (or possibly 1.3 could someone confirm?) as it is not required by newer versions of java, I think it is generated on the fly either way it is not a concern of the developer anymore.

The compiller is not finding the generated stub class file for some reason, I cannot know without seeing the error but there is probably a very simple configuration reason for this problem.

Regards,
Mark


SCJP<br />SCJD
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 918

Try java -verbose to get what really happen.


SCJP, SCJD, SCWCD, OCPJBCD
John Deal
Greenhorn

Joined: Sep 07, 2006
Posts: 20
Thanks for all of the ideas. Now the scary part....I can't reproduce the problem! I put my system in hybernation mode for a few days to keep everything exactly as I had it until I could spend some concentrated time on it and now it works! Scary.
John Deal
Greenhorn

Joined: Sep 07, 2006
Posts: 20
Well....it seems like the sunshine treatment did not work after all. The problem is back without changing the code. I rebooted the system and it came back . I did do the -verbose and I have these observations:

After I get the registry and verify I have it by doing a list() call, I do a Naming.bind(REMOTE_DB_NAME, remoteDataStub); with REMOTE_DB_NAME being a string constant "HIBServer" and remoteDataStub being the stub for remoteData (the implementation class of the remote interface that extends Remote and alos extents UnicastRemoteObject) that exists as RemoteData_Stub.class in the directory with all the other server classes. Below is the verbose output from this point. Note that I get a java.io.UnsupportedEncodingException a little bit after the bind() command (I have tried bind() and rebind() with same effect). I could not find anything to tell me what this exactly means but assume it is something about the stub object it does not like.

The other interesting note is if I do not startup a rmiregistry and run start my server its createRegistry() works and the same bind() (or rebind()) method works. In a debugger I can look in the created Registry object and see the binding of the name and object in its hash table.

Any hints on why the binding is successful if I create the registry vs using an empty existing registry? Thanks for all the help.

[Loaded java.rmi.Naming from C:\eclipse\jre\lib\rt.jar]
[Loaded java.rmi.Naming$ParsedNamingURL from C:\eclipse\jre\lib\rt.jar]
[Loaded sun.reflect.UnsafeFieldAccessorFactory from C:\eclipse\jre\lib\rt.jar]
[Loaded sun.reflect.UnsafeStaticFieldAccessorImpl from C:\eclipse\jre\lib\rt.jar]
[Loaded sun.reflect.UnsafeQualifiedStaticFieldAccessorImpl from C:\eclipse\jre\lib\rt.jar]
[Loaded sun.reflect.UnsafeQualifiedStaticLongFieldAccessorImpl from C:\eclipse\jre\lib\rt.jar]
[Loaded sun.reflect.UnsafeQualifiedStaticObjectFieldAccessorImpl from C:\eclipse\jre\lib\rt.jar]
[Loaded sun.reflect.GeneratedSerializationConstructorAccessor2 from __JVM_DefineClass__]
[Loaded java.io.UnsupportedEncodingException from C:\eclipse\jre\lib\rt.jar]
[Loaded sun.reflect.GeneratedSerializationConstructorAccessor3 from __JVM_DefineClass__]
[Loaded sun.reflect.GeneratedSerializationConstructorAccessor4 from __JVM_DefineClass__]
[Loaded sun.reflect.GeneratedSerializationConstructorAccessor5 from __JVM_DefineClass__]
[Loaded java.io.ObjectStreamClass$ClassDataSlot from C:\eclipse\jre\lib\rt.jar]
[Loaded sun.reflect.NativeMethodAccessorImpl from C:\eclipse\jre\lib\rt.jar]
[Loaded sun.reflect.DelegatingMethodAccessorImpl from C:\eclipse\jre\lib\rt.jar]
[Loaded java.rmi.ServerException from C:\eclipse\jre\lib\rt.jar]
[Loaded sun.reflect.GeneratedSerializationConstructorAccessor6 from __JVM_DefineClass__]
[Loaded java.io.PrintWriter from C:\eclipse\jre\lib\rt.jar]
[Loaded sun.reflect.GeneratedSerializationConstructorAccessor7 from __JVM_DefineClass__]
[Loaded sun.reflect.GeneratedSerializationConstructorAccessor8 from __JVM_DefineClass__]
[Loaded java.io.ObjectStreamClass$1 from C:\eclipse\jre\lib\rt.jar]
[Loaded java.io.ObjectStreamClass$MemberSignature from C:\eclipse\jre\lib\rt.jar]
[Loaded java.io.ObjectStreamClass$3 from C:\eclipse\jre\lib\rt.jar]
[Loaded java.io.ObjectStreamClass$4 from C:\eclipse\jre\lib\rt.jar]
[Loaded java.io.ObjectStreamClass$5 from C:\eclipse\jre\lib\rt.jar]
[Loaded sun.reflect.GeneratedSerializationConstructorAccessor9 from __JVM_DefineClass__]
[Loaded sun.reflect.GeneratedSerializationConstructorAccessor10 from __JVM_DefineClass__]
[Loaded sun.reflect.GeneratedSerializationConstructorAccessor11 from __JVM_DefineClass__]
[Loaded sun.reflect.GeneratedSerializationConstructorAccessor12 from __JVM_DefineClass__]
[Loaded java.rmi.UnmarshalException from C:\eclipse\jre\lib\rt.jar]
[Loaded sun.reflect.GeneratedSerializationConstructorAccessor13 from __JVM_DefineClass__]
[Loaded sun.reflect.GeneratedSerializationConstructorAccessor14 from __JVM_DefineClass__]
Remote Exception from bind(): RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: suncertify.db.RemoteData_Stub
[Loaded java.util.HashMap$KeyIterator from C:\eclipse\jre\lib\rt.jar]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: rmic and ClassNotFoundException