You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Marc Lustig <ma...@marclustig.com> on 2002/12/12 11:18:11 UTC

Setting up Maven-driven Turbine-webapp HOW-TO

Hi,

with my new Turbine-webapp I wanted to be as flexible as possible and
decided to use Maven and build a webapp from scratch instead of having
pre-built tdk-stuff around.
Also this decision was due to the fact that Maven is very actively developed
and there is a good chance to find assistance.
I went through various obstacles so it took me four weeks after all to get
started (I didn't know anything about Maven before.)
This is a summerize of the major steps that I did.
I hope it will encourage people to follow the same path.

Disclaimer:
Please note, this is just the way I did it!
There might be more efficient ways.


Creating a Maven-driven Turbine Web-Application
-----------------------------------------------

1) Getting started
- installing ant 1.4.1 (later versions should also work)
- get latest stable Maven-edition from cvs HEAD
- checkout jakarta-turbine-2  from CVS
- set MAVEN_HOME
- run jakarta-turbine-maven/>ant –f build-bootstrap.xml in
jakarta-turbine-maven/
	--> maven gets built and installed on the system
- build turbine
	--> run jakarta-turbine-2/>maven
	--> run jakarta-turbine-2/>maven site:generate

In order to proceed you have to switch to Maven-b7!
--> rename your Maven-dir or delete it
--> get Maven-1.0-b7 release build and unpack it, rename root-dir to
MAVEN_HOME


- create a root-directory for your webapp at a place of your choice, for
example "/foo-project/". This is the root-directory of your Maven-Project.
- copy content of
MAVEN_HOME\plugins\maven-examples-plugin-1.1-SNAPSHOT\simple-webapp\
to
foo-project/
- edit foo-project/project.xml according to the needs of your webapp
- create dirs
	src/java
	src/test
	src/schema
	src/webapp/WEB-INF
	src/webapp/WEB-INF/conf
	src/webapp/templates
	src/java/com/mycom/myproject/modules/actions
	src/java/com/mycom/myproject/modules/screens
- adjust your app-web.xml in src/webapp/WEB-INF/
- copy jakarta-turbine-2/conf/TurbineResources.properties to
src/webapp/WEB-INF/conf/ to have a basic Turbine-configuration

2) Integrating Torque
- install Torque-plugin for maven as explained at
http://jakarta.apache.org/turbine/torque/maven-howto.html
- add Torque settings to foo-project/project.properties according to the
howto
--> set database-access
- add dependencies to to foo-project/project.xml according to the howto
- put Torque.properties to src/webapp/WEB-INF/conf
- put id-table-schema.xml into src/java/schema/
- put turbine-schema.xml into src/java/schema/
- put project-schema.xml into src/java/schema/

Your are now ready to create your project-schema.xml OM-modell. Once you
have done this you can run "maven torque:main" or any other torque:goal.
If you get an error, the torque-plugin that you deployed to Maven is
corrupt.
Try using latest Torque release-build and redeploy the plugin.
If you still get an error, contact the torque-dev-list ;-)

3) Building your webapp
Before you can build your webapp you need to add a few thing to your
project.xml:
First put this into all of your existing <dependency> entries that you added
before:

			<properties>
				<war.bundle.jar>true</war.bundle.jar>
			</properties>

Then, add these dependencies.

		<dependency>
			<id>turbine</id>
			<version>2.2</version>
			<properties>
				<war.bundle.jar>true</war.bundle.jar>
			</properties>
		</dependency>
		<dependency>
			<id>torque</id>
			<version>3.0</version>
			<properties>
				<war.bundle.jar>true</war.bundle.jar>
			</properties>
		</dependency>
		<dependency>
			<id>mysql-connector-3</id>
			<jar>mysql-connector-java-3.0.0-beta-bin.jar</jar>
			<properties>
				<war.bundle.jar>true</war.bundle.jar>
			</properties>
		</dependency>
		<dependency>
			<id>ecs</id>
			<version>1.4.1</version>
			<properties>
				<war.bundle.jar>true</war.bundle.jar>
			</properties>
		</dependency>
		<dependency>
			<id>xmlrpc</id>
			<version>1.2-a1</version>
			<properties>
				<war.bundle.jar>true</war.bundle.jar>
			</properties>
		</dependency>
		<dependency>
			<id>flux</id>
			<version>2.2</version>
			<properties>
				<war.bundle.jar>true</war.bundle.jar>
			</properties>
		</dependency>


Make sure to have this entry in your project.properties:
"maven.war.src=src/webapp"

Run "foo-project/> maven java:jar war:webapp" to your webapp and find it
under target/

Generelly:
--> foo-project/src/ is where you put your files,
--> foo-project/target/ is maven's scratch place to build things you ask for
(quoted from somone who helped me)

So, put everything you want in your war under src/webapp ( like images/
templates/ etc ) classes and jars will be pulled from the correct locations
and everything else is gotten from src/webapp and packaged up nicely for you
in a war or in target/ (again quoted.)

4) setting up Tomcat and deploying your webapp
If you use a recent Tomcat-edition (4.1.12 for example) you have to
uncomment SSI and CGI entries in conf/web.xml. (see RELEASE-NOTES-4.1.txt in
tomcat/)

If you use Linux you can symlink your webapp to tomcat, otherwise you need
to copy it from target/ to tomcat/webapps/.

Start your tomcat.
Check in tomcat/logs/ for errors. If you get errors you might need to add
additional dependencies.
Then check webapps/foo-project/logs/turbine.log whether Turbine has started
up successfully.

Finally you can run your webapp. The url depends on your web.xml config.
If you like a short URL you might want to rename your foo-project to ROOT.
(not in your project! only in tomcat/webapps/)
You will then be able to access your webapp this way:
server:8080/foo-project.

Voila!
You should see now the Flux-screen.
You are ready to actually start developing your webapp!

Enjoy!

Note: Once I switched to Maven b7, I have been unable to build either torque
or turbine from cvs HEAD using this maven-installation anymore, but after
all I don't care anymore about that, as long as my webapp works.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


AW: Setting up Maven-driven Turbine-webapp HOW-TO

Posted by Marc Lustig <ma...@marclustig.com>.
> > <Context path="/freya" docBase="E:/src/Wisdom/freya/target/freya"
> > debug="0"/>
> 
> That's a nice idea, however when I use this, instead of the 
> webapp, only the
> index.html from target/myproject/ is being loaded:


Oops, sorry, correction. If you don't add the slash at the end it works. 

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Setting up Maven-driven Turbine-webapp HOW-TO

Posted by Age Mooy <am...@home.nl>.
> > The much easier way is to create a <Context> in tomcat's server.xml 
> > conf file that points to your webapp dir. That way your webapp is 
> > always deployed and you don't have to manually copy your changes to 
> > tomcat al the time. See the Tomcat docs for more details 
> but here's my 
> > entry:
> >
> > <Context path="/freya" docBase="E:/src/Wisdom/freya/target/freya"
> > debug="0"/>
> 
> That's a nice idea, however when I use this, instead of the 
> webapp, only the index.html from target/myproject/ is being 
> loaded: In my app-web.xml I have this:
> 
> 	<servlet-mapping>
> 		<servlet-name>audiotex</servlet-name>
> 		<url-pattern>/audiotex</url-pattern>
> 	</servlet-mapping>
> 
> So, url /audiotex/audiotex should work, but it doesn't.
> Idea?

I don't have a lot of experience with servlet-mappings. I use the
turbine standard web.xml that looks like this:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN" "http://java.sun.com/j2ee/dtds/web-app_2.3.dtd">

<web-app>
  <servlet>
    <servlet-name>starter</servlet-name>
    <servlet-class>org.apache.turbine.Turbine</servlet-class>

    <init-param>
      <param-name>properties</param-name>
      <param-value>/WEB-INF/conf/Turbine.properties</param-value>
    </init-param>
  </servlet>
</web-app>

In tomcat 4.1.12 this means that you have to enable the invoker servlet,
resulting in a URL like this:

http://localhost:8080/freya/servlet/starter

No doubt you can setup the web.xml to use a servlet mapping for the
turbine servlet... check the servlet spec for info I would say.

Age



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


AW: Setting up Maven-driven Turbine-webapp HOW-TO

Posted by Marc Lustig <ma...@marclustig.com>.

> -----Ursprüngliche Nachricht-----
> Von: Age Mooy [mailto:amooy@home.nl]
> Gesendet: Donnerstag, 12. Dezember 2002 11:38
> An: 'Turbine Users List'
> Betreff: RE: Setting up Maven-driven Turbine-webapp HOW-TO
>
>
>
> > 4) setting up Tomcat and deploying your webapp
> > If you use a recent Tomcat-edition (4.1.12 for example) you
> > have to uncomment SSI and CGI entries in conf/web.xml. (see
> > RELEASE-NOTES-4.1.txt in
> > tomcat/)
> >
> > If you use Linux you can symlink your webapp to tomcat,
> > otherwise you need to copy it from target/ to tomcat/webapps/.
>
> The much easier way is to create a <Context> in tomcat's server.xml conf
> file that points to your
> webapp dir. That way your webapp is always deployed and you don't have
> to manually copy your changes to tomcat al the time. See the Tomcat docs
> for more details but here's my entry:
>
> <Context path="/freya" docBase="E:/src/Wisdom/freya/target/freya"
> debug="0"/>

That's a nice idea, however when I use this, instead of the webapp, only the
index.html from target/myproject/ is being loaded:
In my app-web.xml I have this:

	<servlet-mapping>
		<servlet-name>audiotex</servlet-name>
		<url-pattern>/audiotex</url-pattern>
	</servlet-mapping>

So, url /audiotex/audiotex should work, but it doesn't.
Idea?

Marc


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Setting up Maven-driven Turbine-webapp HOW-TO

Posted by Age Mooy <am...@home.nl>.
> 4) setting up Tomcat and deploying your webapp
> If you use a recent Tomcat-edition (4.1.12 for example) you 
> have to uncomment SSI and CGI entries in conf/web.xml. (see 
> RELEASE-NOTES-4.1.txt in
> tomcat/)
> 
> If you use Linux you can symlink your webapp to tomcat, 
> otherwise you need to copy it from target/ to tomcat/webapps/.

The much easier way is to create a <Context> in tomcat's server.xml conf
file that points to your
webapp dir. That way your webapp is always deployed and you don't have
to manually copy your changes to tomcat al the time. See the Tomcat docs
for more details but here's my entry:

<Context path="/freya" docBase="E:/src/Wisdom/freya/target/freya"
debug="0"/>

The above cause tomcat to map /freya directly to my target/freya dir.

Age



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>