AnsweredAssumed Answered

Problem with JBPMSpringActionHandler

Question asked by bcoulson on Apr 12, 2011
Latest reply on May 2, 2011 by mcook
All

I am attempting to connect to my Java class from within an advanced worfklow step. I have defined my process definition as follows.


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

<process-definition  xmlns="urn:jbpm.org:jpdl-3.1"  name="scwf:publishDocument">

<swimlane name="initiator"/>

   <start-state name="Start">
      <task name="scwf:assignWorkflow" swimlane="initiator"/>
      <transition to="AnalystTask" name="toAnalyst"></transition>
   </start-state>

   <task-node name="AnalystTask">
      <task name="scwf:createDocument" swimlane="initiator">
         <event type="task-create">
            <script>
               if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
                  if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
            </script>
         </event>
      </task>
      <transition to="TeamLeadTask" name="toTeamLead">
           <action class="gov.dhs.ipds.alfresco.AlfrescoHelper" config-type="bean" name="reviewChanges"/>
      </transition>
   </task-node>

   <task-node name="TeamLeadTask">
      <task name="scwf:reviewDocument" swimlane="initiator">
         <event type="task-create">
            <script>
               if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
                  if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
            </script>
         </event>
      </task>

      <transition to="End" name="toProduction">
      </transition>
   </task-node>

   <end-state name="End"></end-state>
</process-definition>

And my Java code is as follows

package gov.dhs.ipds.alfresco;

import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler;
import org.springframework.beans.factory.BeanFactory;
import org.jbpm.graph.exe.ExecutionContext;

public class AlfrescoHelper extends  JBPMSpringActionHandler {

   private static final long serialVersionUID = 1000L;

   public void execute(ExecutionContext ctx) throws Exception {
      System.out.println("Inside AlfrescoHelp.execute()");
   }

   public AlfrescoHelper() {
      System.out.println("Inside AlfrescoHelper()");
   }
   
   @Override
   protected void initialiseHandler(BeanFactory factory) {
      System.out.println("Inside AlfrescoHelper.initialiseHandler()");
      // TODO Auto-generated method stub
   }
}

When I attempt to execute the workflow task that instantiates the Java action class, I get the following exception(s) in my logfile.


09:06:44,209  ERROR [web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gov.dhs.ipds.alfresco.AlfrescoHelper' defined in file [C:\Alfresco\tomcat\shared\classes\alfresco\extension\someco-model-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [gov.dhs.ipds.alfresco.AlfrescoHelper]: Constructor threw exception; nested exception is java.lang.NullPointerException
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:946)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:890)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416)
   at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:261)
   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:192)
   at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
   at org.alfresco.web.app.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:63)
   at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
   at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
   at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
   at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
   at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
   at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
   at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
   at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
   at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
   at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
   at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
   at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
   at org.apache.catalina.core.StandardService.start(StandardService.java:519)
   at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
   at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
   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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
   at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [gov.dhs.ipds.alfresco.AlfrescoHelper]: Constructor threw exception; nested exception is java.lang.NullPointerException
   at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141)
   at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:72)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:938)
   … 38 more
Caused by: java.lang.NullPointerException
   at org.springmodules.workflow.jbpm31.JbpmFactoryLocator.useBeanFactory(JbpmFactoryLocator.java:162)
   at org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler.<init>(JBPMSpringActionHandler.java:46)
   at gov.dhs.ipds.alfresco.AlfrescoHelper.<init>(AlfrescoHelper.java:15)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
   at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
   at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
   … 40 more

I cannot see what I am doing wrong nor have I been able to find any information in the forums here or on Spring or jBpm to determine what I am doing wrong. I have not added a Spring bean for my Java class. When I do add a bean for it, I get the same exception above so I just get it sooner rather than later - basically at instantiation time.

Any help would be greatly appreciated.

Outcomes