Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.
SOLVED

class not found exception for different framework java classes

Avatar

Level 3

Hi,

I am getting below error when i try to access the custom page created

Caused by: java.lang.ClassNotFoundException: javax.servlet.jsp.PageContext not found by <custom package> [502]
        at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1550)

Same error is repeated for all java classes. I mean i created a component and calling java class from component jsp. I am passing currentNode, pageContext etc... from jsp to java class. There are no issues with compilation. But when i access the page with above component getting no class def found for all classes. 

Caused by: java.lang.ClassNotFoundException: javax.jcr.Node not found by <custom package> [505]
        at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1550)

 

Appreciated for any help

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi,

Where does your Java class live? Inside an OSGI bundle? Or is it just sitting next to the JSP file? In the first case (which I personally recommend) you need to make sure, that the OSGI bundle contains all relevant OSGI imports. Which is done by default correct if you use the maven-bundle plugin (as setup by the various archetypes for AEM/CQ5, which are floating around ...)

kind regards,
Jörg

View solution in original post

5 Replies

Avatar

Level 10

What version of AEM are you using? 

Let me see if i got this straight. You're reading page props using a JSP. ie - 

String pageTitle = currentPage.getTitle();

Then you pass these values to a Java OSGi service and then you try to access the page from Java -- and you get these exceptions? 

Are you using JCR API or using SLing API? What other Java libs are you using? 

Please provide a bit more details - including the CQ version. 

Avatar

Level 3

Hi Scott,

 

I am using AEM 6.0 which is deployed in tomcat server. From component jsp, i am calling a java class method by passing pageContext object. In java class method i am using pageconext object to retrieve request, response, currentNode etc...I am getting above exception whenever pagecontext used to get something

Even when i passed currentNode from jsp to java, even i am getting same error with javax.jcr.node not found

Avatar

Level 10

It's best to pass primitive data types between components and backend Java OSGi Java bundles. A JS object is not a Java object. 

Pass a string value that represents the path and then create the object in Java using the APIs.  

Avatar

Correct answer by
Employee Advisor

Hi,

Where does your Java class live? Inside an OSGI bundle? Or is it just sitting next to the JSP file? In the first case (which I personally recommend) you need to make sure, that the OSGI bundle contains all relevant OSGI imports. Which is done by default correct if you use the maven-bundle plugin (as setup by the various archetypes for AEM/CQ5, which are floating around ...)

kind regards,
Jörg

Avatar

Level 10

See this article that uses Sling API and uses location passed in from front end:

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

The page object is not passed - it's a primitive data type that is passed. Then using the string values - we create the   com.day.cq.wcm.api.Page instance.