AEM project app cannot resolve package dependency in core

pa_dc

09-04-2020

Hey everyone,

 

I have an AEM project where a utility class is found in the core module and is referenced in the apps module in an asset.jsp overlay. However, whenever I attempt to bring up the page in AEM which uses the overlay I am getting an exception that the overlay could not be compiled because this the module reference class could not be found.

 

Any help would be appreciated.

 

Error Log

==> error.log <==

09.04.2020 00:18:38.206 *ERROR* [0:0:0:0:0:0:0:1 [1586416718199] GET /mnt/overlay/dam/gui/content/assets/jcr:content/views/list.0.40.html/content/dam/site/aem/jobnumber/assetfolder HTTP/1.1] org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Uncaught SlingException

org.apache.sling.scripting.jsp.jasper.JasperException: Unable to compile class for JSP:

 

An error occurred at line: 7 in the generated java file

Only a type can be imported. com.site.assets.core.utils.statusutil resolves to a package

at org.apache.sling.scripting.jsp.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:93)

at org.apache.sling.scripting.jsp.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)

at org.apache.sling.scripting.jsp.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:136)

at org.apache.sling.scripting.jsp.jasper.compiler.Compiler.compile(Compiler.java:304)

at org.apache.sling.scripting.jsp.jasper.compiler.Compiler.compile(Compiler.java:282)

at org.apache.sling.scripting.jsp.jasper.compiler.Compiler.compile(Compiler.java:269)

at org.apache.sling.scripting.jsp.jasper.JspCompilationContext.compile(JspCompilationContext.java:501)

at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.prepareServlet(JspServletWrapper.java:427)

at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:486)

at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:449)

at org.apache.sling.scripting.jsp.JspScriptEngineFactory.callJsp(JspScriptEngineFactory.java:346)

at org.apache.sling.scripting.jsp.JspScriptEngineFactory.access$100(JspScriptEngineFactory.java:101)

 

site.core POM

<plugins>
<plugin>
<groupId>org.apache.sling</groupId>
<artifactId>maven-sling-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Import-Package>!com.csvreader.*,javax.inject;version=0.0.0,*</Import-Package>
<Sling-Model-Packages>
com.site.assets.core
</Sling-Model-Packages>
</instructions>
</configuration>
</plugin>
</plugins> 

 

asset.jsp Imports

<%@page import="org.apache.sling.api.resource.Resource"%>
<%@page import="com.site.assets.core.utils.statusutil"%>
<%@taglib prefix="cq" uri="http://www.day.com/taglibs/cq/1.0"%>
<%@include file="/libs/dam/gui/coral/components/admin/contentrenderer/base/init/assetBase.jsp"%>
<%@include file="/libs/dam/gui/coral/components/admin/contentrenderer/base/insightBase.jsp"%>
<%@include file="/libs/dam/gui/coral/components/admin/contentrenderer/row/common/common.jsp"%>

 

AEM 6.3 AEM Assets

Accepted Solutions (1)

Accepted Solutions (1)

Theo_Pendle

MVP

09-04-2020

Hi,

The error seems quite informative to me: 

Only a type can be imported. com.site.assets.core.utils.statusutil resolves to a package

So what are you trying to import exactly?

  1. If com.site.assets.core.utils.statusutil is meant to be a class then:
    1. Make sure it actually is a class
    2. Change the name to reflect that fact (should be StatsUtil not statsutil)

  2. If com.site.assets.core.utils.statusutil is a package then:
    1. Fix the import to import the class in question (eg: com.site.assets.core.utils.statusutil.StatsUtil)
    2. Fix the import to import all classes in the package (eg. com.site.assets.core.utils.statusutil.*)

Also, make sure thal all your packages include a package-info.java file.

Answers (0)