alfresco-sdk: ClassNotFoundException running Integration Tests

I’m submitting a …

[x] bug report
[ ] feature request

Expected Behavior

No ClassNotFoundException should be thrown at the end of running integration tests.

Current Behavior

The following exceptions are thrown at the end of running integration tests: (see stack trace/log excerpt in “Additional information” section). Please also note that the build/goal is marked as “BUILD SUCCESS” and everything seems to be fine (i.e. the integration tests have been executed successfully).

Possible Solution

A first idea is that the mentioned classes are not available in the classpath when stopping the embedded tomcat / end of build lifecycle.

Steps to Reproduce (for bugs)

  1. Create a new AIO Alfresco SDK 3 project.
  2. Run “mvn verify” in the AIO project
  3. Wait until the end
  4. Check log messages

Context

n/a

Your Environment

  • Alfresco SDK version used: 3.0 Release
  • Alfresco version used: 5.2 Enterprise/Community
  • Output of command ‘mvn -version’: Apache Maven 3.3.9

Additional information

Stack Trace/Log excerpt:

[INFO] ------------------------------------------------------------------------

[INFO] Reactor Summary:

[INFO] 

[INFO] AIO - SDK 3.0 Beta ................................. SUCCESS [  0.864 s]

[INFO] Alfresco Platform/Repository JAR Module ............ SUCCESS [  9.461 s]

[INFO] Alfresco Share JAR Module .......................... SUCCESS [  0.659 s]

[INFO] Integration Tests Module ........................... SUCCESS [05:10 min]

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 05:22 min

[INFO] Finished at: 2017-04-19T14:46:04+02:00

[INFO] Final Memory: 375M/1828M

[INFO] ------------------------------------------------------------------------

java.lang.NoClassDefFoundError: de/schlichtherle/truezip/fs/FsLockController$1Sync
	at de.schlichtherle.truezip.fs.FsLockController.sync(FsLockController.java:240)
	at de.schlichtherle.truezip.fs.archive.zip.KeyController.sync(KeyController.java:128)
	at de.schlichtherle.truezip.fs.FsDecoratingController.sync(FsDecoratingController.java:131)
	at de.schlichtherle.truezip.fs.FsFalsePositiveArchiveController.sync(FsFalsePositiveArchiveController.java:480)
	at de.schlichtherle.truezip.fs.FsManager.sync(FsManager.java:105)
	at de.schlichtherle.truezip.fs.FsDefaultManager.sync(FsDefaultManager.java:190)
	at de.schlichtherle.truezip.fs.FsSyncShutdownHook$Hook.run(FsSyncShutdownHook.java:93)
Caused by: java.lang.ClassNotFoundException: de.schlichtherle.truezip.fs.FsLockController$1Sync
	at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
	... 7 more
Exception in thread "Thread-4" java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils
	at org.apache.tomcat.maven.plugin.tomcat7.run.RunMojo$1.run(RunMojo.java:140)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.FileUtils
	at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
	... 1 more
ERROR: IllegalAccessException for stop method in class org.apache.tomcat.maven.plugin.tomcat7.run.ExtendedTomcat
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.tomcat.maven.common.run.EmbeddedRegistry.shutdownAll(EmbeddedRegistry.java:110)
	at org.apache.tomcat.maven.common.run.EmbeddedRegistry$1.run(EmbeddedRegistry.java:69)
Caused by: org.apache.catalina.LifecycleException: Failed to stop component [StandardServer[-1]]
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:236)
	at org.apache.catalina.startup.Tomcat.stop(Tomcat.java:351)
	... 6 more
Caused by: org.apache.catalina.LifecycleException: Failed to stop component [StandardService[Tomcat]]
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:236)
	at org.apache.catalina.core.StandardServer.stopInternal(StandardServer.java:753)
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
	... 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to stop component [StandardEngine[Tomcat]]
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:236)
	at org.apache.catalina.core.StandardService.stopInternal(StandardService.java:502)
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
	... 9 more
Caused by: java.lang.NoClassDefFoundError: org/apache/catalina/core/ContainerBase$StopChild
	at org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:1173)
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
	... 11 more
Caused by: java.lang.ClassNotFoundException: org.apache.catalina.core.ContainerBase$StopChild
	at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
	... 13 more

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 7
  • Comments: 16

Most upvoted comments

+1. I’ve the same thing.

I am having the same problem, and it’s with an empty getting-started sample. The SDK 3.0.1 is NOT working out-of-the-box.

+1 - same thing (albeit with platform-jar-archetype).

I’m submitting a …

[x] bug report
[ ] feature request

Expected Behavior

No ClassNotFoundException should be thrown at the end of running integration tests.

Current Behavior

The following exceptions are thrown at the end of running integration tests: (see stack trace/log excerpt in “Additional information” section). Please also note that the build/goal is marked as “BUILD SUCCESS” and everything seems to be fine (i.e. the integration tests have been executed successfully).

Possible Solution

A first idea is that the mentioned classes are not available in the classpath when stopping the embedded tomcat / end of build lifecycle.

Steps to Reproduce (for bugs)

  1. Create a new AIO Alfresco SDK 3 project.
  2. Run “mvn verify” in the AIO project
  3. Wait until the end
  4. Check log messages

Context

n/a

Your Environment

  • Alfresco SDK version used: 3.0 Release
  • Alfresco version used: 5.2 Enterprise/Community
  • Output of command ‘mvn -version’: Apache Maven 3.3.9

Additional information

Stack Trace/Log excerpt:

[INFO] ------------------------------------------------------------------------

[INFO] Reactor Summary:

[INFO] 

[INFO] AIO - SDK 3.0 Beta ................................. SUCCESS [  0.864 s]

[INFO] Alfresco Platform/Repository JAR Module ............ SUCCESS [  9.461 s]

[INFO] Alfresco Share JAR Module .......................... SUCCESS [  0.659 s]

[INFO] Integration Tests Module ........................... SUCCESS [05:10 min]

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 05:22 min

[INFO] Finished at: 2017-04-19T14:46:04+02:00

[INFO] Final Memory: 375M/1828M

[INFO] ------------------------------------------------------------------------

java.lang.NoClassDefFoundError: de/schlichtherle/truezip/fs/FsLockController$1Sync
	at de.schlichtherle.truezip.fs.FsLockController.sync(FsLockController.java:240)
	at de.schlichtherle.truezip.fs.archive.zip.KeyController.sync(KeyController.java:128)
	at de.schlichtherle.truezip.fs.FsDecoratingController.sync(FsDecoratingController.java:131)
	at de.schlichtherle.truezip.fs.FsFalsePositiveArchiveController.sync(FsFalsePositiveArchiveController.java:480)
	at de.schlichtherle.truezip.fs.FsManager.sync(FsManager.java:105)
	at de.schlichtherle.truezip.fs.FsDefaultManager.sync(FsDefaultManager.java:190)
	at de.schlichtherle.truezip.fs.FsSyncShutdownHook$Hook.run(FsSyncShutdownHook.java:93)
Caused by: java.lang.ClassNotFoundException: de.schlichtherle.truezip.fs.FsLockController$1Sync
	at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
	... 7 more
Exception in thread "Thread-4" java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils
	at org.apache.tomcat.maven.plugin.tomcat7.run.RunMojo$1.run(RunMojo.java:140)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.FileUtils
	at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
	... 1 more
ERROR: IllegalAccessException for stop method in class org.apache.tomcat.maven.plugin.tomcat7.run.ExtendedTomcat
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.tomcat.maven.common.run.EmbeddedRegistry.shutdownAll(EmbeddedRegistry.java:110)
	at org.apache.tomcat.maven.common.run.EmbeddedRegistry$1.run(EmbeddedRegistry.java:69)
Caused by: org.apache.catalina.LifecycleException: Failed to stop component [StandardServer[-1]]
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:236)
	at org.apache.catalina.startup.Tomcat.stop(Tomcat.java:351)
	... 6 more
Caused by: org.apache.catalina.LifecycleException: Failed to stop component [StandardService[Tomcat]]
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:236)
	at org.apache.catalina.core.StandardServer.stopInternal(StandardServer.java:753)
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
	... 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to stop component [StandardEngine[Tomcat]]
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:236)
	at org.apache.catalina.core.StandardService.stopInternal(StandardService.java:502)
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
	... 9 more
Caused by: java.lang.NoClassDefFoundError: org/apache/catalina/core/ContainerBase$StopChild
	at org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:1173)
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
	... 11 more
Caused by: java.lang.ClassNotFoundException: org.apache.catalina.core.ContainerBase$StopChild
	at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
	... 13 more

The below command solved my problem mvn dependency:resolve

I can confirm that it is related to the JVM shutdown hooks not playing nicely with the maven lifecycle and classloading.

When I remove all shutdown hooks the exception messages are no longer displayed. 👍

This was tested by removing the shutdown hooks before the tests end. Removing those hooks is a bit of a hack:

private void removeShutdownHooks() throws ReflectiveOperationException {
    @SuppressWarnings("rawtypes")
    Class clazz = Class.forName("java.lang.ApplicationShutdownHooks");
    Field field = clazz.getDeclaredField("hooks");
    field.setAccessible(true);

    @SuppressWarnings("unchecked")
    Map<Thread, Thread> hooks = (Map<Thread, Thread>)field.get(null);
    hooks.clear();
}