File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Development nearing end ... docs next... but question. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Development nearing end ... docs next... but question." Watch "Development nearing end ... docs next... but question." New topic
Author

Development nearing end ... docs next... but question.

Richard denSeig
Ranch Hand

Joined: Apr 06, 2002
Posts: 32
Hi all,
I developed my assignment assumning we had to use the dynamic classloading...from some of the posts I think this is not required.
I read assign many times and assumed because of RMI requirement it was...
1. Is dynamic classloading required or expected?

-Richard
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

No.
How do you know that the assessor will have a web server? Isn't that needed to do dynamic downloading?
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Sai Prasad
Ranch Hand

Joined: Feb 25, 2002
Posts: 560
Richard:
It is not possible to load the _Stub dynamically for this assignment because
1) You don't have to use a HTTP server
2) You are not supposed to use a drive letter when you set the java.rmi.server.codebase property during server starup.
So you need to bundle the _Stub with the client files, no need to set the codebase property and set the _Stub.class in the CLASSPATH before starting the rmiregistry.
Richard denSeig
Ranch Hand

Joined: Apr 06, 2002
Posts: 32
Hi,
I am no expert, but http:// is not the only way to dynamically load classes...again, I am no expert - I may be mistaken.
When I run my rmiregistry, I set classpath=""...so I am relying entirely on codebase property and file:/// protocol for client to find what it needs.
This means I do need a security manager and policy file...otherwise, my project (in remote mode) will not execute.
Without security manager and policy file (with appropriate permissions), the classes the client requires cannot be downloaded (found): at least the exceptions I get lead me to believe this.
With security manager and policy file, all is well and runs like a top...is this not an indication of dynamic classloading?
Since my project requires an SM and permissions file to run properly, I am wondering how those who are using neither are getting theirs to work.

-Richard
Richard denSeig
Ranch Hand

Joined: Apr 06, 2002
Posts: 32
Hi Sai,
Where did you read that using a Drive letter (C:\... etc...) is not allowed...
Are you saying this is an FBN requirement?
The version of Java I am using does support drive letters...yours too, I'll bet...

-Richard
[ April 17, 2002: Message edited by: Richard denSeig ]
Richard denSeig
Ranch Hand

Joined: Apr 06, 2002
Posts: 32
Oh, (Mark and Sai ... or anyone) one more question...on the same general topic...
maybe I am reading too much into this but the FBN assignment (least the one I have) says that the only *allowed* parameters that can be passed on the command line are:
-DNS server name
-port
-data file name (I am assuming this is the db)
-codebase
-policy file
I know the word *allowed* here means that no others can be used, but it also implies command line options are *optional*...that is the developer need not develop for them at all.
If this is how others are interpreting this then I think I see how others are developing without using security and policy file...
Also, I checked with "Pitt and McNiff" and though I have found a number of RMI inaccuracies in their book, they do say that use of the codebase implies dynamic classloading...and this requires security manager and permissions file.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

What Sai and I are trying to let you know is to NOT use dynamic downloading.
You have to have a web server to do dynamic downlaoding and the assessor will not have a web server so your code will not work, and you will fail.
Hope that clears it up a bit
Mark
Richard denSeig
Ranch Hand

Joined: Apr 06, 2002
Posts: 32
Mark,
Let me ask this a different way...how are you interpreting the FBN requirement regarding commandline parameters...
How did you handle them...did you allow all parameters to be specified, some, or none...
Not to dwell, but, dynamic downloading does NOT require an http server...
Sai Prasad
Ranch Hand

Joined: Feb 25, 2002
Posts: 560
Richard,
I intrepret the requirement as "You can specify some or none of the parameters specified by SUN".
I agree that you can still dynamically download the _Stub using file:/// URL instead of http URL. But in order to use file URL, you need to specify absoulte path in the java.rmi.server.codebase property which is possible if you know the operating system and location of the directories.
You are not supposed to implement this assignment specific to an operating system or directory structure.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Ok. Actually it would be better for me to post part of my readme.

To run the server
1. run the following command
java -Drmi.security.policy=policy.all -jar server.jar

this starts the server and it's GUI.
----------------------------------------------------------------------------------------------------------
To run the client
1. to run in Local mode
a. run the following command
java -jar client.jar

OR


2. to run in Remote mode
a. run following command

java -Djava.security.policy=policy.all -jar client.jar {URL of Server}

make sure you add the URL location of the database in that call.
as an example

java -Djava.security.policy=policy.all -jar client.jar Localhost
or
java -Djava.security.policy=policy.all -jar client.jar 192.155.255.16

No my looking back ideas. In my Factory class that returns Remote or Local Implementation classes, I have an RMISecurityManager when they request Remote.
As you see in the above quote. I only had a policy file on the client when in Remote mode, and on the server. I did not need a policy file or the RMISecurityManager at all, since I did not dynamically download stubs. (See Peter's post in a previous thread this week). (Sure I'll just blame Peter. )
Hope that helps and actually answers your question this time
Mark
Richard denSeig
Ranch Hand

Joined: Apr 06, 2002
Posts: 32
Hello Sai and Mark,
I think the bulb begins to flicker...I understand the point about specific path required for codebase...I have had a lot of trouble with that...so, now I get it (in fact, if I had not been using that I would have been done 2 weeks ago...it is a very tricky thing)...so OK I got that!
I am finding it difficult to put into clear words what I am trying to ask...but, here goes...
1)I thought the point of providing the commandline args was to allow the SUN evaluator to hook up assignment to a "testing" database...maybe not right since some submissions will not allow commandline args...right?
2) But, now that I understand these commandline args are not required, I conclude the db.db that is jarred in each submission is only database the our code is supposed to link-up to (remote and local)...OK...right?
3) Also, when jarred, the SUN supplied Data class cannot read db.db...so I have had to create a method to read the compressed db.db...OK...right?
(Unless, on start my code un-jars the db.db...but, maybe that is not very elegant...).
4) Since commandline args are not required...and http dynamic downloading not available and file protocol dynamic downloading problematic and also out...why are 1)DNS 0r 2) port or 3)db.db given as (possilbe) variable args to start app?
5)Can I use a property file set up with what values I want so my program will perform and allow no user entered commandline args?
-Richard (still scratching head)
Richard denSeig
Ranch Hand

Joined: Apr 06, 2002
Posts: 32
Mark and Sai,
Ok, to answer my own question #4 from post above:

4) Since commandline args are not required...and http dynamic downloading not available and file protocol dynamic downloading problematic and also out...why are 1)DNS 0r 2) port or 3)db.db given as (possilbe) variable args to start app?

They server to tell the program wheather to start in local or remote mode...
No args, local...
DNS, Port, codebase, security mgr, -> remote...
But, I am still not sure about the point of providing another database name...
-Richard
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Hmmm. OK. Args are also used in program to have the RMI lookup go to the right machine. That is what the ip address is for.
OK, you don't need to jar the db.db file, or should I say in the client or server jar. It can be in the same directory outside the jars. that's how I did mine.
1. Right
2and 3 read above paragraph
4. You answered
5. Yes you can, but put in why you chose to in your design.txt. And What if the property file you give has the remote IP Address, and how will you know what the IP addess for the Assessor machine is?
Mark
Richard denSeig
Ranch Hand

Joined: Apr 06, 2002
Posts: 32
Hi Mark,
I appreciate the time you guys are taking to answer my questions.
About the submission, if db.db does not have to be jarred, does that mean that
1) client.jar and
2) server.jar
can be submitted as separate jars and not combined into one jar (assigment.jar)?
-Richard
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

No, you will combine all your files including those two jars into one big jar for submission. The assessor will then unjar the main submission jar to get all the files into one directory structure.
For example. He might create a directory named after your name, then he will unjar the big jar into that directory. And he will run your submission from there.
So when you make your submission jar, test it out by unjarring it in a new directory and see if your assignment runs.
Mark
Richard denSeig
Ranch Hand

Joined: Apr 06, 2002
Posts: 32
ahhhh....too many late nights I guess...
I am not blessed with access to a networked environment just now...I have been doing development on my machine...so, I have at most multiple VMs for running in remote mode...I just completely forgot that the point of RMI is not just different VMs, but machines as well...
Now, I also see the point in providing an alternate db name...
I see the light now...
thanks Mark...and Sai...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Development nearing end ... docs next... but question.