There are several ways you can run up the webapp.
The Naked Objects framework provides a simple bootstrapper class
that will run an embedded instance of Jetty against the
web.xml
. By default the reference to this
bootstrapper is deliberately excluded, so to use it comment back in
the reference to
org.nakedobjects.core:webserver
:
<dependency> <groupId>org.nakedobjects.core</groupId> <artifactId>webserver</artifactId> </dependency>
To run, just run
org.nakedobjects.webserver.WebServer
. This
takes the following arguments:
--deploymentType (defaults to SERVER)
--port (defaults to 8080)
--address (defaults to localhost)
--webapp resourceDirectory
For testing purposes you'll probably want EXPLORATION, which means you don't have to worry about authentication. For production you'll probably want SERVER, in which case you do need to decide how to handle authentication; but we'll discuss this more in Section 5.4, “Authentication”.
Using the maven-jetty-plugin, we can use Maven to run an embedded instance of Jetty. First, add:
<build> <plugins> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <configuration> <contextPath>/</contextPath> </configuration> </plugin> </plugins> </build>
Due to a bug in Restful Objects, it is
currently necessary to deploy to the root context
(/
).
Next, to run in EXPLORATION mode, update the
web.xml
:
<web-app> ... <context-param> <param-name>deploymentType</param-name> <param-value>EXPLORATION</param-value> </context-param> ... </web-app>
As we've already mentioned, for testing you'll probably want EXPLORATION, while for production you'll probably want SERVER. See Section 5.4, “Authentication” for more on this.
In case you were wondering,
NakedObjectsWebServer
(Section 5.3.1, “Using NakedObjectsWebServer”) does not currently honour
deploymentType setting.
You can then run Jetty from Maven using:
mvn jetty:run