cancel
Showing results for 
Search instead for 
Did you mean: 

Using forms in production [Ant scripts]

experimental
Champ in-the-making
Champ in-the-making
Hello there,

Edit I am now using Ant scripts to help control the process lifecycle. I'm not sure if it is correct but it helps.

I have got Activiti working and the provided example processes and form work fine. I have a number of questions how Activiti is expected to be used in production.
  • I see that the forms are referenced through the Activiti namespaced attribute formKey within the BPMN file to the path of the form.

  • Is it possible to specify this within the modeler? Is it possible to deploy processes from outside the Modeller and directly through files, like dropping the files into a folder?

  • Must the forms always be in the WEB-APPS folder of tomcat? Is there a way to setup some kind of repository that is separately maintainable?

  • Does the raw BPMN file in Cycle exclude the Activiti extensions? How do I know that I have been using the extensions?

  • Once you have made a process in the modeler, how do you deploy it so it becomes available in the processes view in Activiti Explorer? I made a process but it appears nowhere but within Modeler.
Edit Renamed topic.
9 REPLIES 9

experimental
Champ in-the-making
Champ in-the-making
The documentation refers to the block in the build.xml ant script that packages up the BPMN files and the forms and puts them into a business archive. I don't understand is how to use this in a real environment. Say I have a process with forms I want to make, so I make a folder named after the process.

What does this actually do? I gathered it generates a .bar file for deploying a process to the server and is supplied with the test libraries and runtime libraries for the process. I do not get what the activiti.cfg jar is for.

<taskdef name="deploy-bar" classname="org.activiti.engine.impl.ant.DeployBarTask">
  <classpath>
    <pathelement path="files/demo"/>
    <fileset dir="build">
      <include name="activiti-cfg.jar"/>
    </fileset>
    <fileset dir="${activiti.home}/examples/activiti-engine-examples/libs-runtime" />
    <fileset dir="${activiti.home}/examples/activiti-engine-examples/libs-test" />
  </classpath>
</taskdef>
<deploy-bar file="${activiti.home}/setup/build/activiti-examples.bar" />
I get the impression I have to restart the server everytime I do this since all the processes are deployed in one go? So I cannot make a .bar for a particular process and deploy that while running?

Can someone shed some light on this because it is confusing me.

tombaeyens
Champ in-the-making
Champ in-the-making
you can put as many or as little .bpmn20.xml process files in a bar file

activiti.cfg jar contains the configuration of the engine.  which db the engine should use and how.

experimental
Champ in-the-making
Champ in-the-making
Right I think I understand now. These are the steps you need to follow to make a deployable process archive.

  • Make a folder for your process

  • Make folders inside called taskforms to contain the BPMN file AND the form files.

  • Compress the process folder and give it a .bar extension.

  • Use the org.activiti.engine.impl.ant.DeployBarTask to and provide the path to the bar file above.
I am writing an ant task that has targets for the following:
  • skeleton Creates a directory structure for a new workflow with forms. Like how Ruby on Rails works, you generate a folder with a predetermined directory structure.

  • build Creates a bar file for sending to other computers.

  • deploy Runs the Ant activiti deploy task and actually inserts the project into Activiti.

  • clean Remove the old business archive.
Is this the right approach? The idea is that there is a lifecycle for the development of the process and deployment.

The deployment works but I get an exception when trying to start my process:

java.lang.NullPointerException
        at org.activiti.engine.impl.form.JuelFormEngine.getFormTemplateString(Ju
elFormEngine.java:58)
My test BPMN is as follows, it's a mutated form of the example process. I have a form.form and started.form in the same taskforms folder. Does the formKey have to be an exact path, if so, what would it be? Is it relative to the .bar file, so it would need to be taskforms\form.form?


<?xml version="1.0" encoding="UTF-8" ?>

<definitions id="definitions"
             targetNamespace="http://activiti.org/bpmn20"
             xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:activiti="http://activiti.org/bpmn">
 
  <process id="testForm" name="Test forms">
 
    <startEvent id="request" activiti:formKey="form.form" />

    <sequenceFlow id="flow1" sourceRef="request" targetRef="handleRequest" />
   
    <userTask id="handleRequest" name="Handle vacation request"
              activiti:formKey="started.form" >
      <documentation>
        Started process with ${data}
      </documentation>
     
      <potentialOwner>
        <resourceAssignmentExpression>
          <formalExpression>management</formalExpression>
        </resourceAssignmentExpression>
      </potentialOwner>        
    </userTask>

    <sequenceFlow id="flow2" sourceRef="handleRequest" targetRef="theEnd2" />
  
         
    <endEvent id="theEnd2" />
     
  </process>
 
</definitions>

markushbm
Champ in-the-making
Champ in-the-making
Experimental, I've got the same problems here. I don't think anyone not working with activiti for the last decade would be able to create a new and deployable process without a suitable documentation. Smiley Happy Could you please share your ant targets so that I'm able to test it by myself and maybe assist with your issue?

Markus

frederikherema1
Star Contributor
Star Contributor
Experimental,

The resources in your .bar file are deployed with the full path (relative to root) of the zip-entries as resourceName. If your forms are inside a folder (eg. forms), the resourceName would be 'forms/myForm.form'.

experimental
Champ in-the-making
Champ in-the-making
I get the impression that the folder doesn't actually matter inside the .bar? It can be anything?
The targets for my buildfile are are:

C:\activiti-5.0.rc1\setup\deployer>ant -Dbarname=test -p
Buildfile: C:\activiti-5.0.rc1\setup\deployer\build.xml

        Helps manage the deployment lifecycle of a workprocess.

Main targets:

build     Make the business archive.
clean     Delete the generated BAR file.
deploy    Insert the process into Activiti.
skeleton  create a skeleton directory to put your BPMN files and forms
It's intended that you skeleton -> build -> deploy.
Make a folder in your ${activiti.home}\setup caled deployer. Save the following buildfile to build.xml

<project name="BARDeployer" basedir=".">
    <description>
        Helps manage the deployment lifecycle of a workprocess.
    </description>
 
  <!– The project name. –>
  <property name="barname" value=""/>
  <!– Where your activiti is installed  –>
  <property name="activiti.home" location="../../"/>
  <!– Where the forms and BPMN files are kept –>
  <property name="formfolder" value="taskforms"/>
 

    <taskdef name="deploy-bar" classname="org.activiti.engine.impl.ant.DeployBarTask">
      <classpath>
        <pathelement path="files/demo"/>
        <fileset dir="../build">
          <include name="activiti-cfg.jar"/>
        </fileset>
        <fileset dir="${activiti.home}/examples/activiti-engine-examples/libs-runtime" />
        <fileset dir="${activiti.home}/examples/activiti-engine-examples/libs-test" />
      </classpath>
    </taskdef>

  <target name="skeleton" description="create a skeleton directory to put your BPMN files and forms" >
    <!– Create the skeleton directory(s) at –>
           
    <mkdir dir="./${barname}/${formfolder}/"/>
  </target>
 
  <target name="build" description="Make the business archive.">
   <zip destfile="./${barname}.bar">
      <fileset dir="./${barname}/">
        <include name="**/*.form"/>
         <include name="**/*.bpmn20.xml"/>


      </fileset>
    </zip> 
  </target>
 
 
  <target name="deploy" description="Insert the process into Activiti.">
  <!– Activiti provided –>
   <deploy-bar file="./${barname}.bar"/>
  </target>
 

  <target name="clean" description="Delete the generated BAR file." >
    <delete file="./${barname}.bar"/>
  </target>
 
</project>
All targets are executed like this:

cd deployer
ant -Dbarname=myworkflow <target>
You must provide the bar name everytime by using:-Dbarname=<barname>
Here is an example usage.

C:\activiti-5.0.rc1\setup\deployer>ant -Dbarname=myworkflow skeleton
Buildfile: C:\activiti-5.0.rc1\setup\deployer\build.xml

skeleton:
    [mkdir] Created dir: C:\activiti-5.0.rc1\setup\deployer\myworkflow\taskforms


BUILD SUCCESSFUL
Total time: 0 seconds
Then put a BPMN file and a form into the myworkflow\taskforms folder and we can build and deploy it in one go. Make sure you have the Activiti server started.

C:\activiti-5.0.rc1\setup\deployer>ant -Dbarname=myworkflow build deploy
Buildfile: C:\activiti-5.0.rc1\setup\deployer\build.xml

build:
      [zip] Building zip: C:\activiti-5.0.rc1\setup\deployer\myworkflow.bar

deploy:
[deploy-bar] Initializing process engine default
[deploy-bar] 24-Nov-2010 13:33:12 org.activiti.engine.ProcessEngines initProcess
EnginFromResource
[deploy-bar] INFO: initializing process engine for resource jar:file:/C:/activit
i-5.0.rc1/setup/build/activiti-cfg.jar!/activiti.cfg.xml
[deploy-bar] 24-Nov-2010 13:33:13 org.activiti.engine.impl.ProcessEngineImpl <in
it>
[deploy-bar] INFO: ProcessEngine default created
[deploy-bar] 24-Nov-2010 13:33:13 org.activiti.engine.ProcessEngines initProcess
EnginFromResource
[deploy-bar] INFO: initialised process engine default
[deploy-bar] Starting to deploy 1 files
[deploy-bar] Handling file C:\activiti-5.0.rc1\setup\deployer\myworkflow.bar
[deploy-bar] deploying bar C:\activiti-5.0.rc1\setup\deployer\myworkflow.bar
[deploy-bar] 24-Nov-2010 13:33:13 org.activiti.engine.impl.jobexecutor.JobAcquis
itionThread run
[deploy-bar] INFO: JobAcquisitionThread starting to acquire jobs
[deploy-bar] 24-Nov-2010 13:33:13 org.activiti.engine.impl.bpmn.deployer.BpmnDep
loyer deploy
[deploy-bar] INFO: Processing resource taskforms/started.form
[deploy-bar] 24-Nov-2010 13:33:13 org.activiti.engine.impl.bpmn.deployer.BpmnDep
loyer deploy
[deploy-bar] INFO: Processing resource taskforms/
[deploy-bar] 24-Nov-2010 13:33:13 org.activiti.engine.impl.bpmn.deployer.BpmnDep
loyer deploy
[deploy-bar] INFO: Processing resource taskforms/test.bpmn20.xml
[deploy-bar] 24-Nov-2010 13:33:14 org.activiti.engine.impl.bpmn.parser.BpmnParse
parseDefinitionsAttributes
[deploy-bar] INFO: XMLSchema currently not supported as typeLanguage
[deploy-bar] 24-Nov-2010 13:33:14 org.activiti.engine.impl.bpmn.parser.BpmnParse
parseDefinitionsAttributes
[deploy-bar] INFO: XPath currently not supported as typeLanguage
[deploy-bar] 24-Nov-2010 13:33:14 org.activiti.engine.impl.bpmn.deployer.BpmnDep
loyer deploy
[deploy-bar] INFO: Processing resource taskforms/form.form

BUILD SUCCESSFUL
Total time: 2 seconds

It deploys fine but I get a message box with 'Failure [OK]' in it. Pressing OK does nothing. What is the resourceName? I noticed that the demo buildfile has the a Java package path, why is this? What am I doing wrong?

markushbm
Champ in-the-making
Champ in-the-making
Thanks, I'll give it a try and report back asap. Smiley Happy

experimental
Champ in-the-making
Champ in-the-making
I have fixed the problem. When I made my form, I included an erroneous element. String type elements do not need hidden input fields to represent the type! Date fields and integers do however. This misled me into thinking I had to specify a String as the type. Woops.

I have been using clean build deploy to represent my cycle, db.drop and 'demo.teardown'. As you can imagine, that's pretty tedious. Is there any chance I could undeploy a process from ant without having to drop the database?

If you want to test yourself too, the form.form is:

<h1>This is a test form</h1>

<p>Yada yada yada</p>

<input name="data" type="text" value="insert"/>
and started.form

<h1>Congratulations, me</h1>

<p>You inputted ${data}</p>

<p>You started your own activiti process with forms</p>
The BPMN is as follows:

<?xml version="1.0" encoding="UTF-8" ?>

<definitions id="definitions"
             targetNamespace="http://activiti.org/bpmn20"
             xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:activiti="http://activiti.org/bpmn">
 
  <process id="myworkflow" name="Test forms">
 
    <startEvent id="request" activiti:formKey="taskforms/form.form" />

    <sequenceFlow id="flow1" sourceRef="request" targetRef="handleRequest" />
   
    <userTask id="handleRequest" name="Finish the test form"
              activiti:formKey="taskforms/started.form" >
      <documentation>
        Started process with ${data}
      </documentation>
     
      <potentialOwner>
        <resourceAssignmentExpression>
          <formalExpression>management</formalExpression>
        </resourceAssignmentExpression>
      </potentialOwner>        
    </userTask>

    <sequenceFlow id="flow2" sourceRef="handleRequest" targetRef="theEnd2" />
  
         
    <endEvent id="theEnd2" />
     
  </process>
 
</definitions>
If you found this helpful, please post your own suggestions and improvements.

I believe the documentation needs to be made more obvious. This was mostly trial and error, NPE are not friendly! I think there needs to be a focus on the documentation on how to use the infrastructure in production. A good example is the Drools documentation about the central repository. Your BPMN documentation is miles better than the competition though.

Thank you everybody for your help!

markushbm
Champ in-the-making
Champ in-the-making
I tested your script and it works fine with your process. Now I tried to deploy another simple process.

<?xml version="1.0" encoding="UTF-8" ?>

<definitions id="definitions"
             targetNamespace="http://activiti.org/bpmn20"
             xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:activiti="http://activiti.org/bpmn">
 
  <process id="simpleEmailProcess" name="E-Mail versenden">
    <startEvent id="theStart" />
    <sequenceFlow sourceRef="theStart" targetRef="sendMail" />
    <serviceTask id="sendMail" activiti:type="mail">
      <extensionElements>
        <activiti:field name="to">
          <activiti:string>test@example.com</activiti:string>
        </activiti:field>
        <activiti:field name="subject">
          <activiti:string>Hello Miss Piggy!</activiti:string>
        </activiti:field>
        <activiti:field name="html">
          <expression>
            <![CDATA[
              <html>
                <body>
                  Hello Miss Piggy,<br/><br/>
                  Just saying hi!<br/><br/>
                  Kind regards,<br/>
                  Me.
                </body>
              </html>
            ]]>
          </expression>
        </activiti:field>      
      </extensionElements>
    </serviceTask>
    <sequenceFlow sourceRef="sendMail" targetRef="theEnd" />
    <endEvent id="theEnd" />
  </process>

</definitions>

It deploys fine and is listed in activiti-probe, but when I try to open the process list in activiti-explorer I just get "Loading…" and nothing happens. Any help? This is the output:

actuser@actsrv:~/activiti-5.0.rc1/setup/deployer$ ant -Dbarname=myworkflow build deploy
Buildfile: build.xml

build:
      [zip] Building zip: /home/actuser/activiti-5.0.rc1/setup/deployer/myworkflow.bar

deploy:
[deploy-bar] Initializing process engine default
[deploy-bar] Nov 26, 2010 2:23:31 AM org.activiti.engine.ProcessEngines initProcessEnginFromResource
[deploy-bar] INFO: initializing process engine for resource jar:file:/home/actuser/activiti-5.0.rc1/setup/build/activiti-cfg.jar!/activiti.cfg.xml
[deploy-bar] Nov 26, 2010 2:23:33 AM org.activiti.engine.impl.ProcessEngineImpl <init>
[deploy-bar] INFO: ProcessEngine default created
[deploy-bar] Nov 26, 2010 2:23:33 AM org.activiti.engine.ProcessEngines initProcessEnginFromResource
[deploy-bar] INFO: initialised process engine default
[deploy-bar] Starting to deploy 1 files
[deploy-bar] Handling file /home/actuser/activiti-5.0.rc1/setup/deployer/myworkflow.bar
[deploy-bar] deploying bar /home/actuser/activiti-5.0.rc1/setup/deployer/myworkflow.bar
[deploy-bar] Nov 26, 2010 2:23:33 AM org.activiti.engine.impl.jobexecutor.JobAcquisitionThread run
[deploy-bar] INFO: JobAcquisitionThread starting to acquire jobs
[deploy-bar] Nov 26, 2010 2:23:33 AM org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy
[deploy-bar] INFO: Processing resource taskforms/
[deploy-bar] Nov 26, 2010 2:23:33 AM org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy
[deploy-bar] INFO: Processing resource taskforms/MyWorkflow.bpmn20.xml
[deploy-bar] Nov 26, 2010 2:23:33 AM org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
[deploy-bar] INFO: XMLSchema currently not supported as typeLanguage
[deploy-bar] Nov 26, 2010 2:23:33 AM org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
[deploy-bar] INFO: XPath currently not supported as typeLanguage

BUILD SUCCESSFUL
Total time: 3 seconds
actuser@actsrv:~/activiti-5.0.rc1/setup/deployer$

You can undeploy a process with activiti-probe. Just delete it and it will get deleted from the database as well. No need to drop the database.