Assignment 5 FAQ, Errata, and Addenda
Last update: Saturday, April 12, 2008 21:02 EDT
- I cannot run rmic on remus.
- Add /usr/local/java/bin to your PATH environment or run /usr/local/java/bin/rmic.
-
When I run the demo program and pass the arg,
"this is just a test", it actually treats each of the words in that single string as separate. So instead of printing:tset a tsuj si sihtit prints:
siht si tsuj a tset - The java environment on remus (and possibly other machines) is seriously messed up. /usr/local/bin/java is a buggy c-shell script that not only doesn't handle arguments properly but also somehow messes up the resolution of localhost. Use /usr/local/java/bin/java to run your programs. It's still a buggy ksh script but seems to work ok in this case.
- I'm getting a java.lang.ClassNotFoundException: Sample_Stub exception.
-
There are two things you should check:
- Make sure that your CLASSPATH includes the directory where the stub file(s) live when running the rmiregistry.
- If you start your rmiregistry on a different port than the default 1099, make sure that your server and client are modified appropriately to access that port and that you're not connecting to somebody else's instance of rmiregistry that is listening on another port.
- Are we expected to use regular expressions to scrape the info? Or do you think that would make it easier (or harder).
- You don't need to use regular expressions. I'm honestly not sure if it will make your job a lot easier but it might make it a bit easier if you're comfortable with regex patterns.
- Does java have nice command line parsing libraries? Only ones I see online are either open source or something someone threw together... it's odd that java doesn't have a library to do this (that I know of).
- I don't know of any nice command line parsing libraries but I've never searched for them. I've always done my own work of iterating through the arg list. It might be lame but it was quick and dirty. See this example.
-
Under the scraping server section, it states that the wind direction
variable should be a String, but later on, in the
weatherinfo.javafile, you havewind_diras an integer. I think you meant for both of them to be strings. - Correct. They should be Strings.
- More corrections
-
In WeatherInterface.java, it is necessary to add an import,
import java.io.Serializable;. Same goes forweatherinfo.java.In
WeatherInterface.java, it is not necessary to import weatherinfo, since weatherinfo is just in the current directory. -
When you tell us not to modify
weatherinfo.javaorWeatherInterface.java, does that mean we shouldn't submit them in the tar file? Is there a reason we aren't allowed to change anything? I know it's not necessary to change anything, but I did change the import statements to get stuff to compile. I am also gonna add comments, but if we shouldn't submit them, that would be unnecessary. - You can modify the import statements. I just don't want the basic data structure and calling interface to be changed. If you modified anything then submit the modified files.
- I get a Sample server failed:access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve) error.
-
Again, there are a couple of things to check:
- check that you have an rmiregistry running
- check that you have the policy file in the directory where you are running java -Djava.security.policy=policy SampleServer
- How do I set a CLASSPATH?
-
If you're using bash, ksh, or sh, set it via:
CLASSPATH=$CLASSPATH:/ug/u0/pxk/src/rmihello export CLASSPATH
Where /ug/u0/pxk/src/rmihello is replaced with the directory where your files live. Alternatively, if you plan on starting all services from that directory, you can add . to the CLASSPATH instead of the full pathname to tell java to search the current directory. If you're using csh or tcsh, you can set a CLASSPATH via:setenv CLASSPATH /ug/u0/pxk/src/rmihello
- I want to run rmiregistry, the client, and the server on different machines. What files must I copy?
-
For the client, you need
SampleClient.class, SampleInterface.class, Sample_Stub.class.
For the server, you need Sample.class, SampleInterface.class, SampleServer.class, Sample_Stub.class, policy.
For rmiregistry, you need SampleInterface.class, Sample_Stub.class. - Does the rmiregistry have to run on the same machine as the server?
- Unfortunately, it does. You should use localhost as the hostname on your server. You will lose many points for using hard-coded names such as remus or eden or romulus.
- I know for the server end, when I type in the rmiregistry command, I can specify the port there, but how do I tell the client to connect to that port that I specify there?
-
In your client, you need to specify the host and port of the rmi registry when you do a lookup. This is a URI-named entity of the form rmi://hostname:port/interfacename (for example, rmi://localhost:4422/Weather). If :port is missing, the default is :1099. You'll have to construct this name on the fly.
In your server, you'll need to tell the server to bind to a particular rmi registry. This is done in a similar manner, where you will create a string containing the URI. For example: Naming.rebind("rmi://localhost:4422/Weather", new Weather())
- Should multiple clients connect to the rmi server ? In other words, do we have to make the server a multi-threaded one ?
- No, it need not be multi-threaded.
- I am having problems compiling when I use StringBuffer.indexOf method. When I compile, I get an error stating that indexOf(java.lang.String) not found in class java.lang.StringBuffer. It compiles file on my windows machine. But when I try to compile it on cereal/remus/romulus, I get the error.
- If you're not running at least jdk 1.4 then you won't get the feature. That need not be a problem for you. Just convert the StringBuffer to a String once you've read in all the data and then use indexOf on the String.
- Must I make sure that -h and -p flags are before the zip codes, if they are specified. If there are not before the zip codes, do I terminate the client?
- Yes. Just loop through the arguments and process the -h and -p ones first until you hit something that doesn't start with a '-'. Consider everything else to be a zip code. For each zip code, check if it's a 5-digit number. If it is, call the rmi function. Otherwise print an error for that data and continue on to the next one.
- I don't need import weatherinfo; in Weatherinterface.java.
- This is fine. If you're using Java version 1.4 or greater, then you don't need the import statement. If you're using an earlier version then you do.
-
I get this error when I run the SampleServer on remus:
Sample server failed:Unknown host: localhost; nested exception is: java.net.UnknownHostException: localhost - I believe this is due to the messed-up java environment on remus. (and possibly other machines). Use /usr/local/java/bin/java to run your programs.