Imixs Workflow ...the open source workflow technology

JSF Tools

Building an Archetype

The Imixs JSF Tools provide an example jsf application called "imixs-workflow-jee-archetype". This sample jee web application can be used as a template to build an Imixs JEE Workflow app. The sample application can be also use dot generate a maven archetype. The JSF Tool Project provides such an archetype at:

 org.imixs.workflow:imixs-workflow-jee-archetype

The following section contains informations about the build process of this archetype.

Note:
It is not necessary to generate a new archetype from the sample application. The following informations are for developers who want to generate this or a new archetype from the sample application. Please see the Using Archetypes if you want to start a sample workflow application.

Generating the Archetype from the sample application

To generate a new archetype from the imixs-workflow-jee-archetype project you can use the maven archetype plugin calling the 'create-from-project' goal. This goal will generate a new archetype skeleton into the target folder. To call the goal you should work with a maven console (mvn command) at the project folder from the sample application

>cd [project_home]
>mvn archetype:create-from-project

After the first generation some resources need to be modified manually in different file locations. The following section will describe the different files which need to be changed. All resource files to be modified are located under

 [project_home]/target/generated-sources/archetype/

archetype-metadata.xml

Add the following section to the beginning of the archetype-metadata.xml file to define new required variables. The file is located in

 [project_home]/target/generated-sources/archetype/src/main/resources/META-INF/maven

This vars are used later in different deployment descriptors to optimize the generated code out from the archetype.

 <requiredProperties>
        <requiredProperty key="jta-data-source">
                <defaultValue>jdbc/workflow</defaultValue>
        </requiredProperty>
        <requiredProperty key="realm">
                <defaultValue>imixsrealm</defaultValue>
        </requiredProperty>
        <requiredProperty key="context-root">
                <defaultValue>workflow</defaultValue>
        </requiredProperty>             
 </requiredProperties>

The 'jta-data-source' variable defines the JTA Data source used by the EJB module defined by the persistence.xml. The 'realm' variable is used in web.xml and sun-web.xml to define the security realm name used by the jee app. The 'context-root' variable defines the web context root where the application can be started using a web browser.

Additional the default variable 'rootArtifactId' is used in some cases described below.

pom.xml (parent module)

In the parent pom.xml the modules section should be added because it is not generated by the archetype plugin automatically. Add the following section to the generated pom.xml

....
        <modules>
                <module>${rootArtifactId}-ejb</module>
                <module>${rootArtifactId}-web</module>
                <module>${rootArtifactId}-ear</module>
        </modules>

pom.xml from EAR Module

The pom.xml file from the ear module needs to be modified to replace the module names like shown in the next example because the module names are still hard coded after the archetype generation:

.....
<modules>
        <webModule>
                <groupId>${groupId}</groupId>
                <artifactId>${rootArtifactId}-web</artifactId>
                <contextRoot>/${context-root}</contextRoot>
        </webModule>
        <ejbModule>
                <groupId>${groupId}</groupId>
                <artifactId>${rootArtifactId}-ejb</artifactId>
        </ejbModule>
.....

persistence.xml from EJB Module

The perstence.xml can be changed to use the jta-data-source variable:

<jta-data-source>${jta-data-source}</jta-data-source>

sun-ejb-jar.xml from EJB Module

In the sun-ejb-jar.xml ther are two changes necessary. First the EJB JNDI Names should be changed to generate unique names depending on the artifact name. And the realm variable should be used to change the realm names used by the web service definitions. Also the web Service endpoints should be change to use teh artifact name in the URI.

.....
        <!-- Imixs Workflow Service EJBs - JNDI Definition -->
        <ejb>
                <ejb-name>EntityServiceBean</ejb-name>
                <jndi-name> ejb/${rootArtifactId}EntityServiceBean </jndi-name>
        </ejb>
        <ejb>
                <ejb-name>ModelServiceBean</ejb-name>
                <jndi-name>ejb/${rootArtifactId}ModelServiceBean</jndi-name>
        </ejb>
        <ejb>
                <ejb-name>WorkflowServiceBean</ejb-name>
                <jndi-name> ejb/${rootArtifactId}WorkflowServiceBean
                </jndi-name>
        </ejb>
        <ejb>
                <ejb-name>ReportServiceBean</ejb-name>
                <jndi-name> ejb/${rootArtifactId}ReportServiceBean</jndi-name>
        </ejb>


        <!-- Imixs Workflow WebServices Definition -->
        <ejb>
                <ejb-name>ModelWebServiceBean</ejb-name>
                <jndi-name>ejb/${rootArtifactId}ModelWebServiceBean</jndi-name>
                <webservice-endpoint>
                        <port-component-name>WorkflowModelService</port-component-name>
                        <endpoint-address-uri>${rootArtifactId}WorkflowModelService</endpoint-address-uri>
                        <login-config>
                                <auth-method>BASIC</auth-method>
                                <realm>${realm}</realm>
                        </login-config>
                </webservice-endpoint>
        </ejb>
        <ejb>
                <ejb-name>WorkflowWebServiceBean</ejb-name>
                <jndi-name> ejb/${rootArtifactId}WorkflowWebServiceBean 
                </jndi-name>
                <webservice-endpoint>
                        <port-component-name> WorkflowManagerService </port-component-name>
                        <endpoint-address-uri> ${rootArtifactId}WorkflowManagerService 
                        </endpoint-address-uri>
                        <login-config>
                                <auth-method>BASIC</auth-method>
                                <realm>${realm}</realm>
                        </login-config>
                </webservice-endpoint>
        </ejb>
        <ejb>
                <ejb-name>ReportWebServiceBean</ejb-name>
                <jndi-name> ejb/${rootArtifactId}ReportWebServiceBean 
                </jndi-name>
                <webservice-endpoint>
                        <port-component-name> WorkflowReportService </port-component-name>
                        <endpoint-address-uri> ${rootArtifactId}WorkflowReportService 
                        </endpoint-address-uri>
                        <login-config>
                                <auth-method>BASIC</auth-method>
                                <realm>${realm}</realm>
                        </login-config>
                </webservice-endpoint>
        </ejb>
.....

Installing the modified archetype

After all changes are completed the new archetype can be installed locally. This step is only necessary to test the archetype. To install the archetype call simply the install goal from mvn. Currently it is not possible to use the eclipse embedded mvn plugin for this step.

>cd [project_home]/target/generated-sources/archetype  
>mvn install 

After a successful build you should see a message like this:

...generated-sources/archetype$ mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building imixs-workflow-jee-archetype-archetype
[INFO]    task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
[INFO] Setting property: velocimacro.messages.on => 'false'.
[INFO] Setting property: resource.loader => 'classpath'.
[INFO] Setting property: resource.manager.logwhenfound => 'false'.
[INFO] [archetype:jar]
[INFO] [archetype:add-archetype-metadata]
[INFO] [archetype:integration-test]
[INFO] [install:install]
[INFO] Installing /home/rsoika/eclipse/imixs-workflow/imixs-workflow-jee-archetype/target/generated-sources/archetype/target/imixs-workflow-jee-archetype-archetype-0.0.1-SNAPSHOT.jar to /home/rsoika/.m2/repository/org/imixs/workflow/imixs-workflow-jee-archetype-archetype/0.0.1-SNAPSHOT/imixs-workflow-jee-archetype-archetype-0.0.1-SNAPSHOT.jar
[INFO] [archetype:update-local-catalog]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Fri Oct 23 17:46:55 CEST 2009
[INFO] Final Memory: 12M/121M
[INFO] ------------------------------------------------------------------------

Create new Project

Now you can create a new Project form the generated and installed archetype. The maven archetype plugin will ask for group and archetypeID and also for the new defined variables.

mvn archetype:generate -DarchetypeGroupId=org.imixs.workflow -DarchetypeArtifactId=imixs-workflow-jsf-sample-archetype -DarchetypeVersion=0.0.1-SNAPSHOT

To generate the new artifact from the local catalog use:

mvn archetype:generate -DarchetypeCatalog=local

Deploy the Archetype on dev.java.net

To deploy the Archetype to dev.java.net Maven repository it is necessary to add the wagon-svn extention and the distributionManagement tag to the archetype pom.xml

<?xml version="1.0" encoding="UTF-8"?><project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.imixs.workflow</groupId>
  <artifactId>imixs-workflow-jsf-sample-archetype</artifactId>
  <packaging>maven-archetype</packaging>
  <name>imixs-workflow-jsf-sample-archetype</name>
  <version>0.0.1-SNAPSHOT</version>
  <repositories>
    <repository>
      <id>maven2-repository.dev.java.net</id>
      <name>Java.net Repository for Maven</name>
      <url>http://download.java.net/maven/2/</url>
    </repository>
  </repositories>
  
  <build>
    <extensions>
      <extension>
        <groupId>org.apache.maven.archetype</groupId>
        <artifactId>archetype-packaging</artifactId>
        <version>2.0-alpha-4</version>
      </extension>
        <!-- upload into dev.java.net repository -->
                        <extension>
                                <groupId>org.jvnet.wagon-svn</groupId>
                                <artifactId>wagon-svn</artifactId>
                                <version>RELEASE</version>
                        </extension>
    </extensions>
    <plugins>
      <plugin>
        <artifactId>maven-archetype-plugin</artifactId>
        <version>2.0-alpha-4</version>
        <extensions>true</extensions>
      </plugin>
    </plugins>
    
  </build>
  
        <distributionManagement>
                <!-- upload into dev.java.net repository -->
                <repository>
                        <uniqueVersion>false</uniqueVersion>            
                        <id>java.net-m2-repository</id>
                        <url>java-net:/maven2-repository/trunk/repository/</url>
                </repository>
        </distributionManagement>    
</project> 

For Linux users only

See also the followint additional information (Linux users only)

http://weblogs.java.net/blog/2009/03/21/deploying-artifacts-javanet-repository-using-maven-2-ubuntu-linux

If maven is intalled into a differnet folder you need to setup maven with the following scripts: (assume the maven 2.2.1 is installed in /opt/ folder:

 export M2_HOME=/opt/apache-maven-2.2.1/
 export M2=$M2_HOME/bin
 export PATH=$M2:$PATH
 mvn --version
 mvn deploy