Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

can not found interface class

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For a really good review of reporting systems available on SharePoint, take a look at http://www.sharepointreporting.info/
 
reply
    Bookmark Topic Watch Topic
  • New Topic