Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

AEM 6.2 with Java 8 - JSP Compilation issues

Avatar

Level 2

Hi,

We have recently upgraded from AEM 5.6.1 to AEM 6.2 on java 7. Now we are in middle of upgrading our java version as well. When we upgrade to Java 8 and build, the java classes are getting compiled fine. but jsp files are getting below errors

  1. java.lang.CharSequence can not be resolved. It id indirectly referenced from .class files.
  2. Arrays can not be resolved.

The same code seems to work on java 7. We tried searching for same over web but people have mentioned solutions w.r.t eclipse jre update. In our case build is failing when maven-jspc-plugin is trying to compile the jsp files. If we exclude the plugin, the build works fine but this can not be excluded since it hints out possibility of error during compile time instead of seeing error on CQ5 pages.

15 Replies

Avatar

Employee

Was the jsp already compiled with java7?

Avatar

Level 2
        yes they were getting compiled with java 7. Even though when we are building it without plugin,  they are getting rendered on pages perfectly fine. Its the maven plugin which is not allowing to compile those files with java 8.

Even i'm facing similar issue . Were you able to fix the above issue ? 

Avatar

Level 2

Hi Team,

We are also facing similar issue . Can anyone able to fix the issue.

Avatar

Employee

Try this

1. locate "Apache Sling Commons FileSystem ClassLoader" in /system/console/bundles

2. on the filesystem go to crx-quickstart/launchpad/felix

3. go to bundle<id-from-step1>

4. stop AEM

5. remove data/classes

6. start AEM

Avatar

Level 2

Thanks Feike Visser for the reply.

But we are getting error when we are doing COMPILATION , command "mvn clean install" .

Actually it is happening before installing in AEM .

When we compile with java1.7 it is working fine but when we compile with java1.8 this error is coming (JSP compilation).

One more point : The compiled code with 1.7 have no issues and successfully running in AEM 6.1/6,2 which is running on JAVA1.8 .

So only the problem with compilation.

Avatar

Employee Advisor

"mvn clean install" is typically not compiling JSPs, unlike you have the jspc plugin doing it.

When you say "upgrading to Java 8", do you mean you upgrade the build to Java 8 or do you refer to the runtime (that means the JVM version you use to run AEM)? At best you use both at Java 8.

Jörg

Avatar

Level 2

Hi Jorg,

As mentioned in initial description by @khannapiyush36  , we are also using maven-jspc-plugin for compilation.

The build with Java 8 is giving those errors (failing).

AEM is successfully running on JAVA8 .

note: Local JAVA_HOME set to JAVA1.8 only.

To deploy our code , we have to build code using maven , while doing the compilation , getting those errors (same as mentioned in the initial description of this forum topic) and build is failing.

Avatar

Employee Advisor

That's indeed very strange. I assume that you are using a JDK and not a JRE for building.

Have you updated the JSPC plugin to the latest version?

Jörg

Avatar

Level 2

We have tried updating "jspc-maven-plugin" from 2.0.8 to 2.1.0 , then we get different error for other jsp's.


[ERROR] Failed to execute goal org.apache.sling:jspc-maven-plugin:2.1.0:jspc (co

mpile-jsp) on project upc-generic: Execution compile-jsp of goal org.apache.slin

g:jspc-maven-plugin:2.1.0:jspc failed: A required class was missing while execut

ing org.apache.sling:jspc-maven-plugin:2.1.0:jspc: com/fasterxml/jackson/core/Js

onProcessingException

[ERROR] -----------------------------------------------------

[ERROR] realm =    plugin>org.apache.sling:jspc-maven-plugin:2.1.0

Avatar

Employee Advisor

Make sure that you include a dependency to your pom which provides com.fasterxml. For AEM 6.4 it can be this:

<dependency>

  <artifactId>jackson-core</artifactId>

  <version>2.8.4</version>

  <groupId>com.fasterxml.jackson.core</groupId>

  <scope>provided</scope>

</dependency>

Jörg

Avatar

Level 2

Hi Jörg,

In our parent POM , we have already below

<dependency>

                <groupId>com.fasterxml.jackson.core</groupId>

                <artifactId>jackson-core</artifactId>

                <version>2.3.3</version>

                 <scope>compile</scope>

</dependency>

and as you mentioned tried with version 2.8.4 also , but same error.

Thanks,

Madhav

Avatar

Employee Advisor

Hm, then it's getting weird.

I don't have experience with the JSPC plugin, so remote diagnosing your build is hard. Can you put a minimal example where this problem happens and make it available (e.g. via github), so we can have a better look at it?

Jörg

Avatar

Level 2

Hi Jörg,

Thanks for your comment and support.

But we are able to resolve the issue.

Changes done to resolve:-

1) Updated Parent POM JSPC plugin to 2.1.0 from 2.0.8

<artifactId>jspc-maven-plugin</artifactId>

  <version>2.1.0</version>

2) jackson-core and one more external (sprint freemarker) dependencies are added in App project/POM as well where we have jsp's, clentlibs with packaging plugin .

Generally/Previously these are added in CORE/POM (where we have JAVA classes including taglibs) and there was no issues, technically here only we have to mention all dependencies to compile java classes.

But when using new version of maven-jspc-plugin with JAVA1.8 , it is not able to compile the jsps (if any jsp has taglib or scriptlet code which java class has some external dependency) , so we have tried adding those specific dependencies  in the App/POM also and it solved the problem

Thanks,

Madhav

Avatar

Employee Advisor

Hi Madhav,

thanks for posting the resolution to your issue. In hindsight, it makes sense to add the dependency to the maven project which is using the jspc plugin :-)

Jörg