Author: dan.j.allen
Date: 2009-04-23 21:05:09 -0400 (Thu, 23 Apr 2009)
New Revision: 2620
Added:
examples/trunk/tomcat/readme.txt
Modified:
examples/trunk/tomcat/WebContent/META-INF/context.xml
examples/trunk/tomcat/WebContent/WEB-INF/
examples/trunk/tomcat/pom.xml
Log:
add support for embedded Jetty, embedded Tomcat and standalone Tomcat
add instructions for doing Maven-based deployments
add configuration to prevent Tomcat from saving sessions across restarts
Modified: examples/trunk/tomcat/WebContent/META-INF/context.xml
===================================================================
--- examples/trunk/tomcat/WebContent/META-INF/context.xml 2009-04-24 00:37:22 UTC (rev
2619)
+++ examples/trunk/tomcat/WebContent/META-INF/context.xml 2009-04-24 01:05:09 UTC (rev
2620)
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Context>
+ <Manager pathname=""/> <!-- disables storage of sessions across
restarts -->
<Resource name="app/Manager"
auth="Container"
type="javax.inject.manager.Manager"
Property changes on: examples/trunk/tomcat/WebContent/WEB-INF
___________________________________________________________________
Name: svn:ignore
+ classes
lib
Modified: examples/trunk/tomcat/pom.xml
===================================================================
--- examples/trunk/tomcat/pom.xml 2009-04-24 00:37:22 UTC (rev 2619)
+++ examples/trunk/tomcat/pom.xml 2009-04-24 01:05:09 UTC (rev 2620)
@@ -8,21 +8,105 @@
<version>1.0.0-SNAPSHOT</version>
</parent>
- <groupId>org.jboss.webbeans.examples</groupId>
- <artifactId>webbeans-numberguess-tomcat</artifactId>
+ <artifactId>webbeans-servlet-numberguess</artifactId>
<packaging>war</packaging>
- <name>Web Beans Examples: Numberguess</name>
+ <name>Web Beans Numberguess Example (Servlet)</name>
+ <description>The Web Beans numberguess example for deployment to a servlet
container</description>
<pluginRepositories>
- <pluginRepository>
- <id>codehaus snapshot repository</id>
- <
url>http://snapshots.repository.codehaus.org/</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- </pluginRepository>
- </pluginRepositories>
+ <pluginRepository>
+ <id>codehaus snapshot repository</id>
+ <
url>http://snapshots.repository.codehaus.org/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </pluginRepository>
+ </pluginRepositories>
+ <build>
+ <finalName>${project.artifactId}</finalName>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-clean-plugin</artifactId>
+ <configuration>
+ <failOnError>false</failOnError>
+ <filesets>
+ <fileset>
+ <!-- clean up files from war:inplace -->
+ <directory>WebContent</directory>
+ <includes>
+ <include>WEB-INF/classes/**</include>
+ <include>WEB-INF/lib/**</include>
+ </includes>
+ <followSymlinks>false</followSymlinks>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <!-- don't stage or package files added to src/main/webapp by
war:inplace -->
+
<warSourceExcludes>WEB-INF/classes/**,WEB-INF/lib/**</warSourceExcludes>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>tomcat-maven-plugin</artifactId>
+ <configuration>
+ <path>/${project.build.finalName}</path>
+ <!-- uncomment to use server configuration override; see readme.txt for
details -->
+ <!--<server>tomcat</server>-->
+ <url>http://localhost:${tomcat.http.port}/manager</url>
+ <port>${embedded-tomcat.http.port}</port> <!-- port for
embedded Tomcat only (putting this configuration in the execution for the run goal
doesn't work) -->
+ <warSourceDirectory>WebContent</warSourceDirectory>
+ <!-- if you don't want to use war:inplace, use this path instead
-->
+ <!--
+
<warSourceDirectory>${project.build.directory}/${project.build.finalName}</warSourceDirectory>
+ -->
+ </configuration>
+ <dependencies>
+ </dependencies>
+ </plugin>
+
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <configuration>
+ <connectors>
+ <connector
implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+ <port>${jetty.http.port}</port>
+ <maxIdleTime>3600000</maxIdleTime>
+ </connector>
+ </connectors>
+ <scanIntervalSeconds>10</scanIntervalSeconds>
+ <webAppConfig>
+ <contextPath>/${project.build.finalName}</contextPath>
+ </webAppConfig>
+ <webAppSourceDirectory>WebContent</webAppSourceDirectory>
+ <!-- if you don't want to use war:inplace, use this path instead
-->
+ <!--
+
<webAppSourceDirectory>${project.build.directory}/${project.build.finalName}</webAppSourceDirectory>
+ -->
+ </configuration>
+ <dependencies>
+ </dependencies>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <properties>
+ <jetty.http.port>9090</jetty.http.port>
+ <jetty.debug.port>9190</jetty.debug.port>
+ <tomcat.http.port>8080</tomcat.http.port>
+ <embedded-tomcat.http.port>9090</embedded-tomcat.http.port>
+ <embedded-tomcat.debug.port>9190</embedded-tomcat.debug.port>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.testng</groupId>
@@ -60,17 +144,6 @@
<scope>runtime</scope>
</dependency>
- <!-- <dependency>
- <groupId>org.jboss.el</groupId>
- <artifactId>jboss-el</artifactId>
- <exclusions>
- <exclusion>
- <groupId>javax.el</groupId>
- <artifactId>el-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>-->
-
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-ri</artifactId>
@@ -89,10 +162,5 @@
</dependency>
</dependencies>
-
- <build>
- <finalName>webbeans-numberguess</finalName>
- </build>
-
+
</project>
-
Added: examples/trunk/tomcat/readme.txt
===================================================================
--- examples/trunk/tomcat/readme.txt (rev 0)
+++ examples/trunk/tomcat/readme.txt 2009-04-24 01:05:09 UTC (rev 2620)
@@ -0,0 +1,77 @@
+Web Beans Numberguess Example (Servlet Container)
+=================================================
+
+This example demonstrates the use of Web Beans in a Servlet container
+environment (Tomcat 6 / Jetty 6). No alterations are expected to be made to the
+Servlet container. All services are self-contained within the deployment.
+
+This example uses a Maven 2 build. Execute the following command to build the
+WAR. The WAR will will be located in the target directory after completion of
+the build.
+
+ mvn
+
+Now you are ready to deploy.
+
+== Deploying with an embedded servlet container
+
+Run this command to execute the application in an embedded Jetty 6 container:
+
+ mvn war:inplace jetty:run
+
+You can also execute the application in an embedded Tomcat 6 container:
+
+ mvn war:inplace tomcat:run
+
+In both cases, any changes to assets in WebContent take affect immediately. If
+a change to a webapp configuration file is made, the application may
+automatically redeploy. The redeploy behavior can be fined tuned in the plugin
+configuration (at least for Jetty). If you make a change to a classpath
+resource, you need to execute a build:
+
+ mvn compile war:inplace
+
+Note that war:inplace copies the compiled classes and JARs inside WebContent,
+under WEB-INF/classes and WEB-INF/lib, respectively, mixing source and compiled
+files. However, the build does work around these temporary files by excluding
+them from the packaged WAR and cleaning them during the Maven clean phase.
+These folders are also ignored by SVN.
+
+== Deploying to standalone Tomcat
+
+If you want to run the application on a standalone Tomcat 6, first download and
+extract Tomcat 6. This build assumes you will be running Tomcat in its default
+configuration, with a hostname of localhost and port 8080. Before starting
+Tomcat, add the following line to conf/tomcat-users.xml to allow the Maven
+Tomcat plugin to access the manager application, then start Tomcat:
+
+ <user username="admin" password=""
roles="manager"/>
+
+To override this username and password, add a <server> with id tomcat in your
+Maven 2 settings.xml file, set the <username> and <password> elements to the
+appropriate values and uncomment the <server> element inside the
+tomcat-maven-plugin configuration in the pom.xml.
+
+You can deploy the packaged archive to Tomcat via HTTP PUT using this command:
+
+ mvn package tomcat:deploy
+
+Then you use this command to undeploy the application:
+
+ mvn tomcat:undeploy
+
+Instead of packaging the WAR, you can deploy it as an exploded archive
+immediately after the war goal is finished assembling the exploded structure:
+
+ mvn compile war:exploded tomcat:exploded
+
+Once the application is deployed, you can redeploy it using the following command:
+
+ mvn tomcat:redeploy
+
+But likely you want to run one or more build goals first before you redeploy:
+
+ mvn compile tomcat:redeploy
+ mvn war:exploded tomcat:redeploy
+ mvn compile war:exploded tomcat:redeploy
+