struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Cushing <jimo...@mac.com>
Subject Re: ant, maven and creating war's
Date Wed, 29 Aug 2007 17:20:24 GMT
I haven't touched Ant in years, so I can't help you much there, but  
with Maven 2, it's as simple as running 'mvn package'. The POM itself  
says whether the project produces a JAR, WAR, or some other artifact,  
so package always builds the appropriate artifact for the project.  
For a web app, that is of course a WAR, for something else, it may be  
a JAR.

For development, you might want to try using Jetty instead of Tomcat,  
because Maven 2 has a plugin that makes this really simple. Add the  
following to your POM:

     	<plugins>
     		<plugin>
     			<groupId>org.mortbay.jetty</groupId>
     			<artifactId>maven-jetty-plugin</artifactId>
     			<version>6.1.5</version>
     			<configuration>
     				<scanIntervalSeconds>10</scanIntervalSeconds>
		          <connectors>
		            <connector  
implementation="org.mortbay.jetty.nio.SelectChannelConnector">
		              <port>7171</port>
		            </connector>
		            </connectors>
     			</configuration>
     		</plugin>
     	</plugins>

You can set the port to whatever you want (7171 in this example),  
just make sure it doesn't conflict with anything else you have running.

Then, run 'mvn jetty:run', and a Jetty server will fire up. Nothing  
to install.

Go to http://localhost:7171/ in a browser, and you'll see a link to  
your application.

Now, the really fun part begins: Make changes to your application.  
Edit your pages, your actions, and your configuration, and Jetty will  
pick up those changes without you having to rebuild. Changes to your  
Java code or configuration will cause Jetty to restart your web app,  
automatically, though it may take several seconds. Page changes, of  
course, are picked up without a restart.

Sometimes, I'll find that Jetty does hang on me and ctrl-c won't kill  
the maven/jetty process. If that's the case, just hit ctrl-z to put  
it in the background, 'ps' to get the PID, and 'kill -9 <pid>' to  
force it to quit. Run 'mvn jetty:run' again. But even if you find  
that happening to you 2-4 times a day, it's so much faster than  
WARing it up and pushing it to Tomcat. Plus, anyone on your team can  
use this same command, as they don't have to install or configure  
Tomcat.

On Aug 29, 2007, at 12:07 PM, sp4rc wrote:

> Hello listmembers,
>
> I am new to all this java webapplication stuff, but I hope you can  
> help
> me to get into this great technologies.
>
> So far I have got my tomcat server (5.5.23-r6) up and runnig,
> struts-2.0.9 is on my system (gentoo-linux) and I was able to  
> deploy the
> sample war "blank" ([1] tree output). Now I would like to follow the
> struts tutorial [2] and create my own war file from scratch...
>
> But the problem is, that simply don't know how to create a war file
> using ant or even maven. Can you point me to the right direction?
>
> What is this MANIFEST.MF about?
>
> Does ant or maven compile any sourcecode, or is it just packin the  
> files
> and the servlet-container compiles the first time it gets run?
>
> How does the filestructure of my sources have to look like befor using
> [ant|maven]?
>
> Regs
> /sp4rc
>
> [1]
> /var/lib/tomcat-5.5/webapps/struts2-blank-2.0.9
> |-- META-INF
> |   |-- MANIFEST.MF
> |   `-- maven
> |       `-- org.apache.struts
> |           `-- struts2-blank
> |               |-- pom.properties
> |               `-- pom.xml
> |-- WEB-INF
> |   |-- classes
> |   |   |-- LICENSE.txt
> |   |   |-- NOTICE.txt
> |   |   |-- example
> |   |   |   |-- ExampleSupport.class
> |   |   |   |-- HelloWorld.class
> |   |   |   |-- Login-validation.xml
> |   |   |   |-- Login.class
> |   |   |   |-- package.properties
> |   |   |   `-- package_es.properties
> |   |   |-- example.xml
> |   |   `-- struts.xml
> |   |-- lib
> |   |   |-- commons-logging-1.0.4.jar
> |   |   |-- freemarker-2.3.8.jar
> |   |   |-- ognl-2.6.11.jar
> |   |   |-- struts2-core-2.0.9.jar
> |   |   `-- xwork-2.0.4.jar
> |   |-- src
> |   |   `-- java
> |   |       |-- LICENSE.txt
> |   |       |-- NOTICE.txt
> |   |       |-- example
> |   |       |   |-- ExampleSupport.java
> |   |       |   |-- HelloWorld.java
> |   |       |   |-- Login-validation.xml
> |   |       |   |-- Login.java
> |   |       |   |-- build.bat
> |   |       |   |-- package.properties
> |   |       |   `-- package_es.properties
> |   |       |-- example.xml
> |   |       `-- struts.xml
> |   `-- web.xml
> |-- example
> |   |-- HelloWorld.jsp
> |   |-- Login.jsp
> |   |-- Menu.jsp
> |   |-- Missing.jsp
> |   |-- Register.jsp
> |   `-- Welcome.jsp
> `-- index.html
>
> [2] http://struts.apache.org/2.x/docs/simple-setup.html
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message