• 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

Jar file for the codebase

 
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Has anyone tried a jar file instead of directory location for java.rmi.server.codebase property during the rmi server starup?
Can you share the command with me? Please...Thanks.
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not able to start my server (ClassNotFoundException for the stubs ) with out the java.rmi.server.codebase property value set during the startup.
I can successfully set the property with the value including the drive letter. I really don't want to do it. Is there anyway to set the codebase value using relative path?
What have you done? Thanks a lot.
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It has to do with your classpath variable
If this is set correctly, you won't get the stub problems and you wont have to type in a absurdly long -D flag(ie none at all)
As for doing with a relative path I'm not sure that's possible but I may be wrong
Hope that helps a little
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sai Prasad
sounds like you can use codebase successfully if you use absolute path. But I use codebase successfully. It always throws ClassNotFoundException for the stubs. That means the Stubs never be downloaded successfully. Could you tell me your successful experience.
Thanks a lot.
Dasong
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i never get any problem after setting classpath.
ex.
set classpath=d:\scjd\starting;
my suncertify.db package is in d:\scjd\starting\suncertify\db
regards,
bhuvan.
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Before doing your final submission, just jar up all the client classes including the stubs -- this puts an end to all classpath problems. If you use ant or a development environment with a jar packager, you can easily keep the whole thing jarred up during development as well.
- Peter
 
Dasong
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I mean I run client and server code on different machine. no matter how I set codebase, the client never retrieve _Stub from server. Could guys give some ideas. Thanks
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys...I really need your help. I have been sucessfully developing and testing the application using the command below:
-------------------------------------------
D:\working\ver3.0\scjd\starting>java -Djava.rmi.server.hostname=localhost -Djava
.security.policy=java.policy -Djava.rmi.server.codebase=file:/D:\working\ver3.0\scjd\starting/ suncertify.server.FBNServer
---------------------------------------------
Now I am trying to get rid off the the "codebase" property while starting the server using the command below:
-------------------------------------------
D:\working\ver3.0\scjd\starting>java -Djava.rmi.server.hostname=localhost -Djava
.security.policy=java.policy suncertify.server.FBNServer
------------------------------------------
Here is my policy file:
------------------------------------------
grant {
permission java.net.SocketPermission "*:1024-65535",
"connect,accept";
permission java.io.FilePermission
"-", "read";
};
-------------------------------------------
I get the exception below:
------------------------------------------
ReservationEngine exception: RemoteException occurred in server thread; nested e
xception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
tion is:
java.lang.ClassNotFoundException: suncertify.server.FBNServer_Stub
java.rmi.ServerException: RemoteException occurred in server thread; nested exce
ption is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
tion is:
java.lang.ClassNotFoundException: suncertify.server.FBNServer_Stub
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:352
)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:207)
---------------------------------------------
I have been working on this for 5 hrs now. There is something obviously I am doing wrong. I am using Win2K Professional Edition and JDK1.4
Thanks a lot
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On any side client or Server do you have the following code. System.setSecurityManager(new RMISecurityManager())
I would assume you have it on the server side.
If you do, I just read in an earlier post today that Peter said that you do not need a SecurityManager if you aren't downloading Stubs, which I think all of us aren't.
I actually had one on the client side, becuase the one I tried on the Server side gave me the same Marshalling error that you got.
Hope that helps
Mark
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark,
Thanks for the reply. I do have
System.setSecurityManager(new RMISecurityManager())
at the server and client. Any other ideas? Thanks.
My server code fails during starup during the call to rebind() method. Thanks.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have not figured it out myself (I just started working at it) but I found a good article at JDC Tech Tips from February 27 2001 (developer.java.sun.com/developer/JDCTechTips/2001/tt0227.html) that looks promising.
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I will look in to it. Thanks.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, try removing it from the Server and see what happens. Just remarks that statement out.
Mark
 
Dasong
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,
Need your opinion.
1 both client and server data access object implement one interface DataAccessInterface which package should I put it. three solutions
a. create a common package contain it
suncertify.common.DataAccessInterface
b. put in suncertify.db because we have to put this package on both client and server side.
c. put in suncertify.server because we have to copy this package on both client and server side. the reason put the package in the client side is because we have to put server_Stub at client side
2.till now I'm blocked at download _Stub, so I have to put it at client side in its package suncertify.server.
client side I have to put all the three package suncertify.db,suncertify.server and suncertify.client
server side I put suncertify.db, suncertify.server
Dasong
[ April 15, 2002: Message edited by: Dasong ]
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd say the db package because it is access to the Database. The names are too similar. and it is used on both the server and the client. Put things that are only used on the server in the server package and not a data class. and put things that only the client uses in the client package.
Of course I should have practiced what I preach, and that is most likely the place where I lost points.
Mark
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good news...may be not that good.
After some research, I can come up with the solution below to start my server, rebind the server with out settting the java.rmi.server.codebase property.
My package dir structure starts from
D:\working\ver3.0\scjd\starting folder. Under this folder, I have suncertify\db, suncertify\server, etc...
Before I start rmiregistry, I need to change directory to D:\working\ver3.0\scjd\starting and issue the rmiregistry command. I know I am not supposed to do this becuase rmiregistry can find the class files with out using the codebase property.
But I cannot find anyway to start the server without using the java.rmi.server.codebase property during server startup.
Since this is a deployment issue, I bet everyone who passed the exam has done it this way. I like to hear the comments...please....
[ April 15, 2002: Message edited by: Sai Prasad ]
 
Dasong
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark
when I run java -jar client.jar
Got the error message as "Failed to load Main-Class manifest attribute from client.jar" . how did you do.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you include the manifest file? manifest.mf
here is what is in my client manifest

Hope that helps
Mark
 
Dasong
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,
How did you create or get the manifest file like that. I did get manifest. but it doesn't include Main-Class property.
[ April 15, 2002: Message edited by: Dasong ]
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pardon me for making this thread so long...
I think this explanation will clear up lot of deployment issues.
As for as this assignment is concerned, the spec given to me clearly prevents me to set the java.rmi.server.codebase property during server startup.
When the rebind call is made, the RMI server marshalls(serializes) the _Stub instance and send it over the wire to the RMI registry VM which in turn will try to create an instance of the stub. In order for the Registry to create an instance of the _Stub, it needs to load the Class using its ClassLoader. Since the RMI server sends null as the codebase property to Registry, the Registry VM is not able to load the _Stub class.
Having said that, the XXXX_Stub.class files need to be in the *rmiregistry* classpath. Putting the XXX_Stub.class files in the RMI server classpath will not help the rmiregistry to locate the files.
Therefore, when you create the server side jar file which contain the XXXX_Stub.class files, open a new console and before starting rmiregistry, issue the command set CLASSPATH=XXXXXXXXX.jar. Then start the rmiregistry.
Now you need to think about the marshalling of XXX_Stub instance from the rmiregistry to the client. Since rmiregistry located the XXX_Stub.class file in the local classpath, it will set the java.rmi.server.codebase property to null and marshall the XXX_Stub instance to the client. So the client.jar file now should have the XXX_Stub.class files bundled. This is what Peter has been saying for so long and now I got it. I hope this explanation will help others when you come to deployment.
Below is the eye opener:
RMI FAQ for JDK1.4
 
Dasong
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,
1.How did you create or get the manifest file like that. I did get manifest when I jar them. but it didn't include Main-Class property.
2.your suggestion please.
I cann't access db.db and userguide.html(for online help) when run client.jar
thanks
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dasong. I typed it. Meaning you have to create the manifest file through a text editor. Not the one that the jar command makes for you. You can also specifiy the path of your manifest file to your jar command. Here is my jar command.

as you can see the first part tell the jar command where I put my manifest file.
You know what Dasong, we shouldn't be hijacking this thread. If you have any more questions, put it in a new thread.
Mark
[ April 16, 2002: Message edited by: Mark Spritzler ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic