Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Nashorn throwing java.lang.RuntimeException: java.lang.ClassNotFoundException
Nashorn throwing java.lang.RuntimeException: java.lang.ClassNotFoundException [message #1786693] Wed, 09 May 2018 14:03
Adrián Salinero is currently offline Adrián SalineroFriend
Messages: 6
Registered: October 2017
Junior Member
Hi,

I am using the Eclipse SCADA framework which uses Nashorn to integrate JavaScript into Java.

One feature of Nashorn is that you are able to call Java code directly from the JavaScript fragments.

I have read on some tutorials that in order to invoke a java method you have to use:

var MyJavaClass = Java.type('countdown2.test2');

but I get the following errors:

!ENTRY org.eclipse.scada.vi.ui.draw2d 4 0 2018-05-09 15:45:08.572
!MESSAGE countdown2.test2 cannot be found by org.eclipse.scada.vi.ui.draw2d_0.3.0.v20160226-1536
!STACK 0
java.lang.RuntimeException: java.lang.ClassNotFoundException: countdown2.test2 cannot be found by org.eclipse.scada.vi.ui.draw2d_0.3.0.v20160226-1536
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:397)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:421)
at jdk.nashorn.api.scripting.NashornScriptEngine.access$300(NashornScriptEngine.java:73)
at jdk.nashorn.api.scripting.NashornScriptEngine$3.eval(NashornScriptEngine.java:514)
at org.eclipse.scada.utils.script.ScriptExecutor.executeScript(ScriptExecutor.java:259)
at org.eclipse.scada.utils.script.ScriptExecutor.access$1(ScriptExecutor.java:239)
at org.eclipse.scada.utils.script.ScriptExecutor$3.call(ScriptExecutor.java:295)
at org.eclipse.scada.utils.script.Scripts.executeWithClassLoader(Scripts.java:123)
at org.eclipse.scada.utils.script.ScriptExecutor.execute(ScriptExecutor.java:290)
at org.eclipse.scada.utils.script.ScriptExecutor.execute(ScriptExecutor.java:285)
at org.eclipse.scada.vi.ui.draw2d.SymbolController.runUpdate(SymbolController.java:560)
at org.eclipse.scada.vi.ui.draw2d.SymbolController.handleDataUpdate(SymbolController.java:550)
at org.eclipse.scada.vi.ui.draw2d.SymbolController$2.run(SymbolController.java:503)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4155)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3772)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:694)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:606)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at ejemplo.Application.start(Application.java:20)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
Caused by: java.lang.ClassNotFoundException: countdown2.test2 cannot be found by org.eclipse.scada.vi.ui.draw2d_0.3.0.v20160226-1536
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:439)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:352)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:344)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at jdk.nashorn.internal.runtime.Context.findClass(Context.java:1051)
at jdk.nashorn.internal.objects.NativeJava.simpleType(NativeJava.java:498)
at jdk.nashorn.internal.objects.NativeJava.type(NativeJava.java:322)
at jdk.nashorn.internal.objects.NativeJava.type(NativeJava.java:314)
at jdk.nashorn.internal.objects.NativeJava.type(NativeJava.java:310)
at jdk.nashorn.internal.scripts.Script$Recompilation$23$1510$cilindrovertical.updateValve(cilindrovertical.js:46)
at jdk.nashorn.internal.scripts.Script$2$onUpdate.:program(onUpdate:1)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:637)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
... 38 more


Am I doing something wrong? I am writing the JavaScript code in the "cilindrovertical.js" file and I am referencing the "test2" class which is in the "src" file. How should I write the Java.type code?

https://i.imgur.com/DExadEz.jpg

Thanks in advance for answers.
Previous Topic:Interface Particle Photon with Industrial Sensor
Next Topic:I can't install eclipse
Goto Forum:
  


Current Time: Tue Sep 25 07:32:05 GMT 2018

Powered by FUDForum. Page generated in 0.05723 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top