• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

loading classes

 
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am in a situation I do not understand and will attempt to explain it as
best as i can.

I have created a simple rmi "echo" client/server application straight from
one of the sun courses. it has a class echo.server that only rebinds echo objects to the rmi registry.

I can compile and properly the client server rmi process when the
interface, impl class, stubs/skeletons are all in the same application.jar.
my java command line looks like

java -cp application.jar echo.server

If I move these the remote interface, impl, stub/skeleton to a
library.jar. all compiles properly. However, I recieve unmarshing error Echo ClassNotFoundException when I attempt to run it.

java -cp library.jar;application.jar echo.server


Why would simply moving the remote things to a package that I can share amongst many applictions be disallowed? I
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you provide a short list of what is in each of the JARs? Also, what class is not found that throws the ClassNotFoundException?
 
peter cooke
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If everhting is in one jar all works fine.

In non-working scenario.
All classes are packaged in appropriate directory structure.

the applciation jar contains EchoServer.java at it's top.




libary jar has a EchoApp Directory that contains the remote interface, implementation, stub/skeleton classes. rmic -v1.1

remote interface


Impl class



[ February 02, 2005: Message edited by: peter cooke ]
[ February 02, 2005: Message edited by: peter cooke ]
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I was able to run your example - what you need to do is set the codebase property for your server. The ClassNotFoundException is thrown because the RmiRegistry can't find your stub to save in the registry. All you have to do is change your command line to look something like -



(NEP - edited to break up really long command prompt line.)
[ February 03, 2005: Message edited by: Nathan Pruett ]
 
peter cooke
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nathan thanks so much. Have one last question.
Ok I found the documentation on sun about codebase.

Would you happen to know the reason why I must specify the codebase?
[ February 03, 2005: Message edited by: peter cooke ]
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Section 3.2 in this RMI documentation gives a pretty good description.

Basically, codebase is kind of like a classpath for the remote code. If a client can't load a class in it's local classpath, it will look in the server's codebase for it.
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nearly three years later but just wanted to say thanks to Nate for answering this...

I had the exact same problem (worked unjar'd, threw the classNotFound when the application was jar'd). Interesting though, Sun says you don't need a codebase if you're using 1.5 (which I am). How come I needed the codebase afterall?

Sun's example and explanation

Note: If the server needs to support clients running on pre-5.0 VMs, then a stub class for the remote object implementation class needs to be pregenerated using the rmic compiler, and that stub class needs to be made available for clients to download. See the codebase tutorial for more details.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic