• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

building jar files, server.jar, client.jar and fbn.jar

 
Endre Moen
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two jar files, server.jar and client.jar.
server.jar contains all classes from the server and db package, and a manifest file with Main-class: suncertify.server.Server. Client.jar contains all class from the client package and the DataFacade_stub which is the interfacing class for the RMI connection. These files and all helping files are put in a fbn.jar (db.db and data.policy.txt).
I try to run the server by:
my_path\jar -xcf fbn.jar
my_path\start rmiregistry
my_path\java
-Djava.security.policy=data.policy.txt -jar server.jar
Which will cause:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: suncertify.server.DataFacade_Stub
...
but the DataFacade_Stub is in the server.jar file.
Now, if I extract the server.jar,
my_path\suncertify\server>java Server
Exception in thread "main" java.lang.NoClassDefFoundError: Server (wrong name: suncertify/server/Server)
at java.lang.ClassLoader.defineClass0(Native Method)at java.lang.ClassLoader.defineClass(ClassLoader.java:493)...

But if I compile everything in the db and server package, it will run (yes, everything was compiled and running before I jar'ed it). Even more odd, if I run the program once in this maner and the try to do:
my_path\java
-Djava.security.policy=data.policy.txt -jar server.jar
it will also run! This sugests that something is happening in the rmiregistry or in the enviromnental variables that causes it to run.
Do we have to deliver two executable jar files?
Can we not just give instructions on how to compile and run the program in the readme file.
This is driving me crasy!
 
Branko Paskutini
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Endre,
I had the same problem, and got it working after adding the codebase as one of the jvm parameters. Try this:
my_path\java -Djava.rmi.server.codebase=file:server.jar
-Djava.security.policy=data.policy.txt -jar server.jar
Hope this helps, Branko.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a manifest file in your jar that makes it an executable jar?
Mark
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before you start the RMI Registry, try
set CLASSPATH=server.jar.
 
Endre Moen
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found out of it with help from Geir Morten Hagen.
It is a good idea to add the following to the server:
System.setProperty("java.rmi.server.codebase", "file:"+System.getProperty
("user.dir")+System.getProperty("file.separator")+"server.jar");
System.setProperty("java.security.policy", System.getProperty("user.dir")+
System.getProperty("file.separator")+"data.policy.txt");
I had not added the codebase to the server. Tanx everyone
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic