cancel
Showing results for 
Search instead for 
Did you mean: 

NPE Blueprint initializing BlueprintExpressionManager

ronnybr
Champ in-the-making
Champ in-the-making
Hi everybody,

I am trying to get Activiti running as OSGi-bundle on JBoss AS 7.1.1 and the ExpressionFactoryImpl throws a NPE when trying to access the el.properties.
The server uses OSGi 4.2 and Apache Aries 1.0.0.

Here's the stacktrace:

Caused by: java.lang.NullPointerException
   at org.activiti.engine.impl.juel.ExpressionFactoryImpl.loadProperties(ExpressionFactoryImpl.java:278)
   at org.activiti.engine.impl.juel.ExpressionFactoryImpl.<init>(ExpressionFactoryImpl.java:152)
   at org.activiti.engine.impl.juel.ExpressionFactoryImpl.<init>(ExpressionFactoryImpl.java:137)
   at org.activiti.engine.impl.el.ExpressionManager.<init>(ExpressionManager.java:66)
   at org.activiti.engine.impl.el.ExpressionManager.<init>(ExpressionManager.java:61)
   at org.activiti.osgi.blueprint.ProcessEngineFactoryWithELResolver$BlueprintExpressionManager.<init>(ProcessEngineFactoryWithELResolver.java:43)
   at org.activiti.osgi.blueprint.ProcessEngineFactoryWithELResolver.init(ProcessEngineFactoryWithELResolver.java:29)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_27]
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.6.0_27]
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.6.0_27]
   at java.lang.reflect.Method.invoke(Method.java:616) [rt.jar:1.6.0_27]
   at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:238)
   at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:954)
   at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:708)
   … 47 more


I divided my project like Tijs in Activiti in Action. The activiti-engine- and activiti-osgi-bundles are deployed and I use an "engine"-bundle (like book-engine) for the context.xml.
The context.xml looks like this:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
  xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">

  <ext:property-placeholder />

  <bean id="dataSource" class="org.h2.jdbcx.JdbcDataSource">
    <property name="URL" value="jdbc:h2:mem:test" />
    <property name="user" value="sa" />
    <property name="password" value="sa" />
  </bean>

  <bean id="configurationFactory" class="org.activiti.osgi.blueprint.ConfigurationFactory">
    <property name="dataSource" ref="dataSource" />
    <property name="databaseSchemaUpdate" value="true" />
  </bean>

  <bean id="configuration" factory-ref="configurationFactory" factory-method="getConfiguration" />

  <bean id="processEngineFactory"
      class="org.activiti.osgi.blueprint.ProcessEngineFactoryWithELResolver"
      init-method="init"
      destroy-method="destroy">
     
    <property name="processEngineConfiguration" ref="configuration" />
    <property name="bundle" ref="blueprintBundle" />
    <property name="blueprintELResolver" ref="blueprintELResolver" />
  </bean>

  <bean id="processEngine" factory-ref="processEngineFactory"
    factory-method="getObject" />

  <bean id="runtimeService" factory-ref="processEngine"
    factory-method="getRuntimeService" />
  <bean id="repositoryService" factory-ref="processEngine"
    factory-method="getRepositoryService" />
   
  <reference-list id="activityProviders" availability="optional"
      interface="org.activiti.engine.delegate.JavaDelegate"
      activation="eager">
     
      <reference-listener ref="blueprintELResolver" bind-method="bindService" unbind-method="unbindService"/>
  </reference-list>
 
  <bean id="blueprintELResolver" class="org.activiti.osgi.blueprint.BlueprintELResolver" />
 
  <service ref="processEngine" interface="org.activiti.engine.ProcessEngine" />
  <service ref="runtimeService" interface="org.activiti.engine.RuntimeService" />
  <service ref="repositoryService" interface="org.activiti.engine.RepositoryService" />

</blueprint>


Does anyone have an idea what he tries to do with the el.properties and how I can avoid that NPE?
4 REPLIES 4

ronnybr
Champ in-the-making
Champ in-the-making
Sorry, I forgot to mention that I use Activiti 5.12.1

ronnybr
Champ in-the-making
Champ in-the-making
I found out, what the problem was.
The ExpressionFactoryImpl uses the TCCL to get the el.properties. The problem was, that there was no classloader associated with the thread and that's why I got a NPE in this line
<code>
   input = Thread.currentThread().getContextClassLoader().getResourceAsStream(path);
</code>
I don't know if anyone else uses Activiti as bundle and why the TCCL in my environment was null, but I would like to suggest a change.
The line above is part of the activiti-engine and in my opinion the engine shouldn't be changed because of an OSGi-issue.
I would like to change the init() in org.activiti.osgi.blueprint.ProcessEngineFactoryWithELResolver.
My workaround atm looks like this:
<code>
@Override
  public void init() throws Exception {
    ProcessEngineConfigurationImpl configImpl = (ProcessEngineConfigurationImpl) getProcessEngineConfiguration();
    ClassLoader oldTccl = Thread.currentThread().getContextClassLoader();
    try{
     Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
    configImpl.setExpressionManager(new BlueprintExpressionManager());
    }catch(Exception e){
     e.printStackTrace();
    }finally{
     Thread.currentThread().setContextClassLoader(oldTccl);
    }
</code>
I know my exception-handling is bad style Smiley Wink
I still get other exceptions, but I am working on it. So please consider this a first suggestion and tell me your opinion.

trademak
Star Contributor
Star Contributor
The example of the Activiti in Action book shows the use of the OSGi module on Apache Karaf as you know. This issue seems to be specific to JBoss 7. The workaround you are proposing now is not something that we should make the default in Activiti to my opinion. There should be a better solution I hope.

Best regards,

ronnybr
Champ in-the-making
Champ in-the-making
You were right Tijs, it's not an Activiti but a JBoss issue.

Please don't ask me how and why, but when using JBoss 7.2 everything works fine.
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.