Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Developing JSPS in eclipse cannot resolve some dependencies

clives5916718
Level 2
Level 2

I am trying to move all JSP dev from using CRXDE lite to using Eclipse

I do not seem able to get the following instance variables to be able to point to the correct classes in my maven.

resourceResolver

currentPage e.g.String navstart = currentPage.getPath();

properties e.g. properties.get("pageItems", "1");

resource e.g. resource.getPath()

xssAPI e.g. xssAPI.encodeForHTML(cls)

sling.getService(example.class)

 

I have used the following mavendependencies plugins for my content module in my Maven Project. I am not sure what plugin or dependencies I am missing.

I have been working off of the following dev articles

https://docs.adobe.com/docs/en/cq/5-3/developing/developmenttools/developing_with_eclipse.html

http://docs.adobe.com/docs/en/aem/6-0/develop/dev-tools/ht-projects-maven.html#How-To%20Work%20with%...

 

 

    <!-- ====================================================================== -->
    <!-- D E P E N D E N C I E S -->
    <!-- ====================================================================== -->
    <dependencies>
        <dependency>
            <groupId>za.co.checkers</groupId>
            <artifactId>Checkers.core</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>com.adobe.aem</groupId>
            <artifactId>aem-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.jcr.jcr-wrapper</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.api</artifactId>
        </dependency>

        <dependency>
            <groupId>com.day.cq</groupId>
            <artifactId>cq-commons</artifactId>
            <!-- com.day.cq.commons -->
        </dependency>
        <dependency>
            <groupId>com.day.cq.wcm</groupId>
            <artifactId>cq-wcm-commons</artifactId>
            <!-- com.day.cq.wcm.commons -->
        </dependency>
        <dependency>
            <groupId>com.day.commons</groupId>
            <artifactId>day-commons-jstl</artifactId>
            <!-- javax.servlet.jsp.jstl.core -->
        </dependency>
        <dependency>
            <groupId>com.day.cq.wcm</groupId>
            <artifactId>cq-wcm-taglib</artifactId>
            <!-- com.day.cq.wcm.tags -->
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.scripting.jsp.taglib</artifactId>
            <!-- org.apache.sling.scripting.jsp.taglib -->
        </dependency>
        <dependency>
            <groupId>com.adobe.granite</groupId>
            <artifactId>com.adobe.granite.xssprotection</artifactId>
            <!-- com.adobe.granite.xss -->
        </dependency>
        <dependency>
            <groupId>com.day.cq.wcm</groupId>
            <artifactId>cq-wcm-core</artifactId>
            <!-- com.day.cq.wcm.core.components -->
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <!-- org.apache.commons.lang3 -->
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>

        <dependency>
            <groupId>com.day.cq.wcm</groupId>
            <artifactId>cq-wcm-api</artifactId>
            <!-- com.day.cq.wcm.api -->
        </dependency>
        <dependency>
            <groupId>com.day.cq.wcm</groupId>
            <artifactId>cq-wcm-foundation</artifactId>
        </dependency>
    </dependencies>
</project>

and the following plugins

<plugins>
                        <plugin>
                            <groupId>org.eclipse.m2e</groupId>
                            <artifactId>lifecycle-mapping</artifactId>
                            <version>1.0.0</version>
                            <configuration>
                                <lifecycleMappingMetadata>
                                    <pluginExecutions>
                                        <pluginExecution>
                                            <pluginExecutionFilter>
                                                <groupId>org.apache.sling</groupId>
                                                <artifactId>maven-jspc-plugin</artifactId>
                                                <versionRange>[2.0.6,)</versionRange>
                                                <goals>
                                                    <goal>jspc</goal>
                                                </goals>
                                            </pluginExecutionFilter>
                                            <action>
                                                <ignore />
                                            </action>
                                        </pluginExecution>
                                        <pluginExecution>
                                            <pluginExecutionFilter>
                                                <groupId>org.apache.maven.plugins</groupId>
                                                <artifactId>maven-clean-plugin</artifactId>
                                                <versionRange>[2.4.1,)</versionRange>
                                                <goals>
                                                    <goal>clean</goal>
                                                </goals>
                                            </pluginExecutionFilter>
                                            <action>
                                                <ignore />
                                            </action>
                                        </pluginExecution>
                                    </pluginExecutions>
                                </lifecycleMappingMetadata>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>
                <plugins>
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-resources</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}/jsps-to-compile</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>src/main/content/jcr_root</directory>
                                            <includes>
                                                <include>apps/**</include>
                                                <include>libs/foundation/global.jsp</include>
                                            </includes>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.sling</groupId>
                        <artifactId>maven-jspc-plugin</artifactId>
                        <version>2.0.6</version>
                        <executions>
                            <execution>
                                <id>compile-jsp</id>
                                <goals>
                                    <goal>jspc</goal>
                                </goals>
                                <configuration>
                                    <jasperClassDebugInfo>false</jasperClassDebugInfo>
                                    <sourceDirectory>${project.build.directory}/jsps-to-compile</sourceDirectory>
                                    <outputDirectory>${project.build.directory}/ignoredjspc</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
               
     
                </plugins>

1 Accepted Solution
edubey
Correct answer by
Level 10
Level 10

Hi, 

It is recommended to develop in eclipse with AEM and Sling plugin installed.It will help to resolve all your dependency.

Please follow steps given here : http://adobeaemclub.com/aem-eclipse-plugin-setup-tutorial/

View solution in original post

8 Replies
edubey
Correct answer by
Level 10
Level 10

Hi, 

It is recommended to develop in eclipse with AEM and Sling plugin installed.It will help to resolve all your dependency.

Please follow steps given here : http://adobeaemclub.com/aem-eclipse-plugin-setup-tutorial/

View solution in original post

smacdonald2008
Level 10
Level 10

You can sync JSP (and other nodes/files) from the AEM JCR (CRXDE lite) to Eclipse using vault. See this community article - it shows you how to sync between these tools and setup Eclipse to use these JSPs. (see Prepare for JSP support in Eclipse): 

https://helpx.adobe.com/experience-manager/using/creating-aem-project-using-eclipse.html

clives5916718
Level 2
Level 2

Thank you for the article.

 

I have gone through it steps, it helped a lot.

But I still cannot find some classes. None of the maven dependencies resolve

String selectorPath = currentPage.adaptTo(Resource.class).getResourceMetadata().getResolutionPathInfo();

currentPage throws error class not found, so does Resource, and ResourceReslover.

 

My content project and my AEM are in sync from using the file vault.

 

Another dificulty is that the development article shows to add the following dependencies into the content pom. Bit these have no version numbers or example of Dependencies with version numbers to place dependencies inside the parent pom

 

 

        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.jcr.jcr-wrapper</artifactId>
            <!-- javax.jcr -->
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.api</artifactId>
        </dependency>
        <dependency>
            <groupId>com.day.cq</groupId>
            <artifactId>cq-commons</artifactId>
            <!-- com.day.cq.commons -->
        </dependency>
        <dependency>
            <groupId>com.day.cq.wcm</groupId>
            <artifactId>cq-wcm-commons</artifactId>
            <!-- com.day.cq.wcm.commons -->
        </dependency>
        <dependency>
            <groupId>com.day.cq.wcm</groupId>
            <artifactId>cq-wcm-api</artifactId>
            <!-- com.day.cq.wcm.api -->
        </dependency>
        <dependency>
            <groupId>com.day.commons</groupId>
            <artifactId>day-commons-jstl</artifactId>
            <!-- javax.servlet.jsp.jstl.core -->
        </dependency>
        <dependency>
            <groupId>com.day.cq.wcm</groupId>
            <artifactId>cq-wcm-taglib</artifactId>
            <!-- com.day.cq.wcm.tags -->
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.scripting.jsp.taglib</artifactId>
            <!-- org.apache.sling.scripting.jsp.taglib -->
        </dependency>
        <dependency>
            <groupId>com.adobe.granite</groupId>
            <artifactId>com.adobe.granite.xssprotection</artifactId>
            <!-- com.adobe.granite.xss -->
        </dependency>
        <dependency>
            <groupId>com.day.cq.wcm</groupId>
            <artifactId>cq-wcm-core</artifactId>
            <!-- com.day.cq.wcm.core.components -->
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <!-- org.apache.commons.lang3 -->
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>

clives5916718
Level 2
Level 2

I am using these plugins. The difficulty I have is that I have not been able to find much information on them besides using them to connect to an aem instance for debugging. I would greatly appreciate it if anyone could help me with finding a detailed explanation of the full features of the plugins.

Opkar_Gill
Employee
Employee

Hi Clive,

it seems you are using AEM6, in which case you can use the uber jar rather than the individual dependencies[1]

If you feel you want to use the individual dependencies, then you can use the following URL

http://localhost:4502/system/console/depfinder

In the above page, you can enter the actual class that can't be resolved in Eclipse, and AEM will tell you the internal version of the bundle. You can then set the version in your master pom and mark it as provided.

Regards,

Opkar

[1]http://blogs.adobe.com/experiencedelivers/experience-management/aem6-maven-dependencies-simplicity/

jorgefdez205
Level 3
Level 3

Hi Clive,

I had the same issue and I just included the uber-jar as external jar in my project and all solved ...

I don't know if this is helpful but better late than never..

Thanks

Clive_Stewart
Level 6
Level 6

Thank you Jorge, I will try the uber.jar

 

regards

Clive

Clive_Stewart
Level 6
Level 6

Hi Jorge,

I tried the uber.jar.

My problem is resolved.

Thank you

Clive Stewart