Classloading issues running flowable 6.4.0 on Karaf


#1

Hi flowable team,

we use flowable 5 together with apache karaf 4.0.x and it’s working quite well. Now we would like to migrate to flowable 6.4.0, but we have classloading issues when bootstrapping the engine.

All required flowable bundles are installed:
325 │ Active │ 80 │ 6.4.0 │ Flowable - BPMN Converter
326 │ Active │ 80 │ 6.4.0 │ Flowable - BPMN Model
327 │ Active │ 80 │ 6.4.0 │ Flowable - CMMN API
328 │ Active │ 80 │ 6.4.0 │ Flowable - CMMN Model
329 │ Active │ 80 │ 6.4.0 │ Flowable - Engine Common API
330 │ Active │ 80 │ 6.4.0 │ Flowable - Engine Common
331 │ Active │ 80 │ 6.4.0 │ Flowable - Content API
332 │ Active │ 80 │ 6.4.0 │ Flowable - DMN API
333 │ Active │ 80 │ 6.4.0 │ Flowable - DMN Model
334 │ Active │ 80 │ 6.4.0 │ Flowable - Engine
335 │ Active │ 80 │ 6.4.0 │ Flowable - Form API
336 │ Active │ 80 │ 6.4.0 │ Flowable - Form Model
337 │ Active │ 80 │ 6.4.0 │ Flowable - Identity Link Service API
338 │ Active │ 80 │ 6.4.0 │ Flowable - Identity Link Service
339 │ Active │ 80 │ 6.4.0 │ Flowable - IDM API
340 │ Active │ 80 │ 6.4.0 │ Flowable - IDM Engine
341 │ Active │ 80 │ 6.4.0 │ flowable-idm-engine-configurator
342 │ Active │ 80 │ 6.4.0 │ Flowable - Image Generator
343 │ Active │ 80 │ 6.4.0 │ Flowable - Job Service API
344 │ Active │ 80 │ 6.4.0 │ Flowable - Job Service
345 │ Active │ 80 │ 6.4.0 │ Flowable - Task Service API
346 │ Active │ 80 │ 6.4.0 │ Flowable - Task Service
347 │ Active │ 80 │ 6.4.0 │ Flowable - Process Validation
348 │ Active │ 80 │ 6.4.0 │ Flowable - Variable Service API
349 │ Active │ 80 │ 6.4.0 │ Flowable - Variable Service

The engine is configured as follows:

<bean id="processEngineFactory" class="org.flowable.osgi.blueprint.ProcessEngineFactoryWithELResolver" init-method="init" destroy-method="destroy">
		<property name="processEngineConfiguration" ref="processEngineConfiguration" />
		<property name="bundle" ref="blueprintBundle" />
		<property name="blueprintELResolver" ref="blueprintELResolver" />
		<property name="blueprintContextELResolver" ref="blueprintContainerListener" />
</bean>
<bean id="processEngineConfiguration" class="org.flowable.engine.impl.cfg.StandaloneProcessEngineConfiguration" ext:field-injection="true">
		<property name="dataSource" ref="dataSource" />
		<property name="databaseSchemaUpdate" value="true" />
		<property name="disableIdmEngine" value="true" />
		<property name="mailServerHost" value="${smtpHost}" />
		<property name="mailServerPort" value="${smtpPort}" />
		<property name="mailServerDefaultFrom" value="${fromEmail}" />
		<property name="asyncExecutorActivate" value="${jobExecutorActivate}" />
	</bean>

When starting our process-engine with blueprint.xml above, we get following exception:
Caused by: org.flowable.common.engine.api.FlowableException: Error while building ibatis SqlSessionFactory: inStream parameter is null
at org.flowable.common.engine.impl.AbstractEngineConfiguration.initSqlSessionFactory(AbstractEngineConfiguration.java:686)
at org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl.init(ProcessEngineConfigurationImpl.java:960)
at org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:887)
at org.flowable.osgi.blueprint.ProcessEngineFactory.init(ProcessEngineFactory.java:41)
at org.flowable.osgi.blueprint.ProcessEngineFactoryWithELResolver.init(ProcessEngineFactoryWithELResolver.java:42)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:331)
at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:838)
at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:591)
… 70 more
Caused by: java.lang.NullPointerException: inStream parameter is null
at java.base/java.util.Objects.requireNonNull(Objects.java:246)
at java.base/java.util.Properties.load(Properties.java:403)
at org.flowable.common.engine.impl.AbstractEngineConfiguration.initSqlSessionFactory(AbstractEngineConfiguration.java:679)
… 81 more

The org.flowable.common.engine.impl.AbstractEngineConfiguration.getResourceAsStream(String) Method does not work in OSGi, from OSGi classloading perspective, this bundle does not see the resources it wants to load (mybatis xml configurations).

Any help would be appreciated.

Regards, Björn


#2

Hi Björn,

We have some basic tests in the flowable-osgi module to test the bootstrapping of the Flowable Engine and starting a simple process instance. Would it be possible to create a unit test in the Flowable OSGi module that shows this issue? Then it would be easier to think of a fix. Or maybe we should create a flowable-karaf module and do this testing from there?

Best regards,

Tijs


#3

the best solution would be to provide a working karaf-example in https://github.com/flowable/flowable-examples. I could provide a sample Maven Module, which demonstrates, how to use Flowable with Karaf (and shows the problems I have with that).

If everything fits for you and it’s working, you provide the module in the flowable-examples repository.

What would be the best way to send the project to you?


#4

I added the project:

Can you have a look?


#5

Could you give us feedack, if you will take care of this issue? Otherwise, we have to re-think our migration plan …


#6

Sorry for the delay in answering. I will give your Karaf demo a try over the next couple of days and come back to you in this forum topic.

Best regards,

Tijs


#7

Hi,

I’ve tested your example project and could also reproduce the issue.
The strange thing is that it does work within the flowable-osgi unit test for some reason, maybe because of an extra restriction in Apache Karaf.
I’ve tried a couple of ways to get the issue resolved with exporting the IDM engine mapping files folder etc, but got the same error with every change. Also couldn’t find a solution yet while searching on loading a resource file from another bundle. A ways to make it work for now is to disable the IDM engine, with setting the disableIdmEngine property to true in the process engine configuration.

Best regards,

Tijs


#8

I also noticed, that resources are loaded from other bundles (e.g. flowable-engine loads resources from flowable-engine-common:org.flowable.common.db.properties), so if using OSGi, those packages should also be added to the OSGi export/import declarations.

But imho, this should not work with the org.flowable.osgi.blueprint.BundleDelegatingClassLoader, which is configured for the ProcessEngineConfiguration. I dont understand, why a special classloader is needed here !?

The disableIdmEngine=true configuration changes the classloading behaviour but does not solve the problem, I still see Nullpointers caused by Resources, which could not be load.


#9

Yes I understand your point. But when I disabled the IDM engine the process engine was being created successfully in my tests. For you the process engine bundle still fails?

Best regards,

Tijs


#10

yes, it fails with

Caused by: java.lang.NullPointerException
	at java.io.Reader.<init>(Reader.java:78)
	at java.io.InputStreamReader.<init>(InputStreamReader.java:72)
	at org.flowable.common.engine.impl.AbstractEngineConfiguration.initSqlSessionFactory(AbstractEngineConfiguration.java:659)

I updated my sample project with disableIdmEngine=true, could you pull my changes and check, why we have different behaviour? (I also added a H2 Datasource, see changes in README.md)

Regards, Björn