[MDSAL-165] Suspicious NoClassDefFoundError/ClassNotFoundException in trivial BindingGeneratorUtilTest when running Maven in parallel Created: 11/May/16  Updated: 09/Mar/18  Resolved: 28/Jun/16

Status: Resolved
Project: mdsal
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Michael Vorburger Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 5874

 Description   

I've hit the NoClassDefFoundError/ClassNotFoundException below when running parallel Maven build, in mdsal (root):

mvn -T 1.5C clean install

Q: Is Maven (maven-surefire-plugin) known to be simply completely broken for parallel Maven builds, or should this work, normally?

Could this be an indication of a bigger problem somewhere in ODL code? As you know, I don't know much about anything just yet (but am eager to learn..), but have stumbled upon our org.opendaylight.yangtools.util.ClassLoaderUtils (AKA @Deprecated org.opendaylight.yangtools.yang.binding.util.ClassLoaderUtils - can I put in a Gerrit change to cleanly remove that?) related to ClassLoader and Thread setContextClassLoader magic .. perhaps something subtle wrong in that area?

FYI I'm also trying to get to the bottom of YANGIDE-10 (class loading problem in yangide) - wondering if there could be a connection.

[INFO] — maven-surefire-plugin:2.18.1:test (default-test) @ mdsal-binding-generator-util —
[INFO] Surefire report directory: /home/vorburger/dev/ODL/git/mdsal/binding/mdsal-binding-generator-util/target/surefire-reports
Downloading: http://nexus.opendaylight.org/content/repositories/public/org/apache/maven/surefire/surefire-junit3/2.18.1/surefire-junit3-2.18.1.pom
Downloaded: http://nexus.opendaylight.org/content/repositories/public/org/apache/maven/surefire/surefire-junit3/2.18.1/surefire-junit3-2.18.1.pom (2 KB at 3.0 KB/sec)
Downloading: http://nexus.opendaylight.org/content/repositories/public/org/apache/maven/surefire/surefire-junit3/2.18.1/surefire-junit3-2.18.1.jar
Downloading: http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/yangtools/mockito-configuration/1.0.0-SNAPSHOT/mockito-configuration-1.0.0-20160511.100431-121.jar
Downloaded: http://nexus.opendaylight.org/content/repositories/public/org/apache/maven/surefire/surefire-junit3/2.18.1/surefire-junit3-2.18.1.jar (25 KB at 37.3 KB/sec)

-------------------------------------------------------
T E S T S
-------------------------------------------------------
Downloaded: http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/yangtools/mockito-configuration/1.0.0-SNAPSHOT/mockito-configuration-1.0.0-20160511.100431-121.jar (11 KB at 19.8 KB/sec)
Running org.opendaylight.yangtools.binding.generator.util.BindingTypesTest
Tests run: 2, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.92 sec <<< FAILURE! - in org.opendaylight.yangtools.binding.generator.util.BindingTypesTest
org.opendaylight.yangtools.binding.generator.util.BindingTypesTest.testAugmentable() Time elapsed: 0.893 sec <<< FAILURE!
java.lang.NoClassDefFoundError: org/junit/Assert
at org.opendaylight.yangtools.binding.generator.util.BindingTypesTest.testAugmentable(BindingTypesTest.java:48)
Caused by: java.lang.ClassNotFoundException: org.junit.Assert
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 13 more

org.opendaylight.yangtools.binding.generator.util.BindingTypesTest.testChildOf() Time elapsed: 0.001 sec <<< FAILURE!
java.lang.NoClassDefFoundError: org/junit/Assert
at org.opendaylight.yangtools.binding.generator.util.BindingTypesTest.testChildOf(BindingTypesTest.java:54)

Results :

Failed tests:
org.opendaylight.yangtools.binding.generator.util.BindingTypesTest#testAugmentable NoClassDefFoundError
org.opendaylight.yangtools.binding.generator.util.BindingTypesTest#testChildOf NoClassDefFoundError

Tests run: 2, Failures: 2, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] mdsal-parent ....................................... SUCCESS [ 16.750 s]
[INFO] mdsal-artifacts .................................... SUCCESS [ 11.413 s]
[INFO] mdsal-common-api ................................... SUCCESS [01:51 min]
[INFO] mdsal-dom .......................................... SUCCESS [ 4.306 s]
[INFO] mdsal-dom-api ...................................... SKIPPED
[INFO] mdsal-dom-spi ...................................... SKIPPED
[INFO] mdsal-dom-inmemory-datastore ....................... SKIPPED
[INFO] mdsal-dom-broker ................................... SKIPPED
[INFO] mdsal-binding ...................................... SUCCESS [ 5.822 s]
[INFO] yang-binding ....................................... SUCCESS [01:47 min]
[INFO] mdsal-binding-generator-api ........................ SUCCESS [ 39.720 s]
[INFO] mdsal-binding-generator-util ....................... FAILURE [ 8.858 s]
[INFO] mdsal-binding-generator-impl ....................... SKIPPED
[INFO] binding-parent ..................................... SUCCESS [ 16.663 s]
[INFO] model-parent ....................................... SUCCESS [ 2.863 s]
[INFO] mdsal-binding-java-api-generator ................... SKIPPED
[INFO] maven-sal-api-gen-plugin ........................... SKIPPED
[INFO] yang-ext ........................................... SKIPPED
[INFO] mdsal-binding-test-model ........................... SKIPPED
[INFO] mdsal-binding-dom-codec ............................ SKIPPED
[INFO] general-entity ..................................... SKIPPED
[INFO] mdsal-binding-api .................................. SKIPPED
[INFO] mdsal-binding-util ................................. SKIPPED
[INFO] mdsal-binding-dom-adapter .......................... SKIPPED
[INFO] features-mdsal ..................................... SKIPPED
[INFO] md-sal ............................................. SUCCESS [ 4.043 s]
[INFO] mdsal-binding2 ..................................... SUCCESS [ 3.362 s]
[INFO] mdsal-binding2-spec ................................ SUCCESS [01:45 min]
[INFO] model-iana ......................................... SKIPPED
[INFO] iana-afn-safi ...................................... SKIPPED
[INFO] model-ietf ......................................... SKIPPED
[INFO] ietf-type-util ..................................... SKIPPED
[INFO] ietf-inet-types .................................... SKIPPED
[INFO] ietf-yang-types-20130715 ........................... SKIPPED
[INFO] ietf-interfaces .................................... SKIPPED
[INFO] iana-if-type-2014-05-08 ............................ SKIPPED
[INFO] ietf-restconf ...................................... SKIPPED
[INFO] ietf-yang-types .................................... SKIPPED
[INFO] opendaylight-l2-types .............................. SKIPPED
[INFO] ietf-ted ........................................... SKIPPED
[INFO] ietf-topology ...................................... SKIPPED
[INFO] ietf-topology-l3-unicast-igp ....................... SKIPPED
[INFO] ietf-topology-isis ................................. SKIPPED
[INFO] ietf-topology-ospf ................................. SKIPPED
[INFO] ietf-network-2015-06-08 ............................ SKIPPED
[INFO] ietf-inet-types-2013-07-15 ......................... SKIPPED
[INFO] features-mdsal-model ............................... SKIPPED
[INFO] mdsal-model-artifacts .............................. SUCCESS [ 11.409 s]
[INFO] iana-if-type ....................................... SKIPPED
[INFO] md-sal ............................................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 03:04 min (Wall Clock)
[INFO] Finished at: 2016-05-11T12:07:18+02:00
[INFO] Final Memory: 181M/945M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project mdsal-binding-generator-util: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test failed: There was an error in the forked process
[ERROR] java.lang.NoClassDefFoundError: org/junit/rules/ExpectedException
[ERROR] at org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtilTest.<init>(BindingGeneratorUtilTest.java:60)
[ERROR] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[ERROR] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[ERROR] at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[ERROR] at java.lang.Class.newInstance(Class.java:442)
[ERROR] at org.apache.maven.surefire.junit.PojoTestSet.<init>(PojoTestSet.java:67)
[ERROR] at org.apache.maven.surefire.junit.JUnit3Provider.createTestSet(JUnit3Provider.java:116)
[ERROR] at org.apache.maven.surefire.junit.JUnit3Provider.invoke(JUnit3Provider.java:106)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
[ERROR] Caused by: java.lang.ClassNotFoundException: org.junit.rules.ExpectedException
[ERROR] at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
[ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[ERROR] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
[ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[ERROR] ... 12 more
[ERROR] -> [Help 1]



 Comments   
Comment by Michael Vorburger [ 11/May/16 ]

> AKA @Deprecated org.opendaylight.yangtools.yang.binding.util.ClassLoaderUtils - can I put in a Gerrit change to cleanly remove that?

https://git.opendaylight.org/gerrit/38656

Comment by Michael Vorburger [ 11/May/16 ]

> our org.opendaylight.yangtools.util.ClassLoaderUtils related to ClassLoader and Thread setContextClassLoader magic .. perhaps something subtle wrong in that area?

Upon a closer look, the only setContextClassLoader (which is what I was worried about) is in withClassLoader(final ClassLoader cls, final Callable<V> function) that does a reset to oldCls in a finally block.. looks safe. Hm.

Comment by Michael Vorburger [ 11/May/16 ]

> when running parallel Maven build, in mdsal (root): mvn -T 1.5C clean install

On a second identical run, it went through just fine of course - so this must be some concurrency issue.. Maven bug, or ODL ClassLoader wrangling gone wrong?

Comment by Robert Varga [ 21/Jun/16 ]

Is this still reproducible?

Comment by Martin Ciglan [ 27/Jun/16 ]

I suggest to move this discussion to mailing lists and close this ticket

Comment by Michael Vorburger [ 27/Jun/16 ]

I'll retry this and come back ASAP whether still reproducible ..

Comment by Michael Vorburger [ 28/Jun/16 ]

Actually, it appears to work now - I cannot reproduce the error above anymore.

Of course, this most likely has nothing to do with mdsal. I suspect some update which skitt recently did in odlparent to get us more recent Maven stuff may have helped? Although maven-surefire-plugin is still 2.18.1 now (like above; current latest is 2.19.1).

$ mvno -T 1.5C clean install
[INFO] Total time: 06:38 min (Wall Clock)

$ mvno clean install
[INFO] Total time: 09:08 min

Thus closing as RESOLVED WORKSFORME.

Comment by Martin Ciglan [ 28/Jun/16 ]

thank you

Generated at Wed Feb 07 20:08:49 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.