Executive summary - what's the officially sanctioned way of getting
launch arguments, whether supplied on the command line (java ...) or
when executing a java app within XCode?
Details: I have a java tool that populates a MySQL databases
presented to clients via WebObjects. Various parameters are supplied
to the tool as launch arguments (= command line arguments). It ran
fine when first written a year or two ago, but with the current
version of WO (5.2.3) crashes with the error message
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at
com.webobjects.foundation.NSProperties.setPropertiesFromArgv(NSProperties.java:395)
at fmpToMySQL.main(fmpToMySQL.java:77)
Caused by: java.lang.NullPointerException
at
com.webobjects.foundation.NSBundle.LoadUserAndBundleProperties(NSBundle.java:640)
at
com.webobjects.foundation.NSBundle.<clinit>(NSBundle.java:367)
... 4 more
A minimal test program that duplicates this behaviour looks like this:
import java.util.*;
import com.webobjects.foundation.*;
public class TestLaunchArguments {
private static Properties props;
public static void main ( String args[] ) {
NSProperties.setPropertiesFromArgv( args );
props = System.getProperties();
String argString = props.getProperty("test");
if( argString == null ) {
System.out.println( "Couldn't find -test <argument>" );
} else
System.out.println( "-test " + argString );
}
}
I can still get my java tool to run by packaging it with the WO jar
files I used at the time I wrote it, but as I say it crashes when run
with the current release of WebObjects.
Although most of NSProperty's methods are now deprecated, it's clear
that I need the NSProperties.setPropertiesFromArgv() call to get
launch arguments merged with the system properties (or a call to
something something...) - the arguments don't show up in args,
whether run from XCode or directly from a shell via java... .
In the Java tool (ie not in the test app above), if I hardwire in the
various parameters and comment out the
NSProperties.setPropertiesFromArgv() call, I get the same error
message a bit later in the program while executing an EO method.
Perhaps some piece of EO is looking for a property file that doesn't
exist, or is finding one I'm unaware of that contains bad content?
I've poked around extensively in Apple's documentation, in various
mailing lists, and with google, but not found anything useful.
If this IS the right way for java code to get its hands on launch
arguments in OS X, can someone tell me what I'm doing wrong or what
com.webobjects.foundation is looking for?
If it's NOT the right way for java code to get its hands on launch
arguments in OS X, I'd be infinitely grateful if someone could tell
me what I *should* be doing. A pointer to documentation I've missed
would be great, but preferably documentation that doesn't leave out
essential details :-)...
Thanks in advance,
john beaty
-- ------------------------------ Prof. John C. Beatty School of Computer Science University of Waterloo 200 University Avenue Waterloo, Ontario Canada N2L 3G1 +1 (519) 888-4567 x 4525 voice +1 (519) 885-1208 fax
This archive was generated by hypermail 2.0.0 : Thu Jan 27 2005 - 12:11:01 EST