cancel
Showing results for 
Search instead for 
Did you mean: 

Spring throw error while converting MyEventListener to ActivitiEventListner

bhuvangupta
Champ in-the-making
Champ in-the-making

Error creating bean with name 'processEngineConfiguration' defined in ServletContext resource [/WEB-INF/activiti-standalone-context.xml]: Initialization of bean failed;
nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.util.ArrayList' to required type 'java.util.List' for property 'eventListeners';
nested exception is java.lang.IllegalStateException: Cannot convert value of type [main.MyEventListener] to required type [org.activiti.engine.delegate.event.ActivitiEventListener] for property 'eventListeners[0]': no matching editors or conversion strategy found


Bean defination in actitivi-standalone-context.xml

   <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
     <property name="dataSource" ref="dataSource" />
     <property name="transactionManager" ref="transactionManager" />
     <property name="databaseSchemaUpdate" value="true" />
     <property name="jobExecutorActivate" value="true" />
    <property name="customFormTypes">   
      <list>
        <bean class="org.activiti.explorer.form.UserFormType"/>
        <bean class="org.activiti.explorer.form.ProcessDefinitionFormType"/>
        <bean class="org.activiti.explorer.form.MonthFormType"/>  
      </list>
    </property>
   <property name="eventListeners">
      <list>
         <bean class="main.MyEventListener" />
      </list>
    </property>
  </bean>


main.MyEventListener is a copy from the documentation.

i am on 5.15.1 and using tomcat 6

Any idea about the error ?
6 REPLIES 6

trademak
Star Contributor
Star Contributor
Please include the code of your main.MyEventListener class. Are you implementing the ActivitiEventListener interface?

Best regards,

bhuvangupta
Champ in-the-making
Champ in-the-making
<code>
package main;

import org.activiti.engine.delegate.event.ActivitiEvent;
import org.activiti.engine.delegate.event.ActivitiEventListener;

public class MyEventListener implements ActivitiEventListener {

  @Override
  public void onEvent(ActivitiEvent event) {
   
    switch (event.getType()) {
   
      case JOB_EXECUTION_SUCCESS:
        System.out.println("A job well done!");
        break;
 
      case JOB_EXECUTION_FAILURE:
        System.out.println("A job has failed…");
        break;
       
      default:
        System.out.println("Event received: " + event.getType());
    }
  }

  @Override
  public boolean isFailOnException() {
    // The logic in the onEvent method of this listener is not critical, exceptions
    // can be ignored if logging fails…
    return false;
  }
}

</code>

bhuvangupta
Champ in-the-making
Champ in-the-making
change the file extension to .jar .
cant upload file with different extension other then .txt

bhuvangupta
Champ in-the-making
Champ in-the-making
I have also tried with following scenarios
First case:
[1] download tomcat 6 and install it
[2] download activiti 5.15.1
[3] extract activiti war in webapps folder of tomcat and copy all activiti/lib/*.jar to tomcat/lib
[4] created a jar <code>myEventJar</code> containing MyEventListener.class (i have attached my jar)
[5]  change the activiti-explorer war to change activiti-standalone-context.xml (i have attached my xml)
[6] put myEventjar in lib folder of tomcat.
[7] start the tomcat
>>>> i see above error.
___________________________


Second case:
Extact same as first case + add all the latest spring jars to lib folder of tomcat
>>> same error.
___________________________
i am running it on window 7 with oracle java 6

bhuvangupta
Champ in-the-making
Champ in-the-making
Hi.. I was able to resolve the issue, the problem was:
[1] I had to turn on the unpackwar property true in server.xml
<code><Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"></code>
[2] The event listener need to be inside exploded war.

trademak
Star Contributor
Star Contributor
Tomcat unpacks the WAR by default, so don't understand why a specific configuration would be needed.
Yes, your JAR file needs to be part of the WEB-INF/lib folder of the Explorer and REST application.

Best regards,
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.