Skip to content

Tests Error when building the project code #1252

@ngzhekai

Description

@ngzhekai

Issue with building the project code

Generated a project using the following commands:

mvn -B org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate \
 -D archetypeGroupId=com.adobe.aem \
 -D archetypeArtifactId=aem-project-archetype \
 -D archetypeVersion=51\
 -D appTitle="My Site" \
 -D appId="mysite" \
 -D groupId="com.mysite" \
 -D aemVersion=6.5.0

Encountered errors when I proceed to Deploy and Build the project with the following command:

mvn clean install -X -PautoInstallSinglePackage

Expected Behaviour

Console to log "BUILD SUCCESS"

Actual Behaviour

Expand to View the Console Log
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 23.671 s <<< FAILURE! - in com.mysite.core.filters.LoggingFilterTest
[ERROR] doFilter{AemContext}  Time elapsed: 22.509 s  <<< ERROR!
org.junit.jupiter.api.extension.ParameterResolutionException: Failed to resolve parameter [io.wcm.testing.mock.aem.junit5.AemContext arg0] in method [void com.mysite.core.filters.LoggingFilterTest.doFilter(io.wcm.testing.mock.aem.junit5.AemContext) throws java.io.IOException,javax.servlet.ServletException]: org.apache.commons.collections4.SetUtils.unmodifiableSet([Ljava/lang/Object;)Ljava/util/Set;
Caused by: java.lang.NoSuchMethodError: org.apache.commons.collections4.SetUtils.unmodifiableSet([Ljava/lang/Object;)Ljava/util/Set;

[INFO] Running com.mysite.core.listeners.SimpleResourceListenerTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.045 s - in com.mysite.core.listeners.SimpleResourceListenerTest
[INFO] Running com.mysite.core.models.HelloWorldModelTest
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.199 s <<< FAILURE! - in com.mysite.core.models.HelloWorldModelTest
[ERROR] testGetMessage  Time elapsed: 0.001 s  <<< ERROR!
java.lang.NoClassDefFoundError: Could not initialize class com.adobe.cq.wcm.core.components.internal.link.LinkManagerImpl
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.NoSuchMethodError: org.apache.commons.collections4.SetUtils.unmodifiableSet([Ljava/lang/Object;)Ljava/util/Set; [in thread "main"]

[INFO] Running com.mysite.core.schedulers.SimpleScheduledTaskTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 10.13 s - in com.mysite.core.schedulers.SimpleScheduledTaskTest
[INFO] Running com.mysite.core.servlets.SimpleServletTest
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.094 s <<< FAILURE! - in com.mysite.core.servlets.SimpleServletTest
[ERROR] doGet{AemContext}  Time elapsed: 0.041 s  <<< ERROR!
org.junit.jupiter.api.extension.ParameterResolutionException: Failed to resolve parameter [io.wcm.testing.mock.aem.junit5.AemContext arg0] in method [void com.mysite.core.servlets.SimpleServletTest.doGet(io.wcm.testing.mock.aem.junit5.AemContext) throws javax.servlet.ServletException,java.io.IOException]: Could not initialize class com.adobe.cq.wcm.core.components.internal.link.LinkManagerImpl
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.adobe.cq.wcm.core.components.internal.link.LinkManagerImpl
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.NoSuchMethodError: org.apache.commons.collections4.SetUtils.unmodifiableSet([Ljava/lang/Object;)Ljava/util/Set; [in thread "main"]

[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR]   LoggingFilterTest.doFilter ┬╗ ParameterResolution Failed to resolve parameter [...
[ERROR]   HelloWorldModelTest.testGetMessage ┬╗ NoClassDefFound Could not initialize clas...
[ERROR]   SimpleServletTest.doGet ┬╗ ParameterResolution Failed to resolve parameter [io....
[INFO]
[ERROR] Tests run: 5, Failures: 0, Errors: 3, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] My Site 1.0.0-SNAPSHOT ............................. SUCCESS [  1.040 s]
[INFO] My Site - Core 1.0.0-SNAPSHOT ...................... FAILURE [01:06 min]
[INFO] My Site - UI Frontend 1.0.0-SNAPSHOT ............... SKIPPED
[INFO] My Site - Repository Structure Package 1.0.0-SNAPSHOT SKIPPED
[INFO] My Site - UI apps 1.0.0-SNAPSHOT ................... SKIPPED
[INFO] My Site - UI content 1.0.0-SNAPSHOT ................ SKIPPED
[INFO] My Site - UI config 1.0.0-SNAPSHOT ................. SKIPPED
[INFO] My Site - All 1.0.0-SNAPSHOT ....................... SKIPPED
[INFO] My Site - Integration Tests 1.0.0-SNAPSHOT ......... SKIPPED
[INFO] My Site - Dispatcher 1.0.0-SNAPSHOT ................ SKIPPED
[INFO] com.adobe.cq.cloud.testing.ui.cypress - UI Tests 0.0.1-SNAPSHOT SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:11 min
[INFO] Finished at: 2024-11-20T09:50:03+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project mysite.core: There are test failures.
[ERROR]
[ERROR] Please refer to /mnt/c/AEM-Test/project/mysite/core/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project mysite.core: There are test failures.

Please refer to /mnt/c/AEM-Test/project/mysite/core/target/surefire-reports for the individual test results.
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:333)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:255)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:201)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:361)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:314)
Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures.

Please refer to /mnt/c/AEM-Test/project/mysite/core/target/surefire-reports for the individual test results.
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
    at org.apache.maven.plugin.surefire.SurefireHelper.throwException (SurefireHelper.java:289)
    at org.apache.maven.plugin.surefire.SurefireHelper.reportExecution (SurefireHelper.java:161)
    at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary (SurefirePlugin.java:364)
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked (AbstractSurefireMojo.java:1041)
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute (AbstractSurefireMojo.java:857)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:255)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:201)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:361)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:314)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :mysite.core
[DEBUG] Shutting down adapter factory; available factories [file-lock, rwlock-local, semaphore-local, noop]; available name mappers [discriminating, file-gav, file-hgav, file-static, gav, static]
[DEBUG] Shutting down 'file-lock' factory
[DEBUG] Shutting down 'rwlock-local' factory
[DEBUG] Shutting down 'semaphore-local' factory
[DEBUG] Shutting down 'noop' factory

Steps to Reproduce

Just follow the guides in the reference section to build and deploy the project code to a local instance of AEM.

Platform and Version

OS: Ubuntu 24.04.1 LTS on Windows 10 x86_64
Platform: 5.15.167.4-microsoft-standard-wsl2 (WSL)
Apache Maven: 3.9.9
Java: 11.0.23

Reference

https://experienceleague.adobe.com/en/docs/experience-manager-learn/getting-started-wknd-tutorial-develop/project-archetype/project-setup

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions