Shared Container setup for Process Engine Plugins

929 views
Skip to first unread message

Melissa Palmer

unread,
Jan 9, 2015, 5:39:44 AM1/9/15
to camunda-...@googlegroups.com
Hi

How should one setup your container when implementing a "Process Engine Plugin" as described in [1]? 

I'm using Tomcat and have setup as described in the "Install the platform on a vanilla Tomcat" [2] As such my custom "Process Engine Plugin" therefore needs to be included into the tomcat lib folder. Problem is that do do all my dependency jars this will be a maintenance nightmare. 

What is the best way to setup for this situation? 

Daniel Meyer

unread,
Jan 14, 2015, 3:58:43 AM1/14/15
to camunda-...@googlegroups.com
Hi Melissa,

In apache tomcat there is no other possibility if you use a  shared process engine which is configured in bpm-platform.xml
What you could do in tomcat is to configure the process engine in an application ie. inside the processes.xml file of an application (and not inside bpm-platform.xml). In that case the plugin class is resolved from that application's classpath.
The process engine will be available for all other applications inside the same container.
You will need to make sure though that the application configuring the process engine is deployed before all other applications which use the process engine. I am not sure how to do that in tomcat. Ie. how to configure startup order of applications. Maybe it simply  uses alphabetical sorting :)

In Jboss / Wildfly you can deploy your extensions as modules and make sure that they are only added to the classpath of the process engine and not to the classpath of all applications that are deployed.

Hope this helps,
Daniel

Melissa Palmer

unread,
Jan 15, 2015, 7:02:30 AM1/15/15
to camunda-...@googlegroups.com
Hi Daniel, 

Thanks for your reply... I am now trying to get an "Embed Process Engine" running within tomcat. (as a single war within Vanilla Tomcat installation). 

I've followed most of the steps within the getting started [1] for Spring App. And then looking at the user guide I am trying to user a "org.camunda.bpm.engine.spring.container.ManagedProcessEngineFactoryBean" so that I can set the processEnginePlugins in order to include my own plugin. However I am never able to get the engine to initialized with my own Plugin being registered. ... what am I missing/doing wrong? 

src\main\webapp\WEB-INF\applicationContext,xml   (where za.co.itdynamics.bpm.identity.impl.ItdProcessEnginePlugin implements org.camunda.bpm.engine.impl.cfg.ProcessEnginePlugin


<context:annotation-config />
<bean id="dataSource" class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy">
......
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="itdProcessEnginePlugin" class="za.co.itdynamics.bpm.identity.impl.ItdProcessEnginePlugin" />

<bean id="processEngineConfiguration" class="org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration">
<property name="processEngineName" value="default" />
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseSchemaUpdate" value="true" />
<property name="jobExecutorActivate" value="false" />
       <property name="processEnginePlugins">
<list>
<ref bean="itdProcessEnginePlugin"/>
<bean class="org.camunda.bpm.application.impl.event.ProcessApplicationEventListenerPlugin" />
<bean class="org.camunda.spin.plugin.impl.SpinProcessEnginePlugin" />
<!-- <bean class="org.camunda.connect.plugin.impl.ConnectProcessEnginePlugin" /> -->
<bean class="org.camunda.bpm.engine.impl.plugin.AdministratorAuthorizationPlugin">
<property name="administratorUserName" value="MelissP"></property>
</bean>
</list>
</property>
</bean>
<!-- using ManagedProcessEngineFactoryBean allows registering the ProcessEngine with the BpmPlatform -->
    <bean id="processEngine" class="org.camunda.bpm.engine.spring.container.ManagedProcessEngineFactoryBean">
        <property name="processEngineConfiguration" ref="processEngineConfiguration"/>
    </bean>

<!-- <bean id="processEngine" class="org.camunda.bpm.engine.spring.ProcessEngineFactoryBean">
<property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>
-->  
</beans>

src\main\webapp\WEB-INF\web.xml
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
 
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
  </context-param>
 
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
 
</web-app>


The war builds/deploys 100% and tomcat starts up successfully... within the console I can see logs where seemingly my itdProcessEnginePlugin is listed too? 
Jan 15, 2015 2:00:21 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@4b4e6e7d: defining beans [org.springframework.context
.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.ann
otation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,dataSource,transactionManager,itdProcessEng
inePlugin,processEngineConfiguration,processEngine,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root
of factory hierarchy
Jan 15, 2015 2:00:22 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization completed in 1246 ms



Thanks
Melissa

Melissa Palmer

unread,
Jan 15, 2015, 7:17:18 AM1/15/15
to camunda-...@googlegroups.com
AAhh... .I possible realize my issue. However still not sure how to correct this. I am also trying to use the camunda tasklist/admin/cockpit app. 

However given the setup detailed above... I have used tomcat vanilla out of the box and not followed any of the steps for copying over camunda related jars to the lib folder. 
Hence possibly what tasklist etc. also don't start up correctly in this setup. 

Thanks
Melissa


On Friday, 9 January 2015 12:39:44 UTC+2, Melissa Palmer wrote:

Daniel Meyer

unread,
Jan 15, 2015, 7:47:19 AM1/15/15
to camunda-...@googlegroups.com
Hi Melissa,

If you use an embedded process engine like you explain above, you should use the "standalone" version of the webapplication:

Can also be downloaded from http://camunda.org/download (scroll to the bottom)

The standalone version of the webapp boots its own process engine. You then just have to point the process engine in the webapp and the process engine is your own application to the same database.

Cheers,
Daniel
Message has been deleted
Message has been deleted

Melissa Palmer

unread,
Jan 15, 2015, 9:34:47 AM1/15/15
to camunda-...@googlegroups.com
Hi Daniel, 

I have manage to get a little further... and can now see my plugin getting registered and used in some places: I added a simple Spring rest @Controller class in which I pragmatically call 
processEngine.getIdentityService().createUserQuery()
                                .orderByUserFirstName()
.asc()
.list();
or

BpmPlatform
.getDefaultProcessEngine().getIdentityService().createUserQuery()
                                .orderByUserFirstName()
.asc()
.list();

 
can am able to see that we now hitting my own plugin, and in tern own implementation of the IdentityService.. we've implemented the  org.camunda.bpm.engine.impl.identity.ReadOnlyIdentityProvider

My problem now is that I cannot get the camunda webapps to register/connect to this process engine. 

I am using the   "standalone" version of the webapplication: http://camunda.org/release/camunda-bpm/tomcat/7.2/camunda-webapp-tomcat-standalone-7.2.0.war
as you said before. 

Thanks
Melissa


On Friday, 9 January 2015 12:39:44 UTC+2, Melissa Palmer wrote:

Melissa Palmer

unread,
Jan 16, 2015, 2:52:28 AM1/16/15
to camunda-...@googlegroups.com
Hi Daniel

On further research... I realize that what I am now asking/needing to do is make the process engine which is embedded within one of the tomcat applications - available to other applications in the same container. You'd said in very the very first reply to me that "The process engine will be available for all other applications inside the same container."

What do I need to do to get other applications to use the engine from within this embedded one? 

Thanks
Melissa

Daniel Meyer

unread,
Jan 19, 2015, 6:45:37 AM1/19/15
to camunda-...@googlegroups.com
Hi Melissa,

> What do I need to do to get other applications to use the engine from within this embedded one? 

You need to
a) put the camunda-engine.jar into the shared lib folder (not the application)
b) if configured in Sing, use org.camunda.bpm.engine.spring.container.ManagedProcessEngineFactoryBean (as you already seem to do)

Does this help you?

Daniel

Melissa Palmer

unread,
Jan 21, 2015, 9:11:46 AM1/21/15
to camunda-...@googlegroups.com
Hi Daniel, 

Thanks for the reply.. to be honest I have not officially tried this. As I had a workaround before seeing you reply. 
However I am assuming that I would most likely fall into the same issues I was having that the dependencies for camunda-engine.jar are then not in the tomcat lib directory. 

What I have setup now.. is going back the to the Shared Container setup and I then setup a maven assembly build which creates a zip of all the jars I would need to add to the tomcat lib directory. And at the same time I have added config to tomcat to include a separate folder with just these jars at start up. This zip does start getting rather large as it's including a number of jars such as spring, commons-lang among others. 

It does all work..... not sure if its "best" practice way of doing things? Would love to hear you thoughts on this? 

Thanks
Melissa

Melissa Palmer

unread,
Feb 18, 2015, 4:36:15 AM2/18/15
to camunda-...@googlegroups.com
Hi Daniel 

I've been trying this one again... and still have issues. 
I am able to setup a WAR with an embedded process engine - using Spring and my own ProcessPlugins on startup in the console I successfully see on the console
   ...
   INFO: ProcessEngine default created
   ...
And can access 'ProcessEngine defaultProcessEngine = BpmPlatform.getDefaultProcessEngine();' which in turn enters my own identity plugin successfully. 

I'm unable to ensure this connects to the embedded engine of my own war. 

Things I tried included
1) edit \apache-tomcat-7.0.57\webapps\camunda-webapp-tomcat-standalone-7.2.0\WEB-INF\applicationContext.xml   to only have a dataSource which matches exactly to that of my own war, or to have no beans at all. 
ERROR in this case when I try login to the Admin app: 
INFO: Server startup in 18899 ms
2015-02-18 11:17:17 INFO  ResteasyDeployment:82 - Deploying javax.ws.rs.core.Application: class org.camunda.bpm.admin.impl.web.AdminApplication
Feb 18, 2015 11:17:18 AM org.camunda.bpm.engine.rest.exception.RestExceptionHandler toResponse
WARNING: org.camunda.bpm.engine.rest.exception.InvalidRequestException: Process engine with name default does not exist
        at org.camunda.bpm.webapp.impl.security.auth.UserAuthenticationResource.doLogin(UserAuthenticationResource.java:86)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2) edit \apache-tomcat-7.0.57\webapps\camunda-webapp-tomcat-standalone-7.2.0\WEB-INF\applicationContext.xml   to match my own war applicationContext.xml. 
ERROR in this case on server startup is: 
Caused by: javax.management.InstanceAlreadyExistsException: org.camunda.bpm.platform.process-engine:type=default
        at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324)
        at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
        at org.camunda.bpm.container.impl.jmx.MBeanServiceContainer.startService(MBeanServiceContainer.java:70)
        ... 38 more




Thanks
Melissa

On Friday, 9 January 2015 12:39:44 UTC+2, Melissa Palmer wrote:

thorben....@camunda.com

unread,
Feb 18, 2015, 9:31:06 AM2/18/15
to camunda-...@googlegroups.com
Hi Melissa,

I think you can't use the standalone webapp when you want it to access a shared engine that you bootstrapped with Spring. I'm not sure why Daniel recommended this. If you use an embedded engine in an application and don't register it with the platform, he's correct. All you can do in that case is use the standalone webapp and configure it against the same database. In your case, however, you have a shared engine and the standalone webapp won't find the engine because it contains the engine library itself and looks the engine up from there. Using the "regular" webapps should work though.

Essentials of engine registration and lookup: the engine jar has a static map keeps the registered engines. Having this class twice means having the map twice. Depending on which class is seen by an application that registers an engine and an application that accesses this engine, they may see the same engine or not.

Cheers,
Thorben

Melissa Palmer

unread,
Feb 19, 2015, 1:12:03 AM2/19/15
to camunda-...@googlegroups.com
Hi Thorben/Daniel

I think we might be crossing wires at some points between two posts that I have going. 

What I want/need is: 
a) Process Engine bootstraped via Spring such that I can (1) have my own ProcessEnginePlugin where the IdentityService is my own implementation of a ReadOnlyIdentityProvider (2) setup the CustomPreBPMNParseListeners against ProcessEngineConfigurationImpl so that I can add a global TaskListener (TaskAssignmentListner) which can email users/groups when ever a task is assigned to them
b) at the same time the have a JavaDelegate (EmailJavaDelegate) which is configured via Spring such that I can use it against processes as the "ExpressionDelegate" within a ServiceTask of a process
c) The custom classes TaskAssignmentListner and EmailJavaDelegate will both make use of a NotificationService that is configured within the Spring ApplicationContext
d) Global/Reusable classes packaged into a jar ... each process packaged into its own war file.... but is also able to user the global/reusable classes (ideally configured within Spring)
e) deploy (1) embedded process engine Spring bootstrapped war (2) camunda-webapp.war/camunda-webapp-standallone.war (3) process1.war / process2.war to the same Tomcat webapps directory such that I can 
 - login to the camunda tasklist/admin/cockpit 
 - and ensure that my own IdentityService implementation is used and TaskAssignment listener is setup at a global level
 - once logged into the tasklist/cockpit the processes that you see are the ones that I've deployed ask "process1.war / process2.war / etc."
 - and logging into the admin app will list my users/groups from my IdentityService implementation

Few Questions:
1) Am I trying to attempt something that is not possible.... do I miss understand something? 
2) What would be recommended best practice way for going able this be? 

For this particular post... I am trying the following without success:
- One War file with embedded Process Engine configured via spring
- trying to deploy either camunda-webapp.war or camunda-webapp-standalone.war to the same tomcat/webapps such that it will connect to the above "Embedded Process Engine which was bootstrapped via Spring" [I believe I'm attempting the situation you mention Thorben mentions: "If you use an embedded engine in an application and don't register it with the platform, he's correct."]


Thanks
Melissa

thorben....@camunda.com

unread,
Feb 19, 2015, 12:00:38 PM2/19/15
to camunda-...@googlegroups.com
Hi Melissa,

That sounds doable when you register the process engine bootstrapped in Spring with the platform.

However, we are not able to answer open questions related to your application's architecture here, especially those related to your Spring setup. We can assist you with technical questions on how to achieve a concrete goal with Camunda. We haven't got the resources to assist you beyond that.

Why is that so? Providing general advice on user’s application design is very time consuming for us and we prefer to invest that time in product improvement, so that everybody can benefit.

With your concrete issues, please post the concrete thechnical issues and also post your understanding of how you think Camunda and its Spring integration work in your environment. Then we can correct misunderstandings, provide hints and pointers, and you may be able to figure out how it should be done.

Cheers,
Thorben

Melissa Palmer

unread,
Feb 20, 2015, 4:19:02 AM2/20/15
to camunda-...@googlegroups.com
Hi Thorben

Thanks very much for all the help thus far, I do appreciated it and understand you cannot help with our architecture.
 
I have managed to work out how get the "Engine bootstrapped via Spring" and then have other apps connecting to the same this engine which is what I needed see post at [1]

I found the documentation around "Configuring a container-managed Process Engine as a Spring Bean" very difficult to follow. I have created a pull request at 'https://github.com/camunda/docs.camunda.org/pull/47' in which I added some more documentation. 



Thanks
Melissa


On Friday, 9 January 2015 12:39:44 UTC+2, Melissa Palmer wrote:
Reply all
Reply to author
Forward
0 new messages