cancel
Showing results for 
Search instead for 
Did you mean: 

Karaf 2.2.7 ClassNotFound Exception

rajsenthil
Champ in-the-making
Champ in-the-making
Hi, I have a simple process with a single task as  (1)Start==>(2)Hello Service Task==>(3)End.
The service task is a JavaDelegation class that is trying to refer an object exposed in another bundle. This object is referred inside the beans.xml below as helloService and I am getting the NullPointerException. Could someone help me if I am missing anything?


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

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:ctx="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:osgi="http://www.springframework.org/schema/osgi"
       xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
       xmlns:jaxws="http://cxf.apache.org/jaxws"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/tx      http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
       http://www.springframework.org/schema/osgi-compendium http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd
       http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"
       >   
   
   <bean id="helloWorldConsumer" class="com.ge.research.dhc.process.HelloWorldTask">
       <property name="helloService" ref="helloService"/>
    </bean>
   
   <osgi:reference id="helloService" interface="com.ge.dhc.poc01.helloWorldService.HelloService"/>
                             
</beans>

Thanks
3 REPLIES 3

rajsenthil
Champ in-the-making
Champ in-the-making
The task code is below…


public class HelloWorldTask implements JavaDelegate {

private HelloService helloService;

    public void execute(DelegateExecution execution) throws Exception {
    
        ActivityExecution ae = (ActivityExecution) execution;
        System.out.printf("\n*** Executing Service Task… Execution Id:[%s] Activity: %s[%s]\n",
                ae.getId(), ae.getActivity().getId(), ae.getActivity().getProperty("name"));

        System.out.println("Ok now going to make a call….");
        System.out.println("Return from the service is… " + helloService.sayHello());
    }

public void setHelloService(HelloService helloService) {
  this.helloService = helloService;
}
   
   
}

trademak
Star Contributor
Star Contributor
Did you try the Karaf example of my Activiti in Action book first?

Best regards,

rajsenthil
Champ in-the-making
Champ in-the-making
I got the source code for book-osgi-app and deployed it to karaf. It looks fine.

When the bundle was first deployed, the setter method is called by injecting the object. But when the process is started, it fails with NullPointerException.
The only way I could think of if making the variable to Class level by declaring it as static. If I make that variable as static, then it works.

It looks like the activiti engine is calling the JavaDelegate by creating a new instance. I don't know how to let activiti engine to use the already exisiting object.