Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

maven compile error

Avatar

Level 6

Dear all, Thank you for your time to look into my issue

I've written a small login servlet and trying to build. I've added dependencies but could not able to compile successfully.   Attached is the pom.xml

Error :-

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project userlogin-bundle: Compilation failur
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[6,16] package javax.jcr does not exist
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[7,16] package javax.jcr does not exist
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[8,16] package javax.jcr does not exist
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[10,20] package javax.servlet does not exist
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[11,25] package javax.servlet.http does not exist
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[15,32] package org.apache.jackrabbit.api does not exist
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[16,46] package org.apache.jackrabbit.api.security.user does not exist
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[17,46] package org.apache.jackrabbit.api.security.user does not exist
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[19,27] package org.apache.sling.api does not exist
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[20,27] package org.apache.sling.api does not exist
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[21,36] package org.apache.sling.api.servlets does not exist
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[22,31] package org.apache.sling.jcr.api does not exist
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[30,34] cannot find symbol
[ERROR] symbol: class SlingAllMethodsServlet
[ERROR] public class LoginServlet extends SlingAllMethodsServlet{
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[36,9] cannot find symbol
[ERROR] symbol  : class JackrabbitSession
[ERROR] location: class com.cq.userlogin.LoginServlet
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[41,10] cannot find symbol
[ERROR] symbol  : class SlingRepository
[ERROR] location: class com.cq.userlogin.LoginServlet
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[44,24] cannot find symbol
[ERROR] symbol  : class SlingHttpServletRequest
[ERROR] location: class com.cq.userlogin.LoginServlet
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[45,4] cannot find symbol
[ERROR] symbol  : class SlingHttpServletResponse
[ERROR] location: class com.cq.userlogin.LoginServlet
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[45,46] cannot find symbol
[ERROR] symbol  : class ServletException
[ERROR] location: class com.cq.userlogin.LoginServlet
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[81,23] cannot find symbol
[ERROR] symbol  : class SlingHttpServletRequest
[ERROR] location: class com.cq.userlogin.LoginServlet
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[81,56] cannot find symbol
[ERROR] symbol  : class SlingHttpServletResponse
[ERROR] location: class com.cq.userlogin.LoginServlet
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[91,10] cannot find symbol
[ERROR] symbol  : class Credentials
[ERROR] location: class com.cq.userlogin.LoginServlet
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[35,46] cannot find symbol
[ERROR] symbol  : method getClass()
[ERROR] location: class com.cq.userlogin.LoginServlet
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[48,3] cannot find symbol
[ERROR] symbol  : class HttpSession
[ERROR] location: class com.cq.userlogin.LoginServlet
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[53,20] cannot find symbol
[ERROR] symbol  : class JackrabbitSession
[ERROR] location: class com.cq.userlogin.LoginServlet
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[54,4] cannot find symbol
[ERROR] symbol  : class UserManager
[ERROR] location: class com.cq.userlogin.LoginServlet
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[59,4] cannot find symbol
[ERROR] symbol  : class User
[ERROR] location: class com.cq.userlogin.LoginServlet
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[59,17] cannot find symbol
[ERROR] symbol  : class User
[ERROR] location: class com.cq.userlogin.LoginServlet
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[63,4] cannot find symbol
[ERROR] symbol  : class Credentials
[ERROR] location: class com.cq.userlogin.LoginServlet
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[72,12] cannot find symbol
[ERROR] symbol  : class RepositoryException
[ERROR] location: class com.cq.userlogin.LoginServlet
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[43,2] method does not override or implement a method from a supertype
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[84,12] cannot find symbol
[ERROR] symbol  : class ServletException
[ERROR] location: class com.cq.userlogin.LoginServlet
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[80,2] method does not override or implement a method from a supertype
[ERROR] \AdobeCQ\userlogin\bundle\src\main\java\com\cq\userlogin\LoginServlet.java:[93,14] cannot find symbol
[ERROR] symbol  : class SimpleCredentials
[ERROR] location: class com.cq.userlogin.LoginServlet

 

I appreciate your help

1 Accepted Solution

Avatar

Correct answer by
Level 10

What version of CQ are you using -- this article was tested on 5.5. and 5.6.

What is causing your issue is you are trying to import a version of JackRabbit API that is not included in your CQ version. That is why you have red. 

org.apache.jackrabbit.api,version=[2.3,3) -- Cannot be resolved
org.apache.jackrabbit.api.security.user,version=[2.3,3) -- Cannot be resolved  
 

You can always find out your version of JackRabbit by using the Dependency Finder in the Felix Console. 

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

This will tell you what version your CQ instance uses --  as shown here:

[img]depFinder.png[/img]

Then modify your POM to include the version that is shown.

Let me know what happens. 

Good luck!  

View solution in original post

7 Replies

Avatar

Level 9

Hi,

Can you check your local maven repository i.e. <User-Directory>/.m2/repository ,where all the dependency jars have been downloaded into it or not?.

Thanks,

Kishore

Avatar

Level 10

If you are trying to build a servlet in CQ -- have you read this community article?

It will guide you on how to build a CQ Sling Servlet (using Maven)  and how to call into it:

http://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html

Avatar

Level 6

Thanks Scott and Kishor!

@Scott,

I followed this article here and it says that I have to add dependency to pom.xml which is under <artifactId>. But the article you have referred here says I need to  add dependency to pom.xml which is under <artifactId>/bundle. When I added dependency to pom.xml which is under <artifactId>/bundle then I was able to create jar file. Could you please let me know what is the difference? 

When I uploaded this jar file in Felix console then I got the error.PFA -

org.apache.jackrabbit.api,version=[2.3,3) -- Cannot be resolved
org.apache.jackrabbit.api.security.user,version=[2.3,3) -- Cannot be resolved 
 

 

I'll attach modified pom.xml

Avatar

Level 6

Here is the attached pom.xml 

Kindly let me know what I'm missing here. Thank you for your help again!

Avatar

Correct answer by
Level 10

What version of CQ are you using -- this article was tested on 5.5. and 5.6.

What is causing your issue is you are trying to import a version of JackRabbit API that is not included in your CQ version. That is why you have red. 

org.apache.jackrabbit.api,version=[2.3,3) -- Cannot be resolved
org.apache.jackrabbit.api.security.user,version=[2.3,3) -- Cannot be resolved  
 

You can always find out your version of JackRabbit by using the Dependency Finder in the Felix Console. 

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

This will tell you what version your CQ instance uses --  as shown here:

[img]depFinder.png[/img]

Then modify your POM to include the version that is shown.

Let me know what happens. 

Good luck!  

Avatar

Level 6

Thanks Scott for your reply! I'm using 5.4

I removed the version version=[2.3,3) from mainfest.mf and uploaded bundle again and after it was fine. 

If you don't mind could you please let me know, what is the difference between adding  dependency to pom.xml which is under <artifactId>/bundle and dependency to pom.xml which is under <artifactId>? In which scenarios I should follow two different approach? 

Avatar

Level 10

I am glad that you got it working. 

I typically put my dependency version here:

<dependency>
    <groupId>org.apache.jackrabbit</groupId>
    <artifactId>jackrabbit-core</artifactId>
    <version>2.4.3</version>
</dependency>

 

But when in doubt about what version that CQ uses -- check with the Dependency Finder. If you place the correct version in artifactId - it will work. If you specify a version that is not included in CQ -- you will get this error:

 

org.apache.jackrabbit.api,version=[2.3,3) -- Cannot be resolved
org.apache.jackrabbit.api.security.user,version=[2.3,3) -- Cannot be resolved