cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robin Rigby" <ro...@gondolier.org.uk>
Subject Tutorial and Tomcat deployment
Date Tue, 17 Nov 2009 16:38:23 GMT
Suffering great frustration deploying Cocoon 2.2 to Tomcat.   Reverted to
the tutorial to check the basics.  Hope following notes will help someone
else avoid pain.

Robin

- SUMMARY -------------------

A. Tutorial page 1.  Welcome page has a link to spring bean 
which fails if called from

  http://localhost:8888/myBlock1

but succeeds when called from   
 
  http://localhost:8888/myBlock1/
  
Link is not properly fixed up.  See #2 below.
  
B. Tutorial page 4. Parent POM fails to compile myCocoonWebapp.
Cannot find correct version of maven-war-plugin.  Solutions found 
on mailing list do not work.  See #5 below.

C. <servlet:context/@mount-path="" ...> is not sufficient to mount
the web app as ROOT in Tomcat.  The war file must be ROOT.war
(or the app must be deployed with a context fragment from
elsewhere in the file system).  See #7 below.

D. <finalName>ROOT</finalName> is not sufficient to mount
the web app as ROOT in Jetty.  Change <webAppSourceDirectory/>.  
See #9 below.

E. Tomcat does not unpack ROOT.war if there is a context 
fragment ROOT.xml.  Check and remove the conflicting file.
See #10 below.

F. <finalName>ROOT</finalName> is not sufficient to deploy
the web app as ROOT in Tomcat with tomcat-maven-plugin.  
Add context path. See #12 below.  

- START ----------------------

1.  Create new tutorial blocks

  {...}/myBlock1
  {...}/myBlock2

from 

  http://cocoon.apache.org/2.2/1159_1_1.html
  http://cocoon.apache.org/2.2/1290_1_1.html
  http://cocoon.apache.org/2.2/1291_1_1.html

2.  Run under Jetty + rcl

  cd {...}/myBlock1
  mvn compile jetty:run

browse to 

  http://localhost:8888/myBlock1/

works fine                      <--- OK

But note that 

  http://localhost:8888/myBlock1

works OK (without trailing slash) but then the
link to the Spring bean fails

  http://localhost:8888/spring-bean   <--- FAIL

instead of

  http://localhost:8888/myBlock1/spring-bean

This is not good on page one of the tutorial.

3.  Add webapp block and parent POM

  {...}/myCocoonWebApp
  {...}/pom.xml

from 

  http://cocoon.apache.org/2.2/1362_1_1.html

4.  Run under Jetty + war file

  cd {...}/myBlock1
  mvn install
  cd {...}/myBlock2
  mvn install
  cd {...}/myCocoonWebApp
  mvn package jetty:run

browse to 

  http://localhost:8888/

works fine                      <--- OK

5.  Reactor build from parent POM

  cd {...}
  mvn install

Build fails with           <-- FAIL

  Internal error in the plugin manager 
    executing goal 'org.apache.maven.plugins:maven-war-plugin:2.0.2:war': 
    Unable to find the mojo
'org.apache.maven.plugins:maven-war-plugin:2.0.2:war' 
    in the plugin 'org.apache.maven.plugins:maven-war-plugin'
  Component descriptor cannot be found in the component repository: 
 
org.apache.maven.plugin.Mojoorg.apache.maven.plugins:maven-war-plugin:2.0.2:
war.

This has been an unsolved problem since I first tested Cocoon 2.2.  There
are two 
issues here:  

  i.  The tutorial fails [on my machine] despite the standardisation offered
by Maven.
  ii. The requested plugin is not found in the (any?) repository.

6.  There two solutions at

  http://issues.apache.org/jira/browse/COCOON-2240

Neither one works.  The second solution changes the version number in the
above 
message from 2.0.2 to 2.1-beta-1.

7.  Work around.  Go back to 4 above and copy

  myCocoonWebApp-1.0.0.war

to {tomcat 5.5.20}/webapps. Browse to

  http://localhost:8080/           <-- FAIL

Get error 404 from Tomcat.  But browse to

  http://localhost:8080/myCocoonWebApp-1.0.0/

and it finds the page.  Tomcat ignores the servlet:context/@mount-path="" 
attribute in block-servlet-service.xml

8.  Rename the WAR file ROOT.xml by setting 

  <finalName>ROOT</finalName>

in the POM for myCocoonWebApp.  See

  http://mojo.codehaus.org/tomcat-maven-plugin/usage.html

9.  Test with

  cd {...}/myCocoonWebApp
  mvn clean install jetty:run

This fails with          <-- FAIL

  Webapp source directory 
    {...}\myCocoonWebApp\target\myCocoonWebApp-1.0.0 
    does not exist

Maven has built a ROOT directory and ROOT.war but installed
myCocoonWebApp-1.0.0.war
in the repository (which could be OK).  Jetty has not recognized the
<finalName/>. 
Fix this by changing maven-jetty-plugin in 

  {...}/myCocoonWebApp/pom.xml

under

  <build>
    <plugins>
      <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>maven-jetty-plugin</artifactId>
        <version>6.1.7</version>
        <configuration>

change

 
<webAppSourceDirectory>${project.build.directory}/${pom.artifactId}-${pom.ve
rsion}</webAppSourceDirectory>

to

 
<webAppSourceDirectory>${project.build.directory}/ROOT</webAppSourceDirector
y>

Browse to

  http://localhost:8080/           <-- OK

10. Test by copying 

  ROOT.war 

to {tomcat 5.5.20}/webapps. Browse to

  http://localhost:8080/           <-- FAIL

and Tomcat has not unpacked ROOT.war, though it unpacked the other 
(see #7, above).

Restart Tomcat.  No mention of ROOT.war in {tomcat 5.5.20}/logs.

Check {tomcat 5.5.20}/conf/{engineName}/{hostName} for ROOT.xml.  Remove it.
Tomcat unpacks ROOT.war. Browse to

  http://localhost:8080/           <-- SUCCESS

11. OK, now remove ROOT.war and ROOT subdirectory from {tomcat
5.5.20}/webapps.
Log in to the Tomcat manager

  http://localhost:8080/manager/html

Deploy 

  {...}\myCocoonWebApp\target\ROOT.war

Browse to

  http://localhost:8080/           <-- OK

12. Again, remove ROOT.war and ROOT subdirectory from {tomcat
5.5.20}/webapps.
Add in 

  {...}/myCocoonWebApp/pom.xml

under

  <build>
    <plugins>

a new plugin

      <plugin>
	<groupId>org.codehaus.mojo</groupId>
	<artifactId>tomcat-maven-plugin</artifactId>
	<version>1.0-beta-1</version>
	<configuration>
	  <url>http://localhost:8080/manager</url>
          <server>tomcat-local</server>
        </configuration>
      </plugin>

Set up the server tomcat-local in your Maven settings file

  {userHome}/.m2/settings.xml

under

  <settings> 
    <servers>
 
a new server

      <server>
        <id>tomcat-local</id>
        <username>uname</username>
        <password>pwd</password>
      </server>

All as given at

  http://mojo.codehaus.org/tomcat-maven-plugin/usage.html

Deploy with

  cd {...}/myCocoonWebApp
  mvn tomcat:deploy

Browse to

  http://localhost:8080/           <-- FAIL

The plugin has ignored <finalName/>.  Maven has again built a 
ROOT directory and ROOT.war but installed myCocoonWebApp.war
which works fine but is not required.

Browse to

  http://localhost:8080/myCocoonWebApp/       <-- OK but not useful

Add the context path

      <server>
        <id>tomcat-local</id>
        <username>uname</username>
        <password>pwd</password>
        <path>/ROOT</path>
      </server>

Redeploy with

  mvn tomcat:redeploy

Browse to

  http://localhost:8080/           <-- QED

- END -----------
   





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message