Joost with javascript support - javascript

I am running Joost with javascript support.
Joost explains the usage here.
However, I am getting below errors
`Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/bsf/BSFManager
at net.sf.joost.stx.function.FunctionFactory.getBSFManager(FunctionFactory.java:279)
at net.sf.joost.stx.function.FunctionFactory.addScript(FunctionFactory.java:309)
at net.sf.joost.instruction.ScriptFactory$Instance.compile(ScriptFactory.java:195)
at net.sf.joost.stx.Parser.endElement(Parser.java:419)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1781)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2966)
CausedBy
Caused by: java.lang.ClassNotFoundException: org.apache.bsf.BSFManager
at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
I have added the below jars in classpath with command
export CLASSPATH=${CLASSPATH}:bsf-all-3.1.jar
export CLASSPATH=${CLASSPATH}:rhino-script-engine-1.1.1.jar
export CLASSPATH=${CLASSPATH}:rhino-1.7R5.jar `

Related

error occurs in jvm-npm.js when 'require' the serialport module

I am trying to communicate with serialport with javascript using nashorn engine in java
environment.
npm cannot be used in nashorn, but I want to use it through the jvm-npm project.
but An error occurs when you require the serialport module as shown below. Could you possibly know
the cause and solution?
testSensorRun.class
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.io.FileNotFoundException;
import java.io.FileReader;
public class testSensorRun {
public void func() throws ScriptException, FileNotFoundException, NoSuchMethodException {
System.setProperty("nashorn.args", "--language=es6");
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
engine.eval(new FileReader("serialport_check.js"));
}
}
serialport_check.js
load('jvm-npm.js');
const serialPort = require('serialport');
print("serial port hello");
error
> Task :nashrontest.main() FAILED
Warning: Nashorn engine is planned to be removed from a future JDK release
Cannot load module serialport LOAD_ERROR
Nashorn engine is planned to be removed from a future JDK release
Exception in thread "main" javax.script.ScriptException: Error: Cannot load module #serialport/parser-byte-length in jvm-npm.js at line number 108 at column number 8
at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:477)
at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:461)
at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:413)
at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:409)
at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:157)
at java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:249)
at sensorScript.testSensorRun.func(testSensorRun.java:17)
at nashrontest.main(nashrontest.java:9)
Caused by: jvm-npm.js:108:8 Error: Cannot load module #serialport/parser-byte-length
at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ECMAException.create(ECMAException.java:113)
at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$43$2272AA$jvm_npm.L:21#Require(jvm-npm.js:105)
at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$51$1573A$jvm_npm.L:21#Module#require(jvm-npm.js:53)
at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$60$\^function\_.L:1(<function>:14)
at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$56$1661AAAA$jvm_npm$cu1$restOf.L:21#_load(jvm-npm.js:62)
at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$43$2272AA$jvm_npm$cu1$restOf.L:21#Require(jvm-npm.js:99)
at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$1$\^eval\_/0x00000008001d2040.:program(<eval>:2)
at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:655)
at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:513)
at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:527)
at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:456)
... 6 more
Caused by: jvm-npm.js:108:8 Error: Cannot load module #serialport/parser-byte-length
Execution failed for task ':nashrontest.main()'.
> Process 'command 'C:/Users/bgkim/.jdks/openjdk-11.0.2_windows-x64_bin/jdk-11.0.2/bin/java.exe'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Eclipse 2021-09 is not showing outline for javascript files

I have eclipse 2021-09 (4.21.0) installed with Wild Web Developer 0.11.0 and Node.js embedder included. Javascript files are opened with Generic Text Editor, syntax highlighting is shown but outline view is empty. Even for the most simple *.js files. Take a look at the included screenshot:
What might be wrong? How to fix it?
EDIT:
The same problems exist in a fresh, newly created workspace, with the same example javascript file.
Quick Outline (Ctrl+O) produces java.util.concurrent.TimeoutException with the following message: LanguageServer not initialized after 10s
Exception Stack Trace:
java.util.concurrent.TimeoutException
at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1950)
at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2085)
at org.eclipse.lsp4e.LanguageServerWrapper.getServerCapabilities(LanguageServerWrapper.java:706)
at org.eclipse.lsp4e.LanguageServiceAccessor.lambda$12(LanguageServiceAccessor.java:557)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:176)
at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
at org.eclipse.lsp4e.LanguageServiceAccessor.getLSPDocumentInfosFor(LanguageServiceAccessor.java:558)
at org.eclipse.lsp4e.operations.symbols.LSPSymbolInFileHandler.execute(LSPSymbolInFileHandler.java:40)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:283)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:97)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173)
at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:156)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:488)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:487)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:213)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:308)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:580)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:647)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:439)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:96)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1270)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1059)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1084)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1069)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1111)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1107)
at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1536)
at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4875)
at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:345)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4753)
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4958)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(Native Method)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3624)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1150)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1041)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:156)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
at org.eclipse.equinox.launcher.Main.run(Main.java:1467)
Session data:
eclipse.buildId=4.21.0.I20210906-0500
java.version=15.0.1
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments: -product org.eclipse.epp.package.jee.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product
It seems like a symptom of https://github.com/eclipse/wildwebdeveloper/issues/294 . Monitor the issue for potential workarounds and resolutions.

How to use class when testing with Vue, Cypress and Cucumber?

I am trying to implement something simple: I want my e2e tests run with Cypress and cucumber.
I have an application created with Vue CLI 4.1.1. I added with NPM the package: cypress-cucumber-preprocessor (V1.19.0)
Edit:
After a lot of research and tests, I think I found where the problem comes from, but I don't know how to fix it yet:
The '#vue/cli-plugin-babel/preset' does not seem to be working with
.feature file...
My babel.config.js file is:
module.exports = {
presets: [
'#vue/cli-plugin-babel/preset'
]
}
Any idea how I can make cli-plugin-babel working with cucumber cypress?
Original message :
I have a Test.feature file, executing steps defined in test.step.js files.
Here is the content of my test.spec.js
import { When, Then } from 'cypress-cucumber-preprocessor/steps';
import { HomePage } from './pages/home.page';
When(/^I open the Home page$/, () => {
let homePage = new HomePage();
homePage.goTo();
});
Then(/^I see "([^"]*)" in the main heading$/, msg => {
cy.contains('h1', msg)
});
And the content of my PageObject home.page.js:
export class HomePage {
goTo() {
cy.visit("/");
}
}
When I run:
npm run test:e2e
I get the following error:
Oops...we found an error preparing this test file:
tests/e2e/features/Test.feature
The error was:
SyntaxError: 'import' and 'export' may appear only with 'sourceType: module'
This occurred while Cypress was compiling and bundling your test code. This is usually caused by:
- A missing file or dependency
- A syntax error in the file or one of its dependencies
Fix the error in your code and re-run your tests.
These errors does not occur when I use:
export function goToHomePage() {
cy.visit("/");
}
You can checkout my project on Github: https://github.com/truar/cloudcmr-v2 (branch master for the passing case, branch pageObject_pattern for the failing case).
I am assuming this is something related to ES6 and cypress... but I clearly don't know what is going on here. Besides, everything I find on the Internet talks about cypress cucumber and Typescript, which I don't use...
What am I missing?
I found the answer. See this PR for more details : https://github.com/cypress-io/cypress/issues/2945
Basically, there is an incompatibility between Babel 7 and Cypress 3. I had to change the babel.config.js file :
module.exports = process.env.CYPRESS_ENV
? {}
: {
presets: ["#vue/cli-plugin-babel/preset"]
};
It is just a workaround, not a real fix. We have to disable babel when running cypress.
Hope will help you !

Wasm compilation exceeds internal limits in this context for the provided arguments

So I am trying to create a WebAssembly Module from an ArrayBuffer.
C code:
#include <stdio.h>
int main() {
printf("hello, world!\n");
return 0;
}
I compile it like so:
$ emcc -O2 hello.c -s WASM=1 -o hello.html
I start a local http server.
And I try to load it in my browser like so:
fetch('hello.wasm')
.then(res => res.arrayBuffer())
.then(buff => WebAssembly.Module(buff));
And I get the following error:
Uncaught (in promise) RangeError: WebAssembly.Module(): Wasm compilation exceeds internal limits in this context for the provided arguments
at fetch.then.then.buff (:1:77)
at
I don't what to make of this error and I can't find anything via web searches.
Any help is kindly appreciated
Thanks!
WebAssembly.Module is synchronous and some browsers don't allow large modules on the main thread to avoid having compilation block the main thread.
Try this instead:
fetch('hello.wasm').then(response =>
response.arrayBuffer()
).then(buffer =>
WebAssembly.instantiate(buffer, importObj)
).then(({module, instance}) =>
instance.exports.f()
);
It's better to use WebAssembly.instantiate because it does compilation and instantiation together and allows the engine to keep at the importObject to make sure things look OK (especially, the WebAssembly.Memory).
Here I assume you want more than main, and instead want to invoke your module's exported function f.

Compiling GLUT using Emscripten

I am trying to compile the following code:
http://pastebin.com/024Ew4fK
And I am using the following directives:
-s LEGACY_GL_EMULATION=1 -lglut -lGLU -lGL
I got the following warnings:
warning: unresolved symbol: glPointSize
warning: unresolved symbol: glutSolidSphere
warning: unresolved symbol: glutWireSphere
And these are the errors:
WARNING: using emscripten GL immediate mode emulation. This is very limited in what it supports
missing function: glPointSize
uncaught exception: abort(-1) at jsStackTrace#file:///C:/Users/Tyrion/Documents/Proyectos/GLUT_SolarSystem/out.js:1173:13
stackTrace#file:///C:/Users/Tyrion/Documents/Proyectos/GLUT_SolarSystem/out.js:1190:22
abort#file:///C:/Users/Tyrion/Documents/Proyectos/GLUT_SolarSystem/out.js:15901:44
_glPointSize#file:///C:/Users/Tyrion/Documents/Proyectos/GLUT_SolarSystem/out.js:2135:56
_main#file:///C:/Users/Tyrion/Documents/Proyectos/GLUT_SolarSystem/out.js:11483:2
asm._main#file:///C:/Users/Tyrion/Documents/Proyectos/GLUT_SolarSystem/out.js:15672:8
callMain#file:///C:/Users/Tyrion/Documents/Proyectos/GLUT_SolarSystem/out.js:15766:15
doRun#file:///C:/Users/Tyrion/Documents/Proyectos/GLUT_SolarSystem/out.js:15824:42
run/<#file:///C:/Users/Tyrion/Documents/Proyectos/GLUT_SolarSystem/out.js:15835:7
setTimeout handler*run#file:///C:/Users/Tyrion/Documents/Proyectos/GLUT_SolarSystem/out.js:15831:5
#file:///C:/Users/Tyrion/Documents/Proyectos/GLUT_SolarSystem/out.js:15927:1
Why does it say that glPointSize is missing?
These are the features of Glut supported by Emscripten:
https://github.com/kripken/emscripten/blob/master/src/library_glut.js
In order to draw something, for example a sphere, Kripken suggested somewhere to look for a function written in C that does it by itself and then, to port that function to my program.

Categories