Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

Unable to compile the JSP file

Avatar

Level 6

Hi Team,

  This is the  code written to build the packages. I am running this in AEM6.2. It's returning the below error "Unable to compile class for JSP: An error occurred at line: 51 in the generated java file Only a type can be imported. com.day.cq.packaging.CQPackageManager resolves to a package An error occurred at line: 82 in the jsp file: /apps/tools/components/listPage/createPackage.jsp CQPackageManager cannot be resolved to a type 79: packages.getNode(packPath).remove(); 80: packages.getSession().save(); 81: } 82: CQPackageManager pckgManager = sling.getService(CQPackageManager.class); 83: JcrPackage pack = pckgManager.createPackage(sess,pkgGroupName,packageName); 84: pckgManager.ensureVersion(pack); 85: DefaultWorkspaceFilter filters = new DefaultWorkspaceFilter(); An error occurred at line: 82 in the jsp file: /apps/tools/components/listPage/createPackage.jsp CQPackageManager cannot be resolved to a type 79: packages.getNode(packPath).remove(); 80: packages.getSession().save(); 81: } 82: CQPackageManager pckgManager = sling.getService(CQPackageManager.class); 83: JcrPackage pack = pckgManager.createPackage(sess,pkgGroupName,packageName); 84: pckgManager.ensureVersion(pack); 85: DefaultWorkspaceFilter filters = new DefaultWorkspaceFilter();"  can some one guide me how to fix this. I have copied the code as well. Thanks in advance.

<%@page session="false" import="javax.jcr.*,
        com.day.cq.wcm.api.Page,
        com.day.cq.wcm.api.PageManager,
        org.apache.sling.api.resource.Resource,
        com.day.cq.wcm.commons.WCMUtils,
        com.day.cq.wcm.api.NameConstants,
        com.day.cq.wcm.api.designer.Designer,
        com.day.cq.wcm.api.designer.Design,
        com.day.cq.wcm.api.designer.Style,
        org.apache.sling.api.resource.ValueMap,
        com.day.cq.wcm.api.components.ComponentContext,
        com.day.cq.wcm.api.components.EditContext,
        java.util.Date, java.text.SimpleDateFormat, 
        java.text.FieldPosition, java.text.ParsePosition,
        java.util.Iterator,
        javax.jcr.Property,
        javax.jcr.Node,
        javax.jcr.PropertyType,
        javax.jcr.Session,
        com.day.cq.commons.jcr.JcrUtil,
        javax.jcr.PropertyIterator,
        com.day.cq.replication.ReplicationQueue,
        com.day.cq.replication.ReplicationQueue.Entry,
        java.util.Iterator,
        java.io.ObjectInputStream,
        java.io.ByteArrayInputStream,
        com.day.cq.replication.ReplicationContentFacade,
        org.apache.sling.api.resource.ResourceResolver,
        java.io.PrintWriter,
        javax.servlet.jsp.JspWriter" %><%
%><%
%><%
%><%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%
%><%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %><%
%><%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %><%
%>
<%@include file="/libs/foundation/global.jsp"%>
<sling:defineObjects />
<%@page import="com.day.cq.packaging.CQPackageManager"%>
<%@page import="com.day.jcr.vault.packaging.PackageManager"%>
<%@page import="com.day.cq.wcm.siteimporter.ImporterContext"%>
<%@page import="com.day.jcr.vault.packaging.JcrPackageManager"%>
<%@page import="com.day.jcr.vault.packaging.PackagingService"%>
<%@page import="com.day.jcr.vault.fs.config.DefaultWorkspaceFilter"%>
<%@page import="com.day.jcr.vault.packaging.JcrPackage"%>
<%@page import="com.day.jcr.vault.fs.api.PathFilterSet"%>
<%@page import="com.day.jcr.vault.util.HtmlProgressListener"%>
<%@page import="org.osgi.framework.BundleContext"%>

<%@page import="org.apache.jackrabbit.util.Text"%>
<%@page import="com.day.cq.rewriter.linkchecker.LinkCheckerSettings"%>
<%@page import="java.util.HashSet"%>
<%@page import="java.util.Set"%>
<html>
<head>
<title>package creation</title>
</head>
    <body>

<%
Session sess = resourceResolver.adaptTo(Session.class);
BundleContext bundleContext = sling.getService(BundleContext.class);
//ImporterContext ctx = ImporterContext.createContext(slingRequest,slingResponse,bundleContext);
//Session sess = sling.getResolver().adaptTo(Session.class);
HttpSession session = request.getSession();
Set<String> allmodifiedPath = new HashSet<String>();
if(null!=session.getAttribute("allModifiedPath")){
    allmodifiedPath = (HashSet<String>)session.getAttribute("allModifiedPath");
}
String pkgGroupName = "CQSupportTool";
String packageName = request.getParameter("pkgName")!=null && !"".equals(request.getParameter("pkgName"))?request.getParameter("pkgName"):"ModifiedPagePackage";

JcrPackageManager packMgr = PackagingService.getPackageManager(sess);

// check if package already exists
String packPath = pkgGroupName + "/" + packageName + ".zip";
Node packages = packMgr.getPackageRoot();
if (packages.hasNode(packPath)) {
packages.getNode(packPath).remove();
packages.getSession().save();
}
CQPackageManager pckgManager = sling.getService(CQPackageManager.class);
JcrPackage pack = pckgManager.createPackage(sess,pkgGroupName,packageName);
pckgManager.ensureVersion(pack);
DefaultWorkspaceFilter filters = new DefaultWorkspaceFilter();
out.println("<br> Adding following filter path <br> ");
for(String path:allmodifiedPath){
    out.println(path);
     filters.add(new PathFilterSet(path));
}

pack.getDefinition().setFilter(filters, true);
packMgr.assemble(pack, null);
String serverName = (request.getProtocol().split("/")[0]).toLowerCase()+"://"+request.getServerName();
if(!"".equals(request.getServerPort())){
    serverName+=":"+request.getServerPort();
}

String docroot = serverName +"/crx/packmgr/service.jsp";
out.println("<br><br><strong>Package Creation Done with name "+ packageName +"</strong>");
%>
<form method="get" action="<%=docroot %>">
<input type="hidden" name="cmd" id="cmd" value="get"></input>
<input type="hidden" name="name" id="name" value="<%=Text.escape(packageName) %>"></input>
<input type="hidden" name="group" id="group" value="<%=Text.escape(pkgGroupName) %>"></input>
<input type="submit" value="Download Package"></input>
</form>
</body>
</html>

1 Accepted Solution

Avatar

Correct answer by
Level 6

Hi ,

I can be able to use the content packager to pull the delta content from production. Thanks for the help. 

 

Thanks

View solution in original post

4 Replies

Avatar

Level 10

I would avoid JSP and look at using Java and the Package Manager API and build as an OSGi bundle. See this article for details on using Package Manager API: 

https://helpx.adobe.com/experience-manager/using/dynamic_aem_packages.html

THis article is based on this GITHUB code: 

https://github.com/Adobe-Consulting-Services/acs-aem-commons/tree/feature/6.2-compatibility

Avatar

Correct answer by
Level 6

Hi ,

I can be able to use the content packager to pull the delta content from production. Thanks for the help. 

 

Thanks

Avatar

Employee Advisor

Hi dragon2A,

Sorry - can you let us know how you resolved the issue?

Did you change the import ? I am struck at the same problem. Please help.

Thanks

Avatar

Level 6

Hi ,

I have used the acs-commons content-packagers to get it done my work. 

My use case needs to copy the delta content from AEM5.6 to AEM6.2 after the initial migration. 

I didn't concentrate on that problem.

Thanks