コミュニティアチーブメントバーを展開する。

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

この会話は、活動がないためロックされています。新しい投稿を作成してください。

解決済み

Not able to call sling service from component jsp

Avatar

Level 9

Hi All,

I have created a component jsp ,from which i need to call a sling service,this component page simply calls the methods of service.When i am trying to see the rendered page i am getting null pointer exception.

Can someone tell me what could be the reason,why could not instantiate the service.

Attaching jsp and service class.

 

<%@include file="/libs/foundation/global.jsp"%>
<%@taglib prefix="cq" uri="http://www.day.com/taglibs/cq/1.0" %>
<%@page import="com.sample.initiatewf.InvokeAEMWorkflow"%>
<h1>TemplatePDF Page</h1>
<%
//create a InvokeAEMWorkflow instance
com.sample.initiatewf.InvokeAEMWorkflow wfService = sling.getService(com.sample.initiatewf.InvokeAEMWorkflow.class);
%>
<h2>About to invoke an AEM workflow using the AEM workflow APIs</h2>
<h3><%=wfService.getStringMsg()%></h3>

 

Thanks,

Kishore

1 受け入れられたソリューション

Avatar

正解者
Level 7

[img]service.png[/img]Kishore,

Your code required below change in jsp file
com.sample.initiatewf.InvokeAEMWorkflow  wfService = sling.getService(com.sample.initiatewf.INvokeAEMWorkflowImp.class);

You were accessing your service with name "com.sample.initiatewf.INvokeAEMWorkflow.class" instead of "com.sample.initiatewf.INvokeAEMWorkflowImp.class"    

Because you registered your service in INvokeAEMWorkflowImp class as below 
@Service(value = {INvokeAEMWorkflowImp.class})
So it has to be accessed with INvokeAEMWorkflowImp.

Please see attached image for more clarification.

Regards
Brijesh

元の投稿で解決策を見る

3 返信

Avatar

正解者
Level 7

[img]service.png[/img]Kishore,

Your code required below change in jsp file
com.sample.initiatewf.InvokeAEMWorkflow  wfService = sling.getService(com.sample.initiatewf.INvokeAEMWorkflowImp.class);

You were accessing your service with name "com.sample.initiatewf.INvokeAEMWorkflow.class" instead of "com.sample.initiatewf.INvokeAEMWorkflowImp.class"    

Because you registered your service in INvokeAEMWorkflowImp class as below 
@Service(value = {INvokeAEMWorkflowImp.class})
So it has to be accessed with INvokeAEMWorkflowImp.

Please see attached image for more clarification.

Regards
Brijesh

Avatar

Level 10

This is based on a community article. It looks like the OSGi bundle that contains the com.sample.initiatewf.InvokeAEMWorkflow service is not deployed and in an active state. 

Make sure to deploy the OSGI bundle and place the bundle into an Active state as discussed here:

http://scottsdigitalcommunity.blogspot.ca/2013/09/creating-workflows-for-adobe-experience.html

Avatar

Level 9

smacdonald2008 wrote...

This is based on a community article. It looks like the OSGi bundle that contains the com.sample.initiatewf.InvokeAEMWorkflow service is not deployed and in an active state. 

Make sure to deploy the OSGI bundle and place the bundle into an Active state as discussed here:

http://scottsdigitalcommunity.blogspot.ca/2013/09/creating-workflows-for-adobe-experience.html

 

 

i am able to deploy bundle and it is also in active state but i am not able to refer the bundle from my component page.