Re: Using java packages with WebObjects and Xcode

Ray Kiddy <[email protected]>
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
On Jan 5, 2007, at 8:48 AM, Joshua Dubey wrote:

> Hi,
>
> I am creating a new web objects application using Xcode2.3.  I  
> would like to be able to use a proper package structure.   
> Specifically, I would like my Application class to be in a package,  
> e.g. com.mycompany.mypackage.
>
> I follow these steps:
>
> File->New Project
> Select WebObjects Application
> Use all defaults on other choices
> Open Application.java and add a package directive
> Build and Run
>
> Output as follows
>
> [Session started at 2007-01-05 08:46:58 -0800.]
> Reading MacOSClassPath.txt ...
> <snip>

>   /Library/WebObjects/Extensions/saaj.jar
>   /Library/WebObjects/Extensions/servlet.jar
>   /Library/WebObjects/Extensions/wsdl4j.jar
>   /Library/WebObjects/Extensions/
> Can't load Application class, exiting...
> java.lang.ClassNotFoundException: Application
> 	at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
> 	at com.webobjects._bootstrap.WOBootstrap.main(WOBootstrap.java:68)
>
> testproj2 has exited with status 1.
>
> Any ideas?
>
> Thanks,
>
> Josh

This is an artifact of how WO sets up the script that actually calls  
java to run your app.

The short answer is to double-click on the project target in your  
Xcode project (the top one), click on the Settings -> "Expert View"  
thing in the left-hand-side list. A list of key-value pairs will then  
appear. Click on "WOAPPLICATION_CLASS_NAME" and change the value to  
com.mycompany.mypackage.Application. You do not need double-quotes  
around this value.

(hint: also, googling "WOApplicationClass" does tell you something.)

The long answer is ... longer.

You can set arbitrary settings like this on the command line by  
executing the script with:

     MyApp.woa/MyApp - 
DWOAPPLICATION_CLASS_NAME=com.mycompany.mypackage.Application

<gripe> Why are some of the settings named such as  
WO_TEMPLATE_MAJOR_VERSION and this is WO without the underscore? No  
one knows. Do not ask.</gripe>

No, a longer answer would go into all the many ways in which trying  
to launch a java application in such a way that it looks like an  
application bundle as found in OpenStep is just too much to go into.

The executable script inside the woa is just a text file, so looking  
at that can be instructive.

- ray
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.