Hi Sameera,

The carbon module I was using was the one found in the jaggery-SNAPSHOT I
downloaded from the jaggeryjs.org site.
I did not check with the updated ones from the WSO2 repo which you had
mentioned above.

This is what I have missed out :D

Thank You Very Much. I can go ahead with this without any need for code
changes.

Regards

-------------------------------------
*Shabir Mohamed*
*Software Engineer*
WSO2 Inc.; http://wso2.com
Email: [email protected] <[email protected]>
Mobile: +94 77 3516019 | +94 71 6583393

On Sun, May 17, 2015 at 2:49 PM, Sameera Medagammaddegedara <
[email protected]> wrote:

> Hi Shabir,
>
> Which version of the carbon module are you using?
>
> The latest version  of the carbon module requires a tenant Id according to
> the following source[1]:
>
> However, I worked around this issue by simple replacing *"tenant" *that
>> is passed in as *domain, *with *"server.superTenant.domain":*
>>
>
> If you construct the UserManager without passing in a tenant domain it
> will automatically pick up the super tenant domain:
>
>
>
> *var userManager = new carbon.user.UserManager(server);*
> Thus you will not be required to edit the carbon module.
>
> *Reference*
> [1]
> https://github.com/wso2/jaggery-extensions/blob/master/carbon/module/scripts/user/user-manager.js#L18
>
> Thank You,
> Sameera
>
> On Sun, May 17, 2015 at 1:27 PM, Shabir Mohamed <[email protected]> wrote:
>
>> Hi Supun,
>>
>> Thanks for that Info. I did not know that there were older and newer
>> versions of this module.
>>
>> Regards
>>
>>
>>
>>
>> -------------------------------------
>> *Shabir Mohamed*
>> *Software Engineer*
>> WSO2 Inc.; http://wso2.com
>> Email: [email protected] <[email protected]>
>> Mobile: +94 77 3516019 | +94 71 6583393
>>
>> On Sat, May 16, 2015 at 5:08 PM, Supun Sethunga <[email protected]> wrote:
>>
>>> Hi Shabir,
>>>
>>> As I can remember this issue occurs due to the difference in the APIs of
>>> the newer and the older versions of "carbon" jaggery module. Latest version
>>> of the module uses *tenant Id *as the input parameter to 
>>> *carbon.user.UserManager(...)
>>> *method, where as older version uses *tenant domain *as the input
>>> parameter. The product you are using is more likely to be using the older
>>> version of the module.
>>>
>>> Regards,
>>> Supun
>>>
>>> On Fri, May 15, 2015 at 11:23 PM, Shabir Mohamed <[email protected]>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> I'm developing a webapp using the core jaggery modules. Im trying to
>>>> add a new user to the carbon user store via my "Sign Up" page. Im using the
>>>> '*carbon*' jaggery module for this purpose.
>>>>
>>>> In the process of adding a new user, I get a *"null"* parameter error
>>>> [1] when I call the following line of code:
>>>>
>>>>     *var tenantId = carbon.server.tenantId();*
>>>> *    var url = getAddress('https') + "/admin/services";*
>>>> *    var server = new carbon.server.Server(url);*
>>>>
>>>> *    var userManager = new carbon.user.UserManager(server, tenantId); *
>>>>
>>>> I looked into the source of the *"user-manager.js"* which is located
>>>> at - */modules/carbon/scripts/user.*
>>>>
>>>> The error occurs as a result of this part of the source:
>>>>
>>>> *        var UserManager = function (serv, tenant) {*
>>>> *                                              tenant = tenant ||
>>>> server.superTenant.domain;*
>>>> *                                              this.server = serv;*
>>>>                                               *this.tenantId =
>>>> server.tenantId({*
>>>> *                                                       domain: tenant*
>>>> *                                              });*
>>>> *                              .........................*
>>>>
>>>> In the call for the *"server.tenantId"* in the above code, *domain* is
>>>> passed in with the value of "*tenant*" which is the *carbon.super* id
>>>> of *"-1234" *and not an actual domain-name*.*
>>>>
>>>> As a result *tenant.js *found inside
>>>> */modules/carbon/scripts/server/ *returns *"-1" [return domain ?
>>>> tenantManager.getTenantId(domain)] *which is set to* this.tenantId *
>>>> inside *"user-manager.js"**.*
>>>>
>>>> This error is carried onto the following sections of the code *(inside
>>>> user-manager.js)* and the code breaks at:
>>>>
>>>> *var realmService =
>>>> server.osgiService('org.wso2.carbon.user.core.service.RealmService'),*
>>>> *            realm = realmService.getTenantUserRealm(this.tenantId);
>>>>              // returns null*
>>>> *        this.manager = realm.getUserStoreManager();
>>>>                     ** // below mentioned [1] error occurs*
>>>>
>>>> The return from  *realmService.getTenantUserRealm(this.tenantId) *is
>>>> *"null"*, given that there is no actual tenant id of *"-1"*.
>>>>
>>>> -------------------------------------------------------------------------------------------
>>>>
>>>> This error has been evaded in the *"carbon" *module included in some
>>>> of our products [Ex: MDM] by simply removing the line thats causing the
>>>> error and only leaving the following:
>>>>
>>>> *  var UserManager = function (serv, tenant) {*
>>>> *                                              tenant = tenant ||
>>>> server.superTenant.domain;*
>>>> *                                              this.server = serv;*
>>>>                               ........................
>>>> *                              .........................*
>>>>
>>>> However, I worked around this issue by simple replacing *"tenant" *that
>>>> is passed in as *domain, *with *"server.superTenant.domain":*
>>>>
>>>> *     var UserManager = function (serv, tenant) {*
>>>> *                this.tenant = tenant || server.superTenant.domain;*
>>>> *                this.server = serv;*
>>>>
>>>> *                this.tenantId = server.tenantId({*
>>>> *                            domain: server.superTenant.domain*
>>>> *                 });*
>>>>                               ........................
>>>> *                              .........................*
>>>>
>>>>
>>>>
>>>> Please do let me know if I am missing anything important here.
>>>> Thanks!
>>>>
>>>>
>>>> *[1]*
>>>> [2015-05-15 21:16:49,912] ERROR
>>>> {org.jaggeryjs.scriptengine.engine.RhinoEngine} -
>>>>  org.mozilla.javascript.EcmaError: TypeError: Cannot call method
>>>> "getUserStoreManager" of null (user-manager#39)
>>>> [2015-05-15 21:16:49,912] ERROR
>>>> {org.jaggeryjs.jaggery.core.manager.WebAppManager} -
>>>>  org.mozilla.javascript.EcmaError: TypeError: Cannot call method
>>>> "getUserStoreManager" of null (user-manager#39)
>>>> org.jaggeryjs.scriptengine.exceptions.ScriptException:
>>>> org.mozilla.javascript.EcmaError: TypeError: Cannot call method
>>>> "getUserStoreManager" of null (user-manager#39)
>>>> at
>>>> org.jaggeryjs.scriptengine.engine.RhinoEngine.execScript(RhinoEngine.java:582)
>>>> at
>>>> org.jaggeryjs.scriptengine.engine.RhinoEngine.exec(RhinoEngine.java:280)
>>>> at
>>>> org.jaggeryjs.jaggery.core.manager.WebAppManager.execute(WebAppManager.java:432)
>>>> at
>>>> org.jaggeryjs.jaggery.core.JaggeryServlet.doPost(JaggeryServlet.java:29)
>>>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
>>>> 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.invoke(CompositeValve.java:177)
>>>> at
>>>> org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:161)
>>>> at
>>>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
>>>> at
>>>> org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:57)
>>>> 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:745)
>>>> Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot call
>>>> method "getUserStoreManager" of null (user-manager#39)
>>>> at
>>>> org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3687)
>>>> at
>>>> org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3665)
>>>> at
>>>> org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3693)
>>>> at
>>>> org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3712)
>>>> at
>>>> org.mozilla.javascript.ScriptRuntime.undefCallError(ScriptRuntime.java:3731)
>>>> at
>>>> org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2258)
>>>> at
>>>> org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2251)
>>>> at
>>>> org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:83)
>>>> at
>>>> org.mozilla.javascript.gen.user_manager_13._c_anonymous_3(user-manager:39)
>>>> at org.mozilla.javascript.gen.user_manager_13.call(user-manager)
>>>> at org.mozilla.javascript.BaseFunction.construct(BaseFunction.java:338)
>>>> at
>>>> org.mozilla.javascript.ScriptRuntime.newObject(ScriptRuntime.java:2349)
>>>> at
>>>> org.jaggeryjs.rhino.login.controller.c0._c_script_0(/login/controller/register-user.jag:49)
>>>> at
>>>> org.jaggeryjs.rhino.login.controller.c0.call(/login/controller/register-user.jag)
>>>> at
>>>> org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
>>>> at
>>>> org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
>>>> at
>>>> org.jaggeryjs.rhino.login.controller.c0.call(/login/controller/register-user.jag)
>>>> at
>>>> org.jaggeryjs.rhino.login.controller.c0.exec(/login/controller/register-user.jag)
>>>> at
>>>> org.jaggeryjs.scriptengine.engine.RhinoEngine.execScript(RhinoEngine.java:577)
>>>> ... 31 more
>>>>
>>>>
>>>> -------------------------------------
>>>> *Shabir Mohamed*
>>>> *Software Engineer*
>>>> WSO2 Inc.; http://wso2.com
>>>> Email: [email protected] <[email protected]>
>>>> Mobile: +94 77 3516019 | +94 71 6583393
>>>>
>>>>
>>>> _______________________________________________
>>>> Dev mailing list
>>>> [email protected]
>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>
>>>>
>>>
>>>
>>> --
>>> *Supun Sethunga*
>>> Software Engineer
>>> WSO2, Inc.
>>> http://wso2.com/
>>> lean | enterprise | middleware
>>> Mobile : +94 716546324
>>>
>>
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> Sameera Medagammaddegedara
> Software Engineer
>
> Contact:
> Email: [email protected]
> Mobile: + 94 077 255 3005
>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to