Version 11.1 by Henrique Prange on 2008/05/15 19:29

Show last authors
1 If you have used the [[woapplication-archetype]] to create your project, jump to the step 3.
2
3 You have to follow some instructions to build a true WAR package:
4
5 == Step 1: Create a web.xml file ==
6
7 You need to create a web.xml file. You can download a simple web.xml file [[here>>^web.xml]]. Don't forget to change the displayName and the WOMainBundle properties:
8
9 {{noformat}}
10
11 <web-app>
12 ...
13 <display-name>Your Application Name</display-name>
14 ...
15 <context-param>
16 <param-name>WOMainBundle</param-name>
17 <param-value>your-app-name</param-value>
18 </context-param>
19 ...
20 </web-app>
21
22 {{/noformat}}
23
24 == Step 2: Create/generate an Info.plist file ==
25
26 You also need to create or generate a valid Info.plist file into your resources folder. [[Here>>^Info.plist]] 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.
27
28 == Step 3: Package your classes, resources and webserver resources ==
29
30 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:
31
32 {{noformat}}
33
34 <build>
35 ...
36 <plugin>
37 <artifactId>maven-war-plugin</artifactId>
38 <configuration>
39 <archiveClasses>true</archiveClasses>
40 </configuration>
41 </plugin>
42 ...
43 </build>
44
45 {{/noformat}}
46
47 == Step 4: Add the required dependencies ==
48
49 You must add the following dependency to run the application as a true WAR:
50
51 {{noformat}}
52
53 <dependency>
54 <groupId>com.apple.webobjects</groupId>
55 <artifactId>JavaWOJSPServlet</artifactId>
56 <version>${woversion}</version>
57 </dependency>
58
59 {{/noformat}}
60
61 **NOTE**: If you are using WebObjects 5.2.x or 5.3.x you have to add this additional dependency:
62
63 {{noformat}}
64
65 <dependency>
66 <groupId>com.apple.webobjects</groupId>
67 <artifactId>JavaWOJSPServlet_client</artifactId>
68 <version>${woversion}</version>
69 </dependency>
70
71 {{/noformat}}
72
73 **NOTE**: if your application uses Wonder, please read [[this tutorial>>http://wiki.objectstyle.org/confluence/display/WONDER/Creating+a+wonder+app+to+deploy+as+a+servlet]].
74
75 == Step 5: Change the packaging type ==
76
77 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:
78
79 {{noformat}}
80
81 <packaging>war</packaging>
82
83 {{/noformat}}
84
85 It's done.
86
87 = Running your application as true WAR =
88
89 You can use the maven-jetty-plugin to run and test your application.
90
91 == Step 1: Configure the maven-jetty-plugin ==
92
93 Add the following configuration to your POM:
94
95 {{noformat}}
96
97 <build>
98 ...
99 <plugin>
100 <groupId>org.mortbay.jetty</groupId>
101 <artifactId>maven-jetty-plugin</artifactId>
102 </plugin>
103 ...
104 </build>
105
106 {{/noformat}}
107
108 == Step 2: Start the Jetty container with Maven ==
109
110 Just execute:
111
112 {{noformat}}
113
114 mvn clean jetty:run-war
115
116 {{/noformat}}
117
118 == Step 3: See the result ==
119
120 Open a browser and type the URL for your application like this: [[http://locahost:8080/your-app-name/WebObjects/]]