cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow and class management

pedwards
Champ on-the-rise
Champ on-the-rise
Hi,

As it currently stands, the rest package and the explorer package are separate wars, each relying on the common database. This causes issues when adding workflows with custom java classes. The reason this is an issue is that the jar files have to be added to both the rest and explorers /WEB-INF/lib directories (yes I could add it to the tomcat lib, but that may cause me other issues, and am not keen to go down that path).

As far as I can see, a BAR file only allow me to package multiple bpmn files together, but not the java they rely on (my custom service classes). I realise that storing java in a database for loading into the respective jvms isn't really ideal, but I don't see another solution.

Do you guys have any thoughts on this or plans to make this easier? Being able to dynamically deploy bpmns with their custom code would be nice. Its a pain having to stop and start tomcat to add/remove extra jar files.

Please correct me if I've missed something.

Thanks
Paul.
6 REPLIES 6

jbarrez
Star Contributor
Star Contributor
No, you're right, we currently don't have such support.

Back in the jBPM3 days, we indeed allowed serializing java code to the database. But it causes subtle bugs and was regarded as not a good practice.

Another solution would be to merge the explorer and rest webapp into one war, sharing the same classpath.

pmsevestre
Champ in-the-making
Champ in-the-making
Hi,

I'm developing an Activiti-based and I've run into the same kind of class-loading issues like those you described. In order to avoid them, I've adopted the following "doctrine":

* Process artifacts (.bar/.bpmn20.xml) never pack java classes
* Service tasks always use the "actitivi:expression" (a delegate expression would work fine). Something like that: activiti:expression="${scriptRunner.execute('myscript.groovy',execution)}"
* Form and process variables only use primitive data types. Anything else type is JSONified before being put into the process context.
* Service task scripts always access backend systems through REST and/or SOAP services, preferably by means of an ESB.

This doctrine works for me because I use Activiti Explorer as a monitoring/admin tool, while all user interaction occurs in a custom-made front-end. Other benefits from this approach are:

* Forms and scripts can be changed without any change in the process itself, without any restart
* Form, script  and process development can be assigned to different team members, and each one can push their changes independently (within certain limits, of course) from each other.

You may ask why didn't I use the script task for this, but I did not find a way to externalize scripts with this kind of activity - but I admit I did not try very much.




jbarrez
Star Contributor
Star Contributor
Thanks for posting this.
Script externalizing is actually something I've been playing with recently. The only thing is that the Javascript engine in the JDK is so dumbed down it's not fun anymore …

perpetuum_mobil
Champ in-the-making
Champ in-the-making
Hi!
In my project I need explorer and rest services with full functionality. And I like the idea of merging explorer and rest wars. But how to do it correctly?
It is not clear to me how to merge WEB-INF directories..
What did I do:
1) I copied WEB-INF/classes/org/activiti/rest of rest into WEB-INF/classes/org/activiti/ of explorer
2) I added these lines from rest web.xml to explorer's web.xml:
<code>
<listener>
    <listener-class>org.activiti.rest.servlet.ActivitiServletContextListener</listener-class>
</listener>
</code>
3) I merged WEB-INF/lib directories
Then I started tomcat
Acc actions I need in explorer worked correctly, but when I try to send rest request to explorer I get
{"errorMessage":"No router defined","statusCode":500}
and in catalina.out:
<code>
3.08.2013 10:20:49 org.restlet.resource.UniformResource doCatch
WARNING: Exception or error caught in resource
org.activiti.engine.ActivitiException: No router defined
at org.activiti.rest.api.DefaultResource.execute(DefaultResource.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.restlet.resource.ServerResource.doHandle(ServerResource.java:452)
at org.restlet.resource.ServerResource.get(ServerResource.java:648)
at org.restlet.resource.ServerResource.doHandle(ServerResource.java:530)
at org.restlet.resource.ServerResource.doNegotiatedHandle(ServerResource.java:590)
at org.restlet.resource.ServerResource.doConditionalHandle(ServerResource.java:302)
at org.restlet.resource.ServerResource.handle(ServerResource.java:849)
at org.restlet.resource.Finder.handle(Finder.java:513)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.routing.Router.doHandle(Router.java:500)
at org.restlet.routing.Router.handle(Router.java:740)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:155)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.engine.ChainHelper.handle(ChainHelper.java:114)
at org.restlet.engine.application.ApplicationHelper.handle(ApplicationHelper.java:75)
at org.restlet.Application.handle(Application.java:391)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.routing.Router.doHandle(Router.java:500)
at org.restlet.routing.Router.handle(Router.java:740)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.routing.Router.doHandle(Router.java:500)
at org.restlet.routing.Router.handle(Router.java:740)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.engine.ChainHelper.handle(ChainHelper.java:114)
at org.restlet.Component.handle(Component.java:391)
at org.restlet.Server.handle(Server.java:491)
at org.restlet.engine.ServerHelper.handle(ServerHelper.java:74)
at org.restlet.engine.http.HttpServerHelper.handle(HttpServerHelper.java:153)
at org.restlet.ext.servlet.ServerServlet.service(ServerServlet.java:1031)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.activiti.explorer.filter.ExplorerFilter.doFilter(ExplorerFilter.java:44)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
</code>

then i changed
<code>
<servlet> 
    <servlet-name>RestletServlet</servlet-name> 
    <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
    <init-param>
        <!– Application class name –>
        <param-name>org.restlet.application</param-name>
        <param-value>org.activiti.explorer.rest.application.ExplorerRestApplication</param-value>
    </init-param>
</servlet>
</code>
in explorer web.xml
to
<code>
<servlet> 
    <servlet-name>RestletServlet</servlet-name> 
    <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
    <init-param>
      <!– Application class name –>
      <param-name>org.restlet.application</param-name>
      <param-value>org.activiti.rest.application.ActivitiRestServicesApplication</param-value>
    </init-param>
</servlet>
</code>
(from rest web.xml)

So I could send rest requests to explorer, start processes, work with user tasks from explorer's UI..
But Process diagrams were not displayed in UI, I had some troubles in getting a list of tasks via rest..

What's the difference betwen org.activiti.explorer.rest.application.ExplorerRestApplication and org.activiti.rest.application.ActivitiRestServicesApplication?
What should I do to correct my merged war?

trademak
Star Contributor
Star Contributor
First please create your own post thread for new questions.
You should combine the ExplorerRestApplication and ActivitiRestServicesApplication entries into one Application class. Did you also include the javascript folders to display models?

Best regards,

kandepiprudhvi
Champ in-the-making
Champ in-the-making
Adding on top of the main question for this thread.. Is there any update since then ? Does 5.21 release support adding bmpns and corresponding Java Services (or JARs) dynamically ? I understand that the jars have to be deployed in lib of Activiti-rest if i have to use rest api. But i am looking at possibility of having one activiti-Engine which supports dynamic addition of workflows and thus avoiding accumulating code at one place.