Getting started with your Cocoon 2.2 based project
A typical Cocoon application is divided into several projects: the web application and the used blocks. For your own project you need a web application project which depends on all the used blocks. If you want to split up your application into different units, you might want to create your own blocks.
The simplest way to start your own Cocoon 2.2 based project is using the provided Maven 2 archetypes creating a skeleton for your project.
Creating a web application project
The cocoon webapp archetype creates a Maven 2 webapp project for you containing
- a skeleton web.xml
- a cocoon.xconf
Make sure that you have Maven 2.0.4 or above installed and then enter following command:
mvn archetype:create \ -DarchetypeGroupId=org.apache.cocoon \ -DarchetypeArtifactId=cocoon-22-archetype-webapp \ -DarchetypeVersion=1.0.0-SNAPSHOT \ -DgroupId=com.mycompany \ -DartifactId=myBlock \
once again for copy and paste without line feeds:
mvn archetype:create -DarchetypeGroupId=org.apache.cocoon
-DarchetypeArtifactId=cocoon-22-archetype-webapp
-DarchetypeVersion=1.0.0-SNAPSHOT -DgroupId=com.mycompany
-DartifactId=myBlock
The next step is changing into the myBlock directory and calling
mvn jetty6:run
After that, you can point your browser to
http://localhost:8888
and you should get a success page.
Creating a block project
The simplest way to start your own Cocoon 2.2 based project is using a Maven 2 archetype, that creates a block skeleton for you. It only contains a
- minimal sitemap
- a Flowscript that uses a Spring bean
- a view pipeline that uses JXTemplate to display values form the bean
Make sure that you have Maven 2.0.4 or above installed and then enter following command:
mvn archetype:create \ -DarchetypeGroupId=org.apache.cocoon \ -DarchetypeArtifactId=cocoon-22-archetype-block \ -DarchetypeVersion=1.0.0-M3 \ -DgroupId=com.mycompany \ -DartifactId=myBlock \
once again for copy and paste without line feeds:
mvn archetype:create -DarchetypeGroupId=org.apache.cocoon
-DarchetypeArtifactId=cocoon-22-archetype-block -DarchetypeVersion=1.0.0-M3
-DgroupId=com.mycompany -DartifactId=myBlock
The next step is changing into the myBlock directory and calling
mvn cocoon:deploy jetty6:run
After that, you can point your browser to
http://localhost:8888
and you should get a success page.

http://localhost:8888/spring-bean
instead of
http://localhost:8888/myBlock1/spring-bean
Starting from version 7.0.1 Maven is supported. You can import the pom.xml directly into Idea. For a quick start: import the pom file and create a run/debug configuration and enter as goal "jetty:run" and hit the "run" button.
NOT work because a lot of dependencies haven't been
downloaded yet. When using the command: "mvn org.mortbay.jetty:maven-jetty-plugin:run", maven will
download all necessery dependencies first. After that,
the simple command will suffice.
But if I browse to http://localhost:8888/myBlock1/, with a trailing slash, the spring-bean link is http://localhost:8888/myBlock1/spring-bean (OK).