cancel
Showing results for 
Search instead for 
Did you mean: 

Invoking a Spring bean from Activiti Explorer

mialtuna
Champ in-the-making
Champ in-the-making
Hello,

Is it possible to invoke Spring beans after a User Task is confirmed in a Activiti Explorer?

We are deploying our Spring application war and the Activiti Explorer war in the same app server. The problem is that if after a user task confirmed using the Explorer the process has to continue with a service task that executes a Spring method, the bean is not known for the Explorer and we have got the next exception

Caused by: org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'ourBean'
at org.activiti.engine.impl.juel.AstIdentifier.eval(AstIdentifier.java:83) [activiti-engine-5.10.jar:5.10]
   at org.activiti.engine.impl.juel.AstMethod.invoke(AstMethod.java:79) [activiti-engine-5.10.jar:5.10]
   at org.activiti.engine.impl.juel.AstMethod.eval(AstMethod.java:75) [activiti-engine-5.10.jar:5.10]
   at org.activiti.engine.impl.juel.AstEval.eval(AstEval.java:50) [activiti-engine-5.10.jar:5.10]
   at org.activiti.engine.impl.juel.AstNode.getValue(AstNode.java:26) [activiti-engine-5.10.jar:5.10]
   at org.activiti.engine.impl.juel.TreeValueExpression.getValue(TreeValueExpression.java:114) [activiti-engine-5.10.jar:5.10]
   at org.activiti.engine.impl.delegate.ExpressionGetInvocation.invoke(ExpressionGetInvocation.java:33) [activiti-engine-5.10.jar:5.10]
   at org.activiti.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:37) [activiti-engine-5.10.jar:5.10]
   at org.activiti.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:25) [activiti-engine-5.10.jar:5.10]
   at org.activiti.engine.impl.el.JuelExpression.getValue(JuelExpression.java:50) [activiti-engine-5.10.jar:5.10]

As there are 2 diferents apps, they have got their own spring contexts.

What would be the best approach to solve that problem?

Thanks in advance!
21 REPLIES 21

frederikherema1
Star Contributor
Star Contributor
Isn't it possible to run the apps in the same wabapp (difference servlet-mappings), sharing the same application-context? If not, you should define remote-beans in the explorer-app-context that have a spring-remote counterpart in your own app. Or use any other remote technique…

mialtuna
Champ in-the-making
Champ in-the-making
frederikheremans thank you for your reply!

Isn't it possible to run the apps in the same wabapp (difference servlet-mappings), sharing the same application-context?

How can I do that? Adding Activiti Explorer sources in my project?

Thanks in advance!

frederikherema1
Star Contributor
Star Contributor
Vaadin allows streaming the resources from a jar-file, so you don't have to include sources. Take a look at the assembly.xml in activiti-webapp-explorer2, this contains a description of a jar-version of the web app, that is used in Alfresco enterprise.

Go to the folder "modules/activiti-webapp-explorer2/" and run "mvn package assembly:assembly". You'll have a jar in your target called "activiti-***-ui.jar". The only thing left to do is configure the Vaadin-servlet in your application (see the web.xml in explorer2).

You might want to alter is the "ui.properties" in the JAR-file to contain this value:

activiti.ui.environment = activiti

To include the activiti-context, just import "activiti-ui-context.xml" in the general spring-config.

This way, you can upgrade easily, by creating a new ui-jar from the activiti-sources and just dump in in your web app Smiley Wink

mialtuna
Champ in-the-making
Champ in-the-making
Thanks again frederikheremans!

I´ve created the jar you mentions in your previous post and now I´ve got problems initializing the context. Is it necesary to edit something else in the jar to make it work with the global context?

Caused by: java.lang.NullPointerException
at org.activiti.explorer.navigation.TaskNavigator.<init>(TaskNavigator.java:53) [activiti-webapp-explorer2-5.11-SNAPSHOT-ui-jar.jar:]
at org.activiti.explorer.navigation.NavigatorManager.afterPropertiesSet(NavigatorManager.java:60) [activiti-webapp-explorer2-5.11-SNAPSHOT-ui-jar.jar:]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
… 20 more

mialtuna
Champ in-the-making
Champ in-the-making
Sorry!!

I was importing the activiti-ui.context.xml before creating taskService bean

mialtuna
Champ in-the-making
Champ in-the-making
There is something yet that is not working propertly…. :cry:

The Activiti-Explorer throws me and exception caused becouse VAADIN widgetset is missign in root/VAADIN/ directory.

If I add this foldes manualy to the project, the login page is displayed without problems.  Smiley Very Happy

The problems is that when I logged in I only see a white screen.

Thanks!

frederikherema1
Star Contributor
Star Contributor
Is the following included in your web.xml?


<servlet>
   <servlet-name>Vaadin Application Servlet</servlet-name>
   <servlet-class>org.activiti.explorer.servlet.ExplorerApplicationServlet</servlet-class>
</servlet>


<servlet-mapping>
   <servlet-name>Vaadin Application Servlet</servlet-name>
   <url-pattern>/activiti-explorer2/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
   <servlet-name>Vaadin Application Servlet</servlet-name>
   <url-pattern>/VAADIN/*</url-pattern>
</servlet-mapping>

mialtuna
Champ in-the-making
Champ in-the-making
SOLVED!

frederikheremans, you are the boss!  :lol:

mialtuna
Champ in-the-making
Champ in-the-making
Hello,

I´m upgrading to 5.11 and I´ve got a problem with the servlet mapping and the modeler.

When I try to edit a definition, a white page with Activiti BPM Suite header is shown.

I suppose that is a mapping problem but I´m getting crazy!

Can anybody help me?

Thanks in advance!

This is my mapping configuration.

  <servlet>
  <servlet-name>Vaadin Application Servlet</servlet-name>
  <servlet-class>org.activiti.explorer.servlet.ExplorerApplicationServlet</servlet-class>
  </servlet>
 
   <!– Restlet adapter, used to expose modeler functionality through REST –>
<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.editor.rest.application.ActivitiRestApplication</param-value>
  </init-param>
</servlet>
   <servlet-mapping>
    <servlet-name>Vaadin Application Servlet</servlet-name>
    <url-pattern>/activiti-explorer2/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
     <servlet-name>Vaadin Application Servlet</servlet-name>
     <url-pattern>/VAADIN/*</url-pattern>
  </servlet-mapping> 
  <servlet-mapping>
  <servlet-name>Vaadin Application Servlet</servlet-name>
  <url-pattern>/activiti-explorer/*</url-pattern>
  </servlet-mapping>
  
   <servlet-mapping>
  <servlet-name>default</servlet-name>
  <url-pattern>/activiti-explorer/api/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
  <servlet-name>default</servlet-name>
  <url-pattern>/activiti-explorer/editor/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
  <servlet-name>default</servlet-name>
  <url-pattern>/activiti-explorer/explorer/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
  <servlet-name>default</servlet-name>
  <url-pattern>/activiti-explorer/libs/*</url-pattern>
</servlet-mapping>

<!– Catch all service requests –>
<servlet-mapping>
  <servlet-name>RestletServlet</servlet-name>
  <url-pattern>/activiti-explorer/service/*</url-pattern>
</servlet-mapping>