Expand my Community achievements bar.

SOLVED

getting "The import com.day.cq.wcm.api cannot be resolved" in eclipse workspace

Avatar

Former Community Member

Hi All,

1) I have set up the eclipse workspace for CQ and just started doing some code. I am using and import on my java file import com.day.cq.wcm.api.Page; on which I am getting an error "The import com.day.cq.wcm.api cannot be resolved". Is there any dependency I will have to define for this in the pom.xml file. I have already defined :

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

but no luck yet.

2) There's another question I have. I have made a simple java file just to check the build process and here's the code :

package com.mercer.taglibs.tags; import java.io.IOException; import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.tagext.SimpleTagSupport; public class HelloWorld extends SimpleTagSupport{ public void doTag() throws JspException, IOException { JspWriter out = getJspContext().getOut(); out.println("Hello Custom Tag with checkin version # 2.1.0!"); } }

The three imports from javax.servlet.jsp are coming from a jar jsp-api-2.1.jar under bundle/lib, I have included that dependency in my pom.xml as

 

 <dependency>
            <groupId>com.mercer</groupId>
            <artifactId>jsp-example</artifactId>
            <version>1.0.0</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/jsp-api-2.1.jar</systemPath>
        </dependency>

It's working fine but I am not sur if this a great way of doing it and I get a warning message when I build my project "'dependencies.dependency.systemPath' for com.mercer:jsp-example:jar should not point at files within the project directory, ${project.basedir}/lib/jsp-api-2.1.jar will be unresolvable by dependent projects @ line 80, column 16". Is there anything I am doing wrong ?

 

Thanks in advance,
Ankit Chandrawat

1 Accepted Solution

Avatar

Correct answer by
Level 9

Hi Ankit,

1. The dependencies configuration looks good. Did you look at Maven Dependencies area under your project to validate these jar are correctly downloaded (locally) and referenced or console log during build process? Else you can also try building the bundle using command prompt where you can see the dependencies (jar download etc...) referenced and resolved correctly.

2. Better to refer servlet jar as dependency in pom.xml because this way you are trying to access asset of a server at run time from outside of application.

 

Thanks,

Pawan

View solution in original post

3 Replies

Avatar

Correct answer by
Level 9

Hi Ankit,

1. The dependencies configuration looks good. Did you look at Maven Dependencies area under your project to validate these jar are correctly downloaded (locally) and referenced or console log during build process? Else you can also try building the bundle using command prompt where you can see the dependencies (jar download etc...) referenced and resolved correctly.

2. Better to refer servlet jar as dependency in pom.xml because this way you are trying to access asset of a server at run time from outside of application.

 

Thanks,

Pawan

Avatar

Former Community Member

Hi Pawan,

Thanks a lot. I have been able to sort that out. BTW, eclipse acted funny. For the [1] I just restarted it and all the errors were gone. 

Regards,

Ankit