Hi All,
I have setup my CQ workspace in eclipse and using maven to build the project. I am trying to compile a test java file:
package com.mercer.taglibs.tags; import com.day.cq.wcm.api.Page; public class HelloPerson { private Page personPage; public static final String PN_PERSON_NAME = "personName"; public HelloPerson(Page personPage) { this.personPage = personPage; } public String getHelloMessage() { String personName = personPage.getProperties().get(PN_PERSON_NAME).toString(); return personName != null ? personName : "--empty--"; } }
I have provided the dependency in parent
<dependency> <groupId>com.day.cq.wcm</groupId> <artifactId>cq-wcm-core</artifactId> <version>5.6.4</version> <scope>provided</scope> </dependency>
pom.xml like this:
and referencing it in the child pom.xml like this:
<dependency> <groupId>com.day.cq.wcm</groupId> <artifactId>cq-wcm-core</artifactId> </dependency>
the error I am getting is:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project mercer-cq-package-bundle: Compilation failure: Compilation failure:
[ERROR] /C:/Users/ankit-chandrawat/workspace/MMC/mercer/trunk/bundle/src/main/java/com/mercer/taglibs/tags/HelloPerson.java:[3,26] package com.day.cq.wcm.api does not exist
[ERROR] /C:/Users/ankit-chandrawat/workspace/MMC/mercer/trunk/bundle/src/main/java/com/mercer/taglibs/tags/HelloPerson.java:[6,17] cannot find symbol
[ERROR] symbol: class Page
[ERROR] location: class com.mercer.taglibs.tags.HelloPerson
[ERROR] /C:/Users/ankit-chandrawat/workspace/MMC/mercer/trunk/bundle/src/main/java/com/mercer/taglibs/tags/HelloPerson.java:[9,28] cannot find symbol
Solved! Go to Solution.
Views
Replies
Total Likes
I took your POM and failed for me too -- the issue is with your POM file.
I modified your POM and its working now:
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
<version>4.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
<version>1.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>biz.aQute</groupId>
<artifactId>bndlib</artifactId>
<version>1.43.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.10</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.api</artifactId>
<version>2.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.jcr.api</artifactId>
<version>2.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<!-- adding dependencies by AnkitC::Start -->
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.jcr.jcr-wrapper</artifactId>
<version>2.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.day.cq</groupId>
<artifactId>cq-commons</artifactId>
<version>5.6.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-commons</artifactId>
<version>5.6.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-api</artifactId>
<version>5.6.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.day.commons</groupId>
<artifactId>day-commons-jstl</artifactId>
<version>1.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-taglib</artifactId>
<version>5.6.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.scripting.jsp.taglib</artifactId>
<version>2.1.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.adobe.granite</groupId>
<artifactId>com.adobe.granite.xssprotection</artifactId>
<version>5.5.22</version>
<scope>provided</scope>
</dependency>
<!-- dependency provided by AnkitC::Start -->
<dependency>
<groupId>com.adobe.granite</groupId>
<artifactId>com.adobe.granite.ui.commons</artifactId>
<version>5.5.60</version>
<scope>provided</scope>
</dependency>
<!-- dependency provided by AnkitC::Stop -->
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-core</artifactId>
<version>5.6.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-api</artifactId>
<version>5.5.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.day.cq</groupId>
<artifactId>cq-commons</artifactId>
<version>5.5.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-core</artifactId>
<version>2.4.3</version>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr-commons</artifactId>
<version>2.4.3</version>
</dependency>
<!-- adding dependencies by AnkitC::Stop -->
</dependencies>
The bolded ones are the new dependencies that i added. Please try this.
Views
Replies
Total Likes
Follow this community article that walks you through how to use Maven and Eclipse to build an OSGi bundle that you can deploy to Adobe Experience Manager:
http://scottsdigitalcommunity.blogspot.ca/2013/09/using-sling-to-retrieve-content-from.html
HTH
Views
Replies
Total Likes
Hi HTH,
Thank you for your response. I have gone through that already and used the dependency the same way as in the link you sent. I am not able to understand what more dependency I need to use. I used CQ in-built dependency checker to determine the dependency of com.day.cq.wcm.api. Declared it and then trying to compile my code. Do let me know if I need to provide some further information.
Regards,
Ankit
Views
Replies
Total Likes
Did you follow the step by step and create the Maven project?
When you build the OSGi in this article -- you will get this result:
[img]DOS.png[/img]
The POM file that you use is and includes all dependencies is in the article.
Views
Replies
Total Likes
Also - as specified in the POM in the article - you need to include this dependency to use com.day.cq.wcm:
<dependency>
<groupId>com.day.cq</groupId>
<artifactId>cq-commons</artifactId>
<version>5.5.0</version>
<scope>provided</scope>
</dependency>
Hope this helps
Views
Replies
Total Likes
Hi HTH,
I am already using this dependency though with a different version:
<dependency>
<groupId>com.day.cq</groupId>
<artifactId>cq-commons</artifactId>
<version>5.6.2</version>
<scope>provided</scope>
</dependency>
Do you think version make a difference? Also, for your reference I am including the whole set of dependencies I am using:
<dependencies> <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.core</artifactId> <version>4.2.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.compendium</artifactId> <version>4.2.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.scr.annotations</artifactId> <version>1.6.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>biz.aQute</groupId> <artifactId>bndlib</artifactId> <version>1.43.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.5.10</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.jcr</groupId> <artifactId>jcr</artifactId> <version>2.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.api</artifactId> <version>2.2.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.jcr.api</artifactId> <version>2.1.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.1</version> <scope>test</scope> </dependency> <!-- adding dependencies by AnkitC::Start --> <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.jcr.jcr-wrapper</artifactId> <version>2.0.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.day.cq</groupId> <artifactId>cq-commons</artifactId> <version>5.6.2</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.day.cq.wcm</groupId> <artifactId>cq-wcm-commons</artifactId> <version>5.6.2</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.day.cq.wcm</groupId> <artifactId>cq-wcm-api</artifactId> <version>5.6.2</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.day.commons</groupId> <artifactId>day-commons-jstl</artifactId> <version>1.1.4</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.day.cq.wcm</groupId> <artifactId>cq-wcm-taglib</artifactId> <version>5.6.2</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.scripting.jsp.taglib</artifactId> <version>2.1.8</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.adobe.granite</groupId> <artifactId>com.adobe.granite.xssprotection</artifactId> <version>5.5.22</version> <scope>provided</scope> </dependency> <!-- dependency provided by AnkitC::Start --> <dependency> <groupId>com.adobe.granite</groupId> <artifactId>com.adobe.granite.ui.commons</artifactId> <version>5.5.60</version> <scope>provided</scope> </dependency> <!-- dependency provided by AnkitC::Stop --> <dependency> <groupId>com.day.cq.wcm</groupId> <artifactId>cq-wcm-core</artifactId> <version>5.6.4</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.0.1</version> <scope>provided</scope> </dependency> <!-- adding dependencies by AnkitC::Stop --> </dependencies>
Let me know if you think the dependencies doesnt look ok.
Thanks,
Ankit
Views
Replies
Total Likes
Did you add this repository to your POM:
<repositories>
<repository>
<id>adobe</id>
<name>Adobe Public Repository</name>
<url>http://repo.adobe.com/nexus/content/groups/public/</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>adobe</id>
<name>Adobe Public Repository</name>
<url>http://repo.adobe.com/nexus/content/groups/public/</url>
<layout>default</layout>
</pluginRepository>
</pluginRepositories>
Views
Replies
Total Likes
Yes, I have them in my pom.xml like this:
<repository>
<id>adobe</id>
<name>Adobe Public Repository</name>
<url>http://repo.adobe.com/nexus/content/groups/public/</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>adobe</id>
<name>Adobe Public Repository</name>
<url>http://repo.adobe.com/nexus/content/groups/public/</url>
<layout>default</layout>
</pluginRepository>
</pluginRepositories>
Views
Replies
Total Likes
I took your POM and failed for me too -- the issue is with your POM file.
I modified your POM and its working now:
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
<version>4.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
<version>1.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>biz.aQute</groupId>
<artifactId>bndlib</artifactId>
<version>1.43.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.10</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.api</artifactId>
<version>2.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.jcr.api</artifactId>
<version>2.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<!-- adding dependencies by AnkitC::Start -->
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.jcr.jcr-wrapper</artifactId>
<version>2.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.day.cq</groupId>
<artifactId>cq-commons</artifactId>
<version>5.6.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-commons</artifactId>
<version>5.6.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-api</artifactId>
<version>5.6.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.day.commons</groupId>
<artifactId>day-commons-jstl</artifactId>
<version>1.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-taglib</artifactId>
<version>5.6.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.scripting.jsp.taglib</artifactId>
<version>2.1.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.adobe.granite</groupId>
<artifactId>com.adobe.granite.xssprotection</artifactId>
<version>5.5.22</version>
<scope>provided</scope>
</dependency>
<!-- dependency provided by AnkitC::Start -->
<dependency>
<groupId>com.adobe.granite</groupId>
<artifactId>com.adobe.granite.ui.commons</artifactId>
<version>5.5.60</version>
<scope>provided</scope>
</dependency>
<!-- dependency provided by AnkitC::Stop -->
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-core</artifactId>
<version>5.6.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-api</artifactId>
<version>5.5.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.day.cq</groupId>
<artifactId>cq-commons</artifactId>
<version>5.5.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-core</artifactId>
<version>2.4.3</version>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr-commons</artifactId>
<version>2.4.3</version>
</dependency>
<!-- adding dependencies by AnkitC::Stop -->
</dependencies>
The bolded ones are the new dependencies that i added. Please try this.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies