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
‎05-07-2018 05:27 PM
Hi Sumanth,
Without knowing more information, I cannot give you any specific help.
What is the role that you have when you are getting the error?
What are the roles that a user can have and not get the error?
Is this problem happening on all of your catalog items or only on specific catalog items?
Thanks,
Cody

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2018 02:28 AM
Hi,
I know the thread is quite old but this might help someone. I had the same issue and in my case there was a reference variable referencing a deleted table. First I deactivated the variable, later configured it's table correctly and everything works fine.
Lukas