Problem compiling JSP files on Java 8 environment

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);

Get help faster and easier

New user?