Folowing is the code snippet in saveConfig.jag which I've used to access
the OSGI service,
try {
context.startTenantFlow();
context.getThreadLocalCarbonContext().setTenantId(tenantId);
log.info('setting tennant id successful');
context.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true);
log.info('setting tennant domain successful');
log.info('server ' + server);
var service =
server.osgiService('org.wso2.carbon.appfactory.issuetracking.service.IssueTrackerService');
log.info('service is called successfully');
service.createProject("applicationName", issueTrackerConfig);
} catch (e) {
log.error(e);
} finally {
context.endTenantFlow();
}
In above code if I replace
org.wso2.carbon.appfactory.issuetracking.service.IssueTrackerService
with
*org.wso2.carbon.appfactory.application.mgt.service.ApplicationManagementService,*
I get no errors and it works fine.
*M.N.F. Dilhasha*
Software Engineering Intern | *WSO2 Lanka*
email :
*[email protected] <[email protected]>*mobile : +94 77 8449321
On Fri, Mar 20, 2015 at 9:53 AM, Anuruddha Premalal <[email protected]>
wrote:
> Hi Fathima,
>
> Could you provide the code snippets, which you used to access the OSGI
> service?.
> You could also refer to modules/manager/manager.jag to verify your method.
>
> Can you also check the service.xml file of the issuetracking service to
> see whether the methods are exposed with correct privileges. You could use
> application management service.xml as a reference.
>
> Regards,
>
> On Fri, Mar 20, 2015 at 9:40 AM, Fathima Dilhasha <[email protected]>
> wrote:
>
>> Hi,
>>
>> Sorry about the previous email. After some time,
>> *org.wso2.carbon.appfactory.issuetracking* component is in ''satisfied'
>> state as follows.
>>
>> *osgi> comp 27 *
>> * Component[*
>> * name = org.wso2.carbon.issutracker*
>> * factory = null*
>> * autoenable = true*
>> * immediate = true*
>> * implementation =
>> org.wso2.carbon.appfactory.issuetracking.internal.IssueTrackerServiceComponent*
>> * state = Unsatisfied*
>> * properties = {service.pid=org.wso2.carbon.issutracker}*
>> * serviceFactory = false*
>> * serviceInterface = null*
>> * references = {*
>> * Reference[name = appfactory.configuration, interface =
>> org.wso2.carbon.appfactory.common.AppFactoryConfiguration, policy =
>> dynamic, cardinality = 1..1, target = null, bind =
>> setAppFactoryConfiguration, unbind = unsetAppFactoryConfiguration]*
>> * Reference[name = appfactory.application.mgt.service, interface =
>> org.wso2.carbon.appfactory.application.mgt.service.ApplicationManagementService,
>> policy = dynamic, cardinality = 1..1, target = null, bind =
>> setApplicationManagementService, unbind =
>> unsetApplicationManagementService]*
>> * }*
>> * located in bundle =
>> org.wso2.carbon.appfactory.issuetracking_2.1.0.SNAPSHOT [194]*
>> *]*
>> *Dynamic information :*
>> * The component is satisfied*
>> * All component references are satisfied*
>> * Component configurations :*
>> * Configuration properties:*
>> * service.pid = org.wso2.carbon.issutracker*
>> * component.name <http://component.name> =
>> org.wso2.carbon.issutracker*
>> * component.id <http://component.id> = 26*
>> * Instances:*
>> *
>> org.eclipse.equinox.internal.ds.impl.ComponentInstanceImpl@31be9a70*
>> * Bound References:*
>> *
>> String[org.wso2.carbon.appfactory.common.AppFactoryConfiguration]*
>> * ->
>> org.wso2.carbon.appfactory.common.AppFactoryConfiguration@588d4893*
>> *
>> String[org.wso2.carbon.appfactory.application.mgt.service.ApplicationManagementService]*
>> * ->
>> org.wso2.carbon.appfactory.application.mgt.service.ApplicationManagementService@2397d850*
>>
>>
>> Now, what could be the reason for the above null pointer exception?
>>
>> Thanks.
>>
>> Regards,
>> Dilhasha
>>
>> *M.N.F. Dilhasha*
>> Software Engineering Intern | *WSO2 Lanka*
>>
>> email :
>> *[email protected] <[email protected]>*mobile : +94 77 8449321
>>
>> On Fri, Mar 20, 2015 at 9:32 AM, Fathima Dilhasha <[email protected]>
>> wrote:
>>
>>> Hi,
>>> I tried listing the osgi services and I found issue tracker service in
>>> 'UNSATISFIED' state.
>>>
>>> These are the details for *org.wso2.carbon.appfactory.issuetracking*
>>> component.
>>>
>>> *osgi> comp 27*
>>> * Component[*
>>> * name = org.wso2.carbon.issutracker*
>>> * factory = null*
>>> * autoenable = true*
>>> * immediate = true*
>>> * implementation =
>>> org.wso2.carbon.appfactory.issuetracking.internal.IssueTrackerServiceComponent*
>>> * state = Unsatisfied*
>>> * properties = {service.pid=org.wso2.carbon.issutracker}*
>>> * serviceFactory = false*
>>> * serviceInterface = null*
>>> * references = {*
>>> * Reference[name = appfactory.configuration, interface =
>>> org.wso2.carbon.appfactory.common.AppFactoryConfiguration, policy =
>>> dynamic, cardinality = 1..1, target = null, bind =
>>> setAppFactoryConfiguration, unbind = unsetAppFactoryConfiguration]*
>>> * Reference[name = appfactory.application.mgt.service, interface =
>>> org.wso2.carbon.appfactory.application.mgt.service.ApplicationManagementService,
>>> policy = dynamic, cardinality = 1..1, target = null, bind =
>>> setApplicationManagementService, unbind =
>>> unsetApplicationManagementService]*
>>> * }*
>>> * located in bundle =
>>> org.wso2.carbon.appfactory.issuetracking_2.1.0.SNAPSHOT [194]*
>>> *]*
>>> *Dynamic information :*
>>> * *The component is NOT satisfied*
>>> * The following references are not satisfied:*
>>> * Reference[name = appfactory.application.mgt.service, interface =
>>> org.wso2.carbon.appfactory.application.mgt.service.ApplicationManagementService,
>>> policy = dynamic, cardinality = 1..1, target = null, bind =
>>> setApplicationManagementService, unbind =
>>> unsetApplicationManagementService]*
>>> * Component configurations :*
>>> * Configuration properties:*
>>> * service.pid = org.wso2.carbon.issutracker*
>>> * component.name <http://component.name> =
>>> org.wso2.carbon.issutracker*
>>> * component.id <http://component.id> = 26*
>>> * Instances:*
>>>
>>>
>>>
>>> *M.N.F. Dilhasha*
>>> Software Engineering Intern | *WSO2 Lanka*
>>>
>>> email :
>>> *[email protected] <[email protected]>*mobile : +94 77 8449321
>>>
>>> On Fri, Mar 20, 2015 at 8:43 AM, Fathima Dilhasha <[email protected]>
>>> wrote:
>>>
>>>> Thank you.
>>>>
>>>> That's correct, I used list admin services to see the services. I'll
>>>> debug more and see.
>>>>
>>>> Thanks.
>>>>
>>>> Regards,
>>>> Dilhasha
>>>>
>>>> *M.N.F. Dilhasha*
>>>> Software Engineering Intern | *WSO2 Lanka*
>>>>
>>>> email :
>>>> *[email protected] <[email protected]>*mobile : +94 77 8449321
>>>>
>>>> On Fri, Mar 20, 2015 at 7:46 AM, Danushka Fernando <[email protected]>
>>>> wrote:
>>>>
>>>>> It needs to be an osgi service to do that. Probably you have used list
>>>>> admin services command to check in osgi console. That will list web
>>>>> services not osgi services. Same as wsdl.
>>>>>
>>>>> Thanks & Regards
>>>>> Danushka Fernando
>>>>> Software Engineer
>>>>> WSO2 inc. http://wso2.com/
>>>>> Mobile : +94716332729
>>>>>
>>>>>
>>>>> On Mar 20, 2015 7:33 AM, "Fathima Dilhasha" <[email protected]> wrote:
>>>>>
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I am trying to access the IssueTrackerService from a module in
>>>>>> appmgt. This gives a null pointer exception as follows.
>>>>>>
>>>>>> *TID: [0] [AF] [2015-03-20 01:27:36,329] ERROR
>>>>>> {module/issuetracker/saveConfig.jag} -
>>>>>> org.mozilla.javascript.WrappedException: Wrapped
>>>>>> java.lang.NullPointerException (osgi#8)*
>>>>>> * at
>>>>>> org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1754)*
>>>>>> * at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:148)*
>>>>>> * at
>>>>>> org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:225)*
>>>>>> * at
>>>>>> org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)*
>>>>>> * at org.mozilla.javascript.gen.osgi_11._c_anonymous_2(osgi:8)*
>>>>>> * at org.mozilla.javascript.gen.osgi_11.call(osgi)*
>>>>>> * at
>>>>>> org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)*
>>>>>> * at
>>>>>> org.jaggeryjs.rhino.appmgt.modules.issuetracker.get.c1._c_anonymous_1(/appmgt/modules/issuetracker/get/saveConfig.jag:56)*
>>>>>> * at
>>>>>> org.jaggeryjs.rhino.appmgt.modules.issuetracker.get.c1.call(/appmgt/modules/issuetracker/get/saveConfig.jag)*
>>>>>> * at
>>>>>> org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2430)*
>>>>>> * at
>>>>>> org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:269)*
>>>>>> * at
>>>>>> org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:97)*
>>>>>> * at
>>>>>> org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:42)*
>>>>>> * at
>>>>>> org.jaggeryjs.rhino.appmgt.modules.issuetracker.c0._c_anonymous_4(/appmgt/modules/issuetracker/module.jag:32)*
>>>>>> * at
>>>>>> org.jaggeryjs.rhino.appmgt.modules.issuetracker.c0.call(/appmgt/modules/issuetracker/module.jag)*
>>>>>> * at
>>>>>> org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:85)*
>>>>>> * at
>>>>>> org.jaggeryjs.rhino.appmgt.site.blocks.issuetracker.list.ajax.c1._c_anonymous_1(/appmgt/site/blocks/issuetracker/list/ajax/save.jag:10)*
>>>>>> * at
>>>>>> org.jaggeryjs.rhino.appmgt.site.blocks.issuetracker.list.ajax.c1.call(/appmgt/site/blocks/issuetracker/list/ajax/save.jag)*
>>>>>> * at
>>>>>> org.mozilla.javascript.optimizer.OptRuntime.call0(OptRuntime.java:23)*
>>>>>> * at
>>>>>> org.jaggeryjs.rhino.appmgt.site.blocks.issuetracker.list.ajax.c1._c_script_0(/appmgt/site/blocks/issuetracker/list/ajax/save.jag:6)*
>>>>>> * at
>>>>>> org.jaggeryjs.rhino.appmgt.site.blocks.issuetracker.list.ajax.c1.call(/appmgt/site/blocks/issuetracker/list/ajax/save.jag)*
>>>>>> * at
>>>>>> org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)*
>>>>>> * at
>>>>>> org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)*
>>>>>> * at
>>>>>> org.jaggeryjs.rhino.appmgt.site.blocks.issuetracker.list.ajax.c1.call(/appmgt/site/blocks/issuetracker/list/ajax/save.jag)*
>>>>>> * at
>>>>>> org.jaggeryjs.rhino.appmgt.site.blocks.issuetracker.list.ajax.c1.exec(/appmgt/site/blocks/issuetracker/list/ajax/save.jag)*
>>>>>> * at
>>>>>> org.jaggeryjs.scriptengine.engine.RhinoEngine.execScript(RhinoEngine.java:567)*
>>>>>> * at
>>>>>> org.jaggeryjs.scriptengine.engine.RhinoEngine.exec(RhinoEngine.java:273)*
>>>>>> * at
>>>>>> org.jaggeryjs.jaggery.core.manager.WebAppManager.execute(WebAppManager.java:541)*
>>>>>> * at
>>>>>> org.jaggeryjs.jaggery.core.JaggeryServlet.doGet(JaggeryServlet.java:24)*
>>>>>> * at javax.servlet.http.HttpServlet.service(HttpServlet.java:735)*
>>>>>> * at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)*
>>>>>> * at
>>>>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)*
>>>>>> * at
>>>>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)*
>>>>>> * at
>>>>>> org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)*
>>>>>> * at
>>>>>> org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)*
>>>>>> * at
>>>>>> org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)*
>>>>>> * at
>>>>>> org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)*
>>>>>> * at
>>>>>> org.jaggeryjs.jaggery.core.JaggeryFilter.doFilter(JaggeryFilter.java:21)*
>>>>>> * at
>>>>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)*
>>>>>> * at
>>>>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)*
>>>>>> * at
>>>>>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)*
>>>>>> * at
>>>>>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)*
>>>>>> * at
>>>>>> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)*
>>>>>> * at
>>>>>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)*
>>>>>> * at
>>>>>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)*
>>>>>> * at
>>>>>> org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:178)*
>>>>>> * at
>>>>>> org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve$1.invoke(CarbonTomcatValve.java:47)*
>>>>>> * at
>>>>>> org.wso2.carbon.webapp.mgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:56)*
>>>>>> * at
>>>>>> org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:47)*
>>>>>> * at
>>>>>> org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:141)*
>>>>>> * at
>>>>>> org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:156)*
>>>>>> * at
>>>>>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)*
>>>>>> * at
>>>>>> org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:52)*
>>>>>> * at
>>>>>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)*
>>>>>> * at
>>>>>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)*
>>>>>> * at
>>>>>> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)*
>>>>>> * at
>>>>>> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)*
>>>>>> * at
>>>>>> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1653)*
>>>>>> * at
>>>>>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)*
>>>>>> * at
>>>>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)*
>>>>>> * at java.lang.Thread.run(Thread.java:744)*
>>>>>> *Caused by: java.lang.NullPointerException*
>>>>>> * at
>>>>>> org.wso2.carbon.context.PrivilegedCarbonContext.getOSGiService(PrivilegedCarbonContext.java:448)*
>>>>>> * at sun.reflect.GeneratedMethodAccessor70.invoke(Unknown Source)*
>>>>>> * at
>>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)*
>>>>>> * at java.lang.reflect.Method.invoke(Method.java:606)*
>>>>>> * at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)*
>>>>>> * ... 59 more*
>>>>>> * {module/issuetracker/saveConfig.jag}*
>>>>>>
>>>>>>
>>>>>> But when I try to access another service (e.g.
>>>>>> ApplicationManagementService) , no exception occurs and code works fine.
>>>>>>
>>>>>> Regarding IssueTrackerService,
>>>>>>
>>>>>>
>>>>>> - It is listed in the osgi console.
>>>>>> - I can access the wsdl for the service at specified url
>>>>>> - I don't see any usage of the IssueTrackerService
>>>>>>
>>>>>>
>>>>>> What can be the issue with this service?
>>>>>> Any help is appreciated.
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> Regards,
>>>>>> Dilhasha
>>>>>>
>>>>>>
>>>>>> *M.N.F. Dilhasha*
>>>>>> Software Engineering Intern | *WSO2 Lanka*
>>>>>>
>>>>>> email :
>>>>>> *[email protected] <[email protected]>*mobile : +94 77 8449321
>>>>>>
>>>>>
>>>>
>>>
>>
>
>
> --
> *Anuruddha Premalal*
> Software Eng. | WSO2 Inc.
> Mobile : +94710461070
> Web site : www.regilandvalley.com
>
>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev