Bug 1098018 - NoClassDefFoundError of dependent jar class during process execution
Summary: NoClassDefFoundError of dependent jar class during process execution
Keywords:
Status: CLOSED EOL
Alias: None
Product: JBoss BPMS Platform 6
Classification: Retired
Component: jBPM Core
Version: 6.0.1
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ER1
: ---
Assignee: Alessandro Lazarotti
QA Contact: Ivo Bek
URL:
Whiteboard:
Depends On:
Blocks: 1115481
TreeView+ depends on / blocked
 
Reported: 2014-05-15 05:47 UTC by Toshiya Kobayashi
Modified: 2020-03-27 20:13 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Fixed Issue Summary: A bug with handling maven dependencies in kie-ci occurred in which only direct dependencies of the project were taken, but the transitive dependencies were not. This would result in the following error: java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext This issue has been resolved with 6.0.3, and the script runs without errors.
Clone Of:
Environment:
Last Closed: 2020-03-27 20:13:18 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
jbpm-spring-dep-test-new.zip (48.14 KB, application/zip)
2014-05-15 05:49 UTC, Toshiya Kobayashi
no flags Details

Description Toshiya Kobayashi 2014-05-15 05:47:48 UTC
Description of problem:

This is the same projects as BZ1097632. (The difference: I applied Maciej's suggestion in comment#4. And edited jbpm-spring-dep-kjar/pom.xml as below)

(A) Jar which uses Spring
(B) Kjar which includes BPMN2 process which depends on (A) jar.
(C) A main application which runs a process in (B) kjar.

Please look into jbpm-spring-dep-test/jbpm-spring-dep-kjar/pom.xml 

I comment-out <dependency> for Spring libraries because (B) kjar just depends on (A) jar and I expect transitive dependencies will be resolved by maven.

But when I run the process, Script Task fails with NoClassDefFoundError.

=====
java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
	at org.jbpm.Process_org$u46$jbpm$u46$sample909675094.action0(Process_org$u46$jbpm$u46$sample909675094.java:18)
	at org.jbpm.Process_org$u46$jbpm$u46$sample909675094Action0Invoker.execute(Process_org$u46$jbpm$u46$sample909675094Action0Invoker.java:14)
	at org.jbpm.workflow.instance.impl.NodeInstanceImpl.executeAction(NodeInstanceImpl.java:182)
	at 
...
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContext
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	... 54 more
====

Steps to Reproduce:
1. Unzip the attached jbpm-spring-dep-test-new.zip
2. cd jbpm-spring-dep-jar
3. mvn clean install
4. cd ../jbpm-spring-dep-kjar
5. mvn clean install
6. cd ../jbpm-spring-dep-main
7. mvn test

Actual results:

Results :

java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext

Expected results:

Test runs without error

Comment 1 Toshiya Kobayashi 2014-05-15 05:49:52 UTC
Created attachment 895714 [details]
jbpm-spring-dep-test-new.zip

Comment 2 Kris Verlaenen 2014-05-15 08:59:11 UTC
Maciej, might this be solved by similar previous fixes?

Comment 3 Maciej Swiderski 2014-05-15 11:05:51 UTC
this was indeed a bug with handling maven dependencies in kie-ci as it was only taking the direct dependencies of the project and not including transitive dependencies.

fixed on master

drools
master:
https://github.com/droolsjbpm/drools/commit/604f86c13596bc0d046753cacd8cd44221e09b60

Comment 5 Maciej Swiderski 2014-07-22 17:43:21 UTC
backported to 6.0.x branch

drools
6.0.x:
https://github.com/droolsjbpm/drools/commit/a5549b276c934ce3bb92249abfde606d11e67bab

Comment 6 Ivo Bek 2014-08-26 14:06:09 UTC
Verified in BPMS 6.0.3.ER1 (6.0.3-redhat-5)

Output of the test is following:

Starting ScriptTask
Calling Spring Service
Thread.currentThread().getContextClassLoader() = sun.misc.Launcher$AppClassLoader@3aeb203b
CheckServiceClient.class.getClassLoader() = java.net.URLClassLoader@7548fbb4
Aug 26, 2014 4:03:48 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1ab7e237: startup date [Tue Aug 26 16:03:48 CEST 2014]; root of context hierarchy
Aug 26, 2014 4:03:48 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from URL [jar:file:/home/ibek/.m2/repository/com/sample/jbpm-spring-dep-jar/1.0.0-SNAPSHOT/jbpm-spring-dep-jar-1.0.0-SNAPSHOT.jar!/checkservice.xml]
Aug 26, 2014 4:03:48 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@7eb6e1: defining beans [checkFeasibilityService]; root of factory hierarchy
context.getClassLoader() = java.net.URLClassLoader@7548fbb4
false
false
Completed ScriptTask
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 10.749 sec


Note You need to log in before you can comment on or make changes to this bug.