[bug-13808]IAE: No page attached to this thread

I’m attempting to perform navigation during a Barcode Scan Event, where when I scan the barcode the perspective Session Barcode Scanned Event constructs a page url based off of the text of the barcode. From my logging, the url is being constructed properly, but my Gateway logs are declaring an Illegal Argument Exception:

 com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.lambda$operateOnPage$18(PerspectiveScriptingFunctions.java:564) at
 com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.operateOnSession(PerspectiveScriptingFunctions.java:606) at
 com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.operateOnPage(PerspectiveScriptingFunctions.java:547) at
 com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.navigate(PerspectiveScriptingFunctions.java:78) at
 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
 java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at 
java.base/java.lang.reflect.Method.invoke(Unknown Source) java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: No perspective page attached to this thread.

The triggering code from the Perspective Session Barcode Scanned Event:


I’ve also tried


but the IAE remained.

Could this stem from the fact that the “camera” screen is displayed while the script is executing?

If I modify the Session Barcode Scanned Event to write to a session prop, and I move the navigation to a component on a page which is bound to the session prop, and perform the navigation as part of an onChange script, the navigation performs as expected.

I’m not completely sure whether this is “supposed” to work, so I filed an internal ticket so we can check it out and verify for sure. I’ll update this thread once that ticket is updated.

We’ve added the pageId to the context so you should have everything you need to navigate. You’ll end up calling system.perspective.navigate(page=data.text, pageId=context.pageId). The change will show up in 8.0.2. Thanks again for the feedback.

1 Like