class not found exception for different framework java classes | Community
Skip to main content
aem_dev1
New Participant
October 16, 2015
Solved

class not found exception for different framework java classes

  • October 16, 2015
  • 5 replies
  • 3235 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by joerghoh

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

5 replies

smacdonald2008
New Participant
October 16, 2015

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. 

aem_dev1
aem_dev1Author
New Participant
October 16, 2015

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

smacdonald2008
New Participant
October 16, 2015

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.  

joerghoh
joerghohAccepted solution
Employee
October 16, 2015

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

smacdonald2008
New Participant
October 16, 2015

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.