File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Distributed Java and the fly likes can not found interface class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "can not found interface class" Watch "can not found interface class" New topic
Author

can not found interface class

Simon Simbolon
Greenhorn

Joined: Apr 15, 2010
Posts: 5
Hi, all

I'm still new to RMI, so please be gentle

I'm trying to create an RMI server using netbeans, but I'm having some difficulties. Here is my code:

the interfaceJar:


The implementationJar:
1st class:


2nd class:


I build both jar and put them with this hierarchy in the server:
/opt/temp/implementationJar.jar
/opt/temp/lib/interfaceJar.jar

but when I run the command: java -jar implementationJar.jar, i got following error:

java.rmi.UnexpectedException: undeclared checked exception; nested exception is:
java.lang.ClassNotFoundException: Could not find class (interfaces.Calculator) at codebase ()
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:160)
at server.CalculatorServer.<init>(CalculatorServer.java:31)
at server.CalculatorServer.main(CalculatorServer.java:48)
Caused by: java.lang.ClassNotFoundException: Could not find class (interfaces.Calculator) at codebase ()
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:359)

What did I do wrong?
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 529
    
    6
Hi,
Include Interfaces.jar in classpath with -cp option.
Setting up RMI needs attention - lots of things that can go wrong. It's a good idea to read RMI tutorial
and RMI FAQ thoroughly first, if you haven't done so already.
Simon Simbolon
Greenhorn

Joined: Apr 15, 2010
Posts: 5
I've tried adding the -cp, so the command like are like this:
java -cp /opt/temp/lib/interfaceJar.jar -jar implementationJar.jar
but the error is still occurs.

I've also tried to add the codebase property:
java -Djava.security.policy=/opt/event-logger-client/wideopen.policy -Djava.rmi.server.codebase=file:///opt/temp/lib/isengInterfaces.jar -jar isengServer.jar
but instead I found error:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassCastException: java.io.ObjectStreamClass cannot be cast to java.lang.String
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:359)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:160)
at server.CalculatorServer.<init>(CalculatorServer.java:31)
at server.CalculatorServer.main(CalculatorServer.java:48)
Caused by: java.lang.ClassCastException: java.io.ObjectStreamClass cannot be cast to java.lang.String

please help?
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 529
    
    6
Hi,

One of these should be done.
1) rmiregistry has the interface jar in its classpath, OR
2) rmiregistry is running with -Djava.rmi.server.codebase set, OR
3) rmiregistry runs without either settings, but then server should run with -Djava.rmi.server.codebase set.
All these are so that the Naming binding can find the interface and tack it onto the dynamically created stub.

Mandatorily, the server should also have -cp interface.jar. This is nothing to with the binding, but because your server has a runtime dependency on the interface.

Also go through this article on dynamic code downloading
Arpita Shah
Greenhorn

Joined: Aug 28, 2009
Posts: 15
For a really good review of reporting systems available on SharePoint, take a look at http://www.sharepointreporting.info/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can not found interface class