When you compile custom JSP files in Adobe Experience Manager (AEM) on a Java 8 environment, issues with autoboxing and scalar types can cause the compilation to fail.

An error similar to the following appears:

java.lang.Error: Unresolved compilation problem:
Type mismatch: cannot convert from Integer too long

In particular, the compilation fails when the compiler encounters statements, such as the following: 

long l = conf.get("foo", 1);

Solution

Make the following changes to the statement, which compiles your JSP file with all java versions/compilers:

long l = conf.get("foo", 1L);

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy