Expand my Community achievements bar.

SOLVED

How can I Fix Compilation error

Avatar

Level 2

Dear all,

 

 when I try to build the arm project ( man clean install) from my local instance , I am getting below error . 

 

 

INFO] -------------------------------------------------------------

[ERROR] COMPILATION ERROR : 

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

[ERROR] /Users/test/AEMAACS/wknd/aem-guides-wknd/core/src/test/java/com/adobe/aem/guides/wknd/core/servlets/SimpleServletTest.java:[39,22] cannot access org.apache.sling.resourcebuilder.api.ResourceBuilder

  class file for org.apache.sling.resourcebuilder.api.ResourceBuilder not found

[INFO] 1 error

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

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

[INFO] Reactor Summary for WKND Sites Project 0.0.1-SNAPSHOT:

[INFO] 

[INFO] WKND Sites Project ................................. SUCCESS [  0.153 s]

[INFO] WKND Sites Project - Core .......................... FAILURE [  1.395 s]

[INFO] WKND Sites Project - UI Frontend ................... SKIPPED

[INFO] WKND Sites Project - Repository Structure Package .. SKIPPED

[INFO] WKND Sites Project - UI apps ....................... SKIPPED

[INFO] WKND Sites Project - UI content .................... SKIPPED

[INFO] WKND Sites Project - UI config ..................... SKIPPED

[INFO] WKND Sites Project - All ........................... SKIPPED

[INFO] WKND Sites Project - Integration Tests ............. SKIPPED

[INFO] WKND Sites Project - Dispatcher .................... SKIPPED

[INFO] WKND Sites Project - UI Tests ...................... SKIPPED

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

[INFO] BUILD FAILURE

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

[INFO] Total time:  2.194 s

[INFO] Finished at: 2023-02-11T14:03:11+05:30

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

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile (default-testCompile) on project aem-guides-wknd.core: Compilation failure

[ERROR] /Users/test/AEMAACS/wknd/aem-guides-wknd/core/src/test/java/com/adobe/aem/guides/wknd/core/servlets/SimpleServletTest.java:[39,22] cannot access org.apache.sling.resourcebuilder.api.ResourceBuilder

[ERROR]   class file for org.apache.sling.resourcebuilder.api.ResourceBuilder not found

[ERROR] 

[ERROR] -> [Help 1]

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile (default-testCompile) on project aem-guides-wknd.core: Compilation failure

/Users/test/AEMAACS/wknd/aem-guides-wknd/core/src/test/java/com/adobe/aem/guides/wknd/core/servlets/SimpleServletTest.java:[39,22] cannot access org.apache.sling.resourcebuilder.api.ResourceBuilder

  class file for org.apache.sling.resourcebuilder.api.ResourceBuilder not found

 

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)

    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)

    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)

    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)

    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)

    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)

    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)

    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:282)

    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)

    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)

    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure

/Users/test/AEMAACS/wknd/aem-guides-wknd/core/src/test/java/com/adobe/aem/guides/wknd/core/servlets/SimpleServletTest.java:[39,22] cannot access org.apache.sling.resourcebuilder.api.ResourceBuilder

  class file for org.apache.sling.resourcebuilder.api.ResourceBuilder not found

 

    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1220)

    at org.apache.maven.plugin.compiler.TestCompilerMojo.execute (TestCompilerMojo.java:180)

    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)

    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)

    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)

    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)

    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)

    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)

    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)

    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:282)

    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)

    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)

    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

[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 :aem-guides-wknd.core

==========

Java / Maven Version 

Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T20:36:16+05:30)

Maven home: /Users/test/.sdkman/candidates/maven/current

Java version: 11.0.18, vendor: Azul Systems, Inc., runtime: /Users/test/.sdkman/candidates/java/11.0.18-zulu/zulu-11.jdk/Contents/Home

Default locale: en_IN, platform encoding: UTF-8

OS name: "mac os x", version: "13.1", arch: "aarch64", family: "mac"

===========

Dependencies are being resolved via Jfrog Artifactory . 

 

I appreciate your help

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@shaijuseb 

It seems that the org.apache.sling.resourcebuilder.api.ResourceBuilder class is missing in the classpath of your project. This error message is indicating that the class file for the ResourceBuilder class cannot be found.

To resolve this issue, you need to include the required dependencies in your project. This class is part of the org.apache.sling.resourcebuilder package, which is part of the Apache Sling Resource Builder bundle.

You can check the dependencies in your project's pom.xml file to see if the required bundle is already included. If it's not, you can add the following dependency to your pom.xml file:

 
<dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.resourcebuilder</artifactId> <version>2.2.0</version> <scope>test</scope> </dependency>

After adding the dependency, you can try to build the project again using the mvn clean install command. If the problem persists, you may need to check other dependencies in your project or the environment to see if there are any missing dependencies or conflicts with existing dependencies.

 
 
 

View solution in original post

8 Replies

Avatar

Level 5

Have you tried building core separately using mvn clean install -PautoInstallBundle?

Avatar

Level 2

Hi @nikita24tailor 

 

I tried to build the core separately and It resulted with same error .

====

INFO] -------------< com.adobe.aem.guides:aem-guides-wknd.core >--------------

[INFO] Building WKND Sites Project - Core 0.0.1-SNAPSHOT

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

[WARNING] The POM for org.apache.sling:org.apache.sling.api:jar:2.16.4 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

[WARNING] The POM for org.apache.jackrabbit:jackrabbit-jcr-commons:jar:2.16.0 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

[WARNING] The POM for org.apache.sling:org.apache.sling.resourceresolver:jar:1.5.34 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

[WARNING] The POM for org.apache.sling:org.apache.sling.settings:jar:1.3.8 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

[WARNING] The POM for org.apache.jackrabbit:jackrabbit-api:jar:2.16.0 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

[WARNING] The POM for org.apache.sling:org.apache.sling.testing.sling-mock.core:jar:3.2.2 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

[WARNING] The POM for org.apache.sling:org.apache.sling.testing.resourceresolver-mock:jar:1.2.4 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

[WARNING] The POM for org.apache.jackrabbit.vault:org.apache.jackrabbit.vault:jar:3.1.44 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

[WARNING] The POM for org.apache.sling:org.apache.sling.testing.caconfig-mock-plugin:jar:1.3.6 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

[INFO] 

[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ aem-guides-wknd.core ---

[INFO] Deleting /Users/test/Office/AEMAACS/wknd/aem-guides-wknd/core/target

[INFO] 

[INFO] --- maven-enforcer-plugin:3.0.0:enforce (enforce-maven) @ aem-guides-wknd.core ---

[INFO] 

[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ aem-guides-wknd.core ---

[INFO] Using 'UTF-8' encoding to copy filtered resources.

[INFO] skip non existing resourceDirectory /Users/testOffice/AEMAACS/wknd/aem-guides-wknd/core/src/main/resources

[INFO] 

[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ aem-guides-wknd.core ---

[INFO] Changes detected - recompiling the module!

[INFO] Compiling 10 source files to /Users/test/Office/AEMAACS/wknd/aem-guides-wknd/core/target/classes

[INFO] 

[INFO] --- bnd-maven-plugin:5.1.2:bnd-process (bnd-process) @ aem-guides-wknd.core ---

[WARNING] The POM for org.apache.sling:org.apache.sling.scripting.spi:jar:1.0.2 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

[WARNING] The POM for org.apache.jackrabbit:jackrabbit-spi-commons:jar:2.20.2 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

[INFO] 

[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ aem-guides-wknd.core ---

[INFO] Using 'UTF-8' encoding to copy filtered resources.

[INFO] skip non existing resourceDirectory /Users/test/Office/AEMAACS/wknd/aem-guides-wknd/core/src/test/resources

[INFO] 

[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ aem-guides-wknd.core ---

[INFO] Changes detected - recompiling the module!

[INFO] Compiling 6 source files to /Users/test/Office/AEMAACS/wknd/aem-guides-wknd/core/target/test-classes

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

[ERROR] COMPILATION ERROR : 

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

[ERROR] /Users/test/Office/AEMAACS/wknd/aem-guides-wknd/core/src/test/java/com/adobe/aem/guides/wknd/core/servlets/SimpleServletTest.java:[39,22] cannot access org.apache.sling.resourcebuilder.api.ResourceBuilder

  class file for org.apache.sling.resourcebuilder.api.ResourceBuilder not found

[INFO] 1 error

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

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

[INFO] BUILD FAILURE

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

[INFO] Total time:  1.706 s

[INFO] Finished at: 2023-02-14T12:23:20+05:30

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

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile (default-testCompile) on project aem-guides-wknd.core: Compilation failure

[ERROR] /Users/test/Office/AEMAACS/wknd/aem-guides-wknd/core/src/test/java/com/adobe/aem/guides/wknd/core/servlets/SimpleServletTest.java:[39,22] cannot access org.apache.sling.resourcebuilder.api.ResourceBuilder

[ERROR]   class file for org.apache.sling.resourcebuilder.api.ResourceBuilder not found

[ERROR] 

[ERROR] -> [Help 1]

[ERROR] 

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[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

 

====

Avatar

Community Advisor

Hi @shaijuseb ,

 

I was able to clone https://github.com/adobe/aem-guides-wknd.git and build successfully in my local using mvn clean install.

 

Can you please which version are you trying to build?

 

Thanks,

Chitra 

Avatar

Community Advisor

@shaijuseb it is working fine for me. I am expecting that this should be because of the Junit version that you have it in your local IDE. can you try build it seperatly and also make sure you follow the correct versions

 

for 6.5 

$ cd aem-guides-wknd/
$ mvn clean install -PautoInstallSinglePackage -Pclassic

 

 

Avatar

Employee Advisor

After cloning using https://github.com/adobe/aem-guides-wknd

 

DEBAL_DAS_1-1676194074997.png

 

 

I was able to build successfully as shown below -

 

DEBAL_DAS_0-1676194039725.png

 

Could you please check the system requirements here https://github.com/adobe/aem-guides-wknd and do compare.

 

Avatar

Correct answer by
Community Advisor

@shaijuseb 

It seems that the org.apache.sling.resourcebuilder.api.ResourceBuilder class is missing in the classpath of your project. This error message is indicating that the class file for the ResourceBuilder class cannot be found.

To resolve this issue, you need to include the required dependencies in your project. This class is part of the org.apache.sling.resourcebuilder package, which is part of the Apache Sling Resource Builder bundle.

You can check the dependencies in your project's pom.xml file to see if the required bundle is already included. If it's not, you can add the following dependency to your pom.xml file:

 
<dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.resourcebuilder</artifactId> <version>2.2.0</version> <scope>test</scope> </dependency>

After adding the dependency, you can try to build the project again using the mvn clean install command. If the problem persists, you may need to check other dependencies in your project or the environment to see if there are any missing dependencies or conflicts with existing dependencies.

 
 
 

Avatar

Level 2

hi @Jagadeesh_Prakash 

 

Thanks for the details . 

 

I was running the build behind  corporate Jforg artifcatory and intially the required dependencies are not properly downloading .nevertheless the class not found error really mislead me .

After configuring remote repo (repo1.maven.org) in Artifactory and adjusting the settings.xml , the build works perfectly.

 

Thanks to all for your valuable suggestions and feedback.