java.lang.NullPointerException when calling \$sp.getCatalogItem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2017 09:06 PM
When using the sc_cat_item widget on existing catalog items, for more than 50% of them, I get the following error. Note that accessing them not via service portal is fine.
I then cloned the widget so I can change the code to isolate the exact line. It appears to be failing at the following line:
data.sc_cat_item = $sp.getCatalogItem(data.sys_id);
I put that in a try catch block and logged the error using the following code:
! !
The log I obtained is as follows:
Trying to get catalog item for 9c5c31ca4f66ae40014bb2f11310c787. There was an error in this widget: null:
com.glide.service_portal.variables.VariableModel.getMappedFieldLength(VariableModel.java:248)
com.glide.service_portal.variables.VariableModel.getMaxLength(VariableModel.java:225)
com.glide.service_portal.variables.VariableModel.buildVariable(VariableModel.java:190)
com.glide.service_portal.variables.VariableModel.get(VariableModel.java:80)
com.glide.service_portal.catalog.SPCatalog.getItem(SPCatalog.java:28)
com.glide.service_portal.widget.SPScriptable.getCatalogItem(SPScriptable.java:914)
sun.reflect.GeneratedMethodAccessor3975.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.mozilla.javascript.MemberBox.invoke(MemberBox.java:138)
org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:292)
org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2577)
org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
org.mozilla.javascript.gen._refname__70030._c_anonymous_2(<refname>:15)
org.mozilla.javascript.gen._refname__70030.call(<refname>)
org.mozilla.javascript.ScriptRuntime.doCall2(ScriptRuntime.java:2645)
org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2582)
org.mozilla.javascript.optimizer.OptRuntime.call0(OptRuntime.java:23)
org.mozilla.javascript.gen._refname__70030._c_anonymous_1(<refname>:2)
org.mozilla.javascript.gen._refname__70030.call(<refname>)
org.mozilla.javascript.ScriptRuntime.doCall2(ScriptRuntime.java:2645)
org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2582)
org.mozilla.javascript.optimizer.OptRuntime.call0(OptRuntime.java:23)
org.mozilla.javascript.gen._refname__70030._c_script_0(<refname>:1)
org.mozilla.javascript.gen._refname__70030.call(<refname>)
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:563)
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3439)
org.mozilla.javascript.gen._refname__70030.call(<refname>)
org.mozilla.javascript.gen._refname__70030.exec(<refname>)
com.glide.script.ScriptEvaluator.execute(ScriptEvaluator.java:259)
com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:110)
com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:76)
com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:67)
com.glide.service_portal.SPScriptEvaluator.eval(SPScriptEvaluator.java:36)
com.glide.service_portal.widget.SPScriptRunner.eval(SPScriptRunner.java:202)
com.glide.service_portal.widget.SPScriptRunner.runScript(SPScriptRunner.java:83)
com.glide.service_portal.widget.SPWidget.get(SPWidget.java:109)
com.glide.service_portal.widget.SPWidget.get(SPWidget.java:92)
com.glide.service_portal.SPPage.getColumnRectangles(SPPage.java:277)
com.glide.service_portal.SPPage.getRowColumns(SPPage.java:221)
com.glide.service_portal.SPPage.getContainerRows(SPPage.java:201)
com.glide.service_portal.SPPage.getContainers(SPPage.java:188)
com.glide.service_portal.SPPage.getPage(SPPage.java:98)
com.glide.service_portal.SPPage.get(SPPage.java:55)
com.glide.service_portal.SPRestService.page(SPRestService.java:43)
sun.reflect.GeneratedMethodAccessor4024.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
com.glide.rest.handler.impl.ServiceHandlerImpl.invokeService(ServiceHandlerImpl.java:43)
com.glide.rest.processors.RESTAPIProcessor.process(RESTAPIProcessor.java:228)
com.glide.processors.AProcessor.runProcessor(AProcessor.java:424)
com.glide.processors.AProcessor.processTransaction(AProcessor.java:195)
com.glide.processors.ProcessorRegistry.process0(ProcessorRegistry.java:178)
com.glide.processors.ProcessorRegistry.process(ProcessorRegistry.java:167)
com.glide.ui.GlideServletTransaction.process(GlideServletTransaction.java:49)
com.glide.sys.Transaction.run(Transaction.java:1976)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)
My suspicion is that it is just a service portal java function issue (as other ways of accessing the form are all okay. Only in portal widgets do we see this problem)
Any help would be much appreciated.
Many thanks in advance. !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2017 02:37 PM
Hi Sujan,
I began to receive the error as well...after adding a variable to a form in the catalog. I read over this thread, set the variable from true to false and no more error. The password reset form came up with no problems. I agree, somehow the new variable was causing the issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2018 11:45 AM
Hi shahrin ,
I am also getting same errors for few catalog items.Have you find any solution for this?
Any help would be appreciated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2018 04:46 AM
Hello,
The issue should be related to one of the Variables for which the Map to Field is selected. Try to deactivate those variables and you will see the Cat Item correctly.
Marco

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2018 02:27 PM
We were having this problem, and it turned out that there was a mandatory field on the Variable definition (item_option_new) record that was empty.
To find the problem
- We made all the variables for the catalog item in-active and verified that the catalog item loaded.
- Then we enabled the variables until we got the error.
The problem variables had required fields that were empty.
Hope this helps.
Thanks,
Cody
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2018 08:34 AM
Hi ,
If I have specific role ,I am not getting this error,if I don't have that role I am getting this error.Can anyone help me with this?