I have created interface IContentService and implemented that interface in java class ContentService.java.I need to call the method of java class inside my component.
public interface IContentService {
public JSONObject getContent(String path)
throws ContentServiceExceptions,RepositoryException,IOException,JSONException;
}
The method in my java class returns the value in the form of JSON format.I want that JSON format data to be displayed through my component.I can able to display the JSON response by hitting the service url,"http://localhost:4502/api/contentservice?pagetype=mspot&path=/content/pagename".But I want to display the JSON response by calling the service in my component.I have tried by calling the service by following it is throwing error,
<%
com.aaa.www.core.service.servlets.IContentService contentService = sling.getService(com.aaa.www.core.service.servlets.IContentService.class);
JSONObject ff = contentService.getContent(String path);
%>
<h3>The value of the key is: <%=ff%></h3>
Solved! Go to Solution.
Views
Replies
Total Likes
Assuming com.abc.www.core.service.servlets.IContentService is the interface - not the implementation class - this is proper syntax. Lets open a connect session - there is nothing more we can add this thread - you are doing it right.
The only way I can help you now is for you to send me your package and code. Then lets setup a connect session.
Views
Replies
Total Likes
Please share the error.
Views
Replies
Total Likes
Have attached the error
Views
Replies
Total Likes
Can you attached complete log from error.log
and one more thing as I said previously
"
Why dont you go for servlet approach instead of OSGI service
Same way you can hit your servlet with parameter and get the JSON reponse
we do have alot of articles implemented this approach
Here's one: http://adobeaemclub.com/
Views
Replies
Total Likes
A simple way is to debug it. Check whether Your service is registered in OSGI console or not. Based on an error, it seems, IConentService is not registered.
--
Jitendra
Views
Replies
Total Likes
Make sure your OSGi bundle is in active state and that your service can be seen under the service view. Look at this article:
Creating your first AEM Service using an Adobe Maven Archetype project
Views
Replies
Total Likes
Hi,
1. service is registered in OSGI console
2. bundle is active
3. I am getting error :
An error occurred at line: 11 in the jsp file: /apps/petco/components/content/servicecomp/servicecomp.jsp JSONObject cannot be resolved to a type
my jsp:
<%
String path=request.getParameter("path");
com.abc.www.core.service.servlets.IContentService contentService = sling.getService(com.abc.www.core.service.servlets.IContentService.class);
%>
<%
JSONObject ob=contentService.getContent(path);
%>
- > I have also attached the error page
Views
Replies
Total Likes
Assuming com.abc.www.core.service.servlets.IContentService is the interface - not the implementation class - this is proper syntax. Lets open a connect session - there is nothing more we can add this thread - you are doing it right.
The only way I can help you now is for you to send me your package and code. Then lets setup a connect session.
Views
Replies
Total Likes
It seems ContentService implementation class has a getContent() method without argument and you are calling with the argument. Just check implementation code.
------
Jitendra
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies