Hi,

I tried logging in between the steps.

* tenantId and tenantDomain are not null
* The null pointer exception takes place in the following line.

server.osgiService('org.wso2.carbon.appfactory.issuetracking.service.IssueTrackerService').createProject(applicationName",
issueTrackerConfig);

Is it because the server cannot track the OSGI service I'm referring to?
 (The service is listed in the OSGI cosole)

How can I figure it out?

Thanks.
Regards,
Dilhasha

*M.N.F. Dilhasha*
Software Engineering Intern | *WSO2 Lanka*

email   :
*dilha...@wso2.com <dilha...@wso2.com>*mobile : +94 77 8449321

On Wed, Mar 18, 2015 at 11:14 AM, Fathima Dilhasha <dilha...@wso2.com>
wrote:

> Hi Mahesh,
>
> Thanks for the points. I'll work on those and see.
>
> Regards,
> Dilhasha
>
> *M.N.F. Dilhasha*
> Software Engineering Intern | *WSO2 Lanka*
>
> email   :
> *dilha...@wso2.com <dilha...@wso2.com>*mobile : +94 77 8449321
>
> On Wed, Mar 18, 2015 at 11:13 AM, Mahesh Chinthaka <mahe...@wso2.com>
> wrote:
>
>> Sorry I missed this,
>> getting modManager varialbe , put this befor getting the tenant domain.
>> var modManager = jagg.module("manager");
>>
>> On Wed, Mar 18, 2015 at 11:11 AM, Mahesh Chinthaka <mahe...@wso2.com>
>> wrote:
>>
>>> Hi Dilhasha,
>>> I think you havent got the tenant domain properly.
>>>
>>> you may use following to get tenant domain.
>>> var tenantDomain = modManager.getTenantDomain();
>>>
>>> you may use following to set tenant domain n id
>>> context.getThreadLocalCarbonContext().setTenantDomain(tenantDomain,true);
>>>
>>>
>>>  in between the steps you can put  info logs to see values, in that way
>>> you may be able to see whats null here.
>>>
>>> On Wed, Mar 18, 2015 at 10:59 AM, Danushka Fernando <danush...@wso2.com>
>>> wrote:
>>>
>>>> Few points
>>>>
>>>>    1. Did you check whether your osgi bundle is activated or not? May
>>>>    be that's the issue. Seems it cannot find the osgi service.
>>>>    2. When start tenant flow in setTenantDomain method there is a
>>>>    another signature which will take in tenantDomain (String) and
>>>>    resolveTenantID (boolean) parameters. You can use that instead of 
>>>> setting
>>>>    tenantID manually.
>>>>    3. The way you have included the module, AFAIR that's not the way
>>>>    to refer to a module. Refer to other places that we have done such a 
>>>> thing.
>>>>
>>>>
>>>> Thanks & Regards
>>>> Danushka Fernando
>>>> Software Engineer
>>>> WSO2 inc. http://wso2.com/
>>>> Mobile : +94716332729
>>>>
>>>> On Wed, Mar 18, 2015 at 10:45 AM, Fathima Dilhasha <dilha...@wso2.com>
>>>> wrote:
>>>>
>>>>> Hi Mahesh,
>>>>>
>>>>> Thanks for the response.
>>>>>
>>>>> Following is the code in saveConfig.jag
>>>>>
>>>>> include("/jagg/jagg.jag");
>>>>> include("/jagg/constants.jag");
>>>>> include("/jagg/config_reader.jag");
>>>>> include("/modules/manager/manager.jag");
>>>>>
>>>>> (function () {
>>>>>
>>>>>     var carbon = require('carbon');
>>>>>     var log = new Log("module/issuetracker/saveConfig.jag");
>>>>>     var multitenancy = carbon.multitenancy;
>>>>>     var server = carbon.server;
>>>>>
>>>>>
>>>>>
>>>>>     var context=multitenancy.getPrivilegedCarbonContext();
>>>>>     var tenantDomain = getTenantDomain();
>>>>>     var tenantId=getTenantId();
>>>>>
>>>>>     var issueTrackerConfig = 
>>>>> Packages.org.wso2.carbon.appfactory.issuetracking.beans.IssueTrackerConfigurations;
>>>>>     var issueConfig=new issueTrackerConfig();
>>>>>     issueConfig.setIssueTrackerinstanceUrl("some url");
>>>>>
>>>>>     try{
>>>>>
>>>>>         context.startTenantFlow();
>>>>>         context.getThreadLocalCarbonContext().setTenantId(tenantId);
>>>>>         
>>>>> context.getThreadLocalCarbonContext().setTenantDomain(tenantDomain);
>>>>>         
>>>>> server.osgiService('org.wso2.carbon.appfactory.issuetracking.service.IssueTrackerService').createProject("applicationName",
>>>>>  issueTrackerConfig);
>>>>>     }catch(e){
>>>>>         log.error(e);
>>>>>     }finally{
>>>>>         context.endTenantFlow();
>>>>>     }
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> }());
>>>>>
>>>>>
>>>>>
>>>>> The getTenantDomain,getTenantId functions are in a different jag file,
>>>>> which I have included (manager.jag).
>>>>>
>>>>>
>>>>>
>>>>> *M.N.F. Dilhasha*
>>>>> Software Engineering Intern | *WSO2 Lanka*
>>>>>
>>>>> email   :
>>>>> *dilha...@wso2.com <dilha...@wso2.com>*mobile : +94 77 8449321
>>>>>
>>>>> On Wed, Mar 18, 2015 at 10:35 AM, Mahesh Chinthaka <mahe...@wso2.com>
>>>>> wrote:
>>>>>
>>>>>> Hi Dilhasha,
>>>>>>
>>>>>> This could be either not setting tenant domain/ id properly or,
>>>>>> issueTrackerConfig parameter might be null at that moment. can you share
>>>>>> the code segment of whole function please. So we can see the reason for 
>>>>>> NPE.
>>>>>>
>>>>>> On Wed, Mar 18, 2015 at 10:27 AM, Fathima Dilhasha <dilha...@wso2.com
>>>>>> > wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I'm trying to access an osgi service available in WSO2 Appfactory,
>>>>>>> from the 'appmgt' jaggery app. In this process I get the following
>>>>>>> exception in the server.
>>>>>>>
>>>>>>> *TID: [0] [AF] [2015-03-18 04:44:00,643] 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.c0._c_anonymous_1(/appmgt/modules/issuetracker/get/saveConfig.jag:49)*
>>>>>>> * at
>>>>>>> org.jaggeryjs.rhino.appmgt.modules.issuetracker.get.c0.call(/appmgt/modules/issuetracker/get/saveConfig.jag)*
>>>>>>> * at
>>>>>>> org.mozilla.javascript.optimizer.OptRuntime.call0(OptRuntime.java:23)*
>>>>>>> * at
>>>>>>> org.jaggeryjs.rhino.appmgt.modules.issuetracker.get.c0._c_script_0(/appmgt/modules/issuetracker/get/saveConfig.jag:26)*
>>>>>>> * at
>>>>>>> org.jaggeryjs.rhino.appmgt.modules.issuetracker.get.c0.call(/appmgt/modules/issuetracker/get/saveConfig.jag)*
>>>>>>> * at
>>>>>>> org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)*
>>>>>>> * at
>>>>>>> org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)*
>>>>>>> * at
>>>>>>> org.jaggeryjs.rhino.appmgt.modules.issuetracker.get.c0.call(/appmgt/modules/issuetracker/get/saveConfig.jag)*
>>>>>>> * at
>>>>>>> org.jaggeryjs.rhino.appmgt.modules.issuetracker.get.c0.exec(/appmgt/modules/issuetracker/get/saveConfig.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)*
>>>>>>> * ... 50 more*
>>>>>>> * {module/issuetracker/saveConfig.jag}*
>>>>>>>
>>>>>>>
>>>>>>> Following is the code segment in saveConfig.jag, which is
>>>>>>> responsible for calling the osgi service.
>>>>>>>
>>>>>>> try{
>>>>>>>
>>>>>>>     context.startTenantFlow();
>>>>>>>     context.getThreadLocalCarbonContext().setTenantId(tenantId);
>>>>>>>     context.getThreadLocalCarbonContext().setTenantDomain(tenantDomain);
>>>>>>>     
>>>>>>> server.osgiService('org.wso2.carbon.appfactory.issuetracking.service.IssueTrackerService').createProject("applicationName",
>>>>>>>  issueTrackerConfig);
>>>>>>> }catch(e){
>>>>>>>     log.error(e);
>>>>>>> }finally{
>>>>>>>     context.endTenantFlow();
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>> It would be really helpful, if someone can help me to overcome this
>>>>>>> problem.
>>>>>>>
>>>>>>> Thanks.
>>>>>>> Regards,
>>>>>>> Dilhasha
>>>>>>>
>>>>>>>
>>>>>>> *M.N.F. Dilhasha*
>>>>>>> Software Engineering Intern | *WSO2 Lanka*
>>>>>>>
>>>>>>> email   :
>>>>>>> *dilha...@wso2.com <dilha...@wso2.com>*mobile : +94 77 8449321
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Dev mailing list
>>>>>>> Dev@wso2.org
>>>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> *Mahesh Chinthaka Vidanagama* | Software Engineer
>>>>>> WSO2, Inc | lean. enterprise. middleware.
>>>>>> #20, Palm Grove, Colombo 03, Sri Lanka
>>>>>> Mobile: +94 71 63 63 083 | Work: +94 112 145 345
>>>>>> Email: mahe...@wso2.com | Web: www.wso2.com
>>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Dev mailing list
>>>>> Dev@wso2.org
>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>>
>>>>>
>>>>
>>>
>>>
>>> --
>>> *Mahesh Chinthaka Vidanagama* | Software Engineer
>>> WSO2, Inc | lean. enterprise. middleware.
>>> #20, Palm Grove, Colombo 03, Sri Lanka
>>> Mobile: +94 71 63 63 083 | Work: +94 112 145 345
>>> Email: mahe...@wso2.com | Web: www.wso2.com
>>>
>>
>>
>>
>> --
>> *Mahesh Chinthaka Vidanagama* | Software Engineer
>> WSO2, Inc | lean. enterprise. middleware.
>> #20, Palm Grove, Colombo 03, Sri Lanka
>> Mobile: +94 71 63 63 083 | Work: +94 112 145 345
>> Email: mahe...@wso2.com | Web: www.wso2.com
>>
>
>
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to