Packaging WO Applications as true WAR with Maven
If you have used the woapplication-archetype to create your project, jump to the step 3.
You have to follow some instructions to build a true WAR package:
Step 1: Create a web.xml file
You need to create a web.xml file. You can download a simple web.xml file here. Don't forget to change the displayName and the WOMainBundle properties:
Unknown macro: noformat. Click on this message for details.
Step 2: Create/generate an Info.plist file
You also need to create or generate a valid Info.plist file into your resources folder. Here is a sample Info.plist. You have to change the $your-app-name and $package occurrences with the respective application name and Application class package.
Step 3: Package your classes, resources and webserver resources
The application jar must follow the NSJarBundle format. The NSJarBundle is a package organized in Resources and WebServerResources folders. In addition, the Resources folder must contain a valid Info.plist file. Your application classes, resources and webserver resources must be package as a jar. It is easy to configure Maven to do this:
Unknown macro: noformat. Click on this message for details.
Step 4: Add the required dependencies
You must add the following dependency to run the application as a true WAR:
Unknown macro: noformat. Click on this message for details.
NOTE: If you are using WebObjects 5.2.x or 5.3.x you have to add this additional dependency:
Unknown macro: noformat. Click on this message for details.
NOTE: if your application uses Wonder, please read this tutorial.
Step 5: Change the packaging type
The default maven-war-plugin can handle the war packaging correctly. You have to change the packaging of your POM to 'war' in order to use this plug-in:
Unknown macro: noformat. Click on this message for details.
It's done.
2009 Bug Warning
It should be done, but...
The 2.0.17 archetype does not add :
{noformat}
<resource>
<targetPath>Resources</targetPath>
<directory>${basedir}/src/main/components</directory>
</resource>
{noformat}
to the pom.xml file, so your war will have no components; you should add these lines.
Also, it does not add a necessary WebObjects 5.3 dependency:
{noformat}
<dependency>
<groupId>${webobjects.groupId}</groupId>
<artifactId>JavaWOJSPServlet_client
</artifactId>
<version>${webobjects.version}</version>
</dependency>
{noformat}
So, you may need to add that.
In addition, the archetype generated Info.plist needs fixing, as does the web.xml in the WEB-INF folder. There are values in these files like $\{project.artifactId\}, but for now, you must manually replace those values with actual values, e.g, MyProject.
These probably will be fixed in the next release of plugins, but for now, watch this space, as there may be additional
bugs posted here.
Running your application as true WAR
You can use the maven-jetty-plugin to run and test your application.
Step 1: Configure the maven-jetty-plugin
Add the following configuration to your POM:
Unknown macro: noformat. Click on this message for details.
Step 2: Start the Jetty container with Maven
Just execute:
Unknown macro: noformat. Click on this message for details.
Step 3: See the result
Open a browser and type the URL for your application like this: http://locahost:8080/your-app-name/WebObjects/