WARNING: you are not looking at the live version but at an older version.

Your first Cocoon application using Maven 2

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-M1 \
  -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-M1 -DgroupId=com.mycompany -DartifactId=myCocoonWebapp

The next step is changing into the myBlock directory and calling

mvn jetty: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-M4 \
  -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-M4 -DgroupId=com.mycompany -DartifactId=myBlock

The next step is changing into the myBlock directory and calling

mvn jetty:run

After that, you can point your browser to

http://localhost:8888

and you should get a success page.

Comments (4)