While executing the following line my server halted for the second request.
Invocable invocableEngine = load();
Object o1 = invocableEngine.invokeFunction("add",5,6,jsonObj);
private static Invocable invocable =null;
public static Invocable load() throws ScriptException, NoSuchMethodException, FileNotFoundException {
if(invocable!=null){
return invocable;
}
File jsFile = new File("test.js");
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("jav8"); //No I18N
Reader reader = new FileReader(jsFile);
engine.eval(reader);
invocable = (Invocable) engine;
return invocable;
}
test.js
add = function(a, b) {
return a + b;
}
I dont want to evaluate the js for each request, so that i used the Invocable as static.
This is the error thrown in the console
A fatal error has been detected by the Java Runtime Environment:
SIGSEGV (0xb) at pc=0x0000000121d6f4b4, pid=791, tid=33539
JRE version: Java(TM) SE Runtime Environment (8.0_25-b17) (build
1.8.0_25-b17) Java VM: Java HotSpot(TM) 64-Bit Server VM (25.25-b02 mixed mode bsd-amd64 compressed oops) Problematic frame: C
[libjav8651059438244345661.dylib+0x184b4]
_ZN2v811HandleScopeC1Ev+0x84
Failed to write core dump. Core dumps have been disabled. To enable
core dumping, try "ulimit -c unlimited" before starting Java again
An error report file with more information is saved as:
hs_err_pid791.log
If you would like to submit a bug report, please visit:
http://bugreport.sun.com/bugreport/crash.jsp The crash happened
outside the Java Virtual Machine in native code. See problematic
frame for where to report the bug.
Related
I am getting JVM crash issue frequently while trying to write to the Excel file.I am using Apache POI 3.12 and Java 8 and Tomcat Server.
I get the following hs_err_pid error:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGBUS (0x7) at pc=0x00007f16e02d1ec0, pid=1135, tid=0x00007f1595ef8700
#
# JRE version: OpenJDK Runtime Environment (8.0_352-b08) (build 1.8.0_352-8u352-ga-1~18.04-b08)
# Java VM: OpenJDK 64-Bit Server VM (25.352-b08 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [libzip.so+0x4ec0]
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
------
Stack: [0x00007f1595df8000,0x00007f1595ef9000], sp=0x00007f1595ef5900, free space=1014k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [libzip.so+0x4ec0]
C [libzip.so+0x5b6e]
C [libzip.so+0x3b25] Java_java_util_zip_ZipFile_getEntry+0x85
J 91 java.util.zip.ZipFile.getEntry(J[BZ)J (0 bytes) # 0x00007f16cd13ea8e [0x00007f16cd13e9c0+0xce]
J 123871 C2 java.util.zip.ZipFile.getInputStream(Ljava/util/zip/ZipEntry;)Ljava/io/InputStream; (304 bytes) # 0x00007f16d6716944 [0x00007f16d67165c0+0x384]
J 124037 C2 org.apache.poi.openxml4j.opc.PackagePart.getInputStream()Ljava/io/InputStream; (44 bytes) # 0x00007f16cda4bd00 [0x00007f16cda4bc60+0xa0]
J 103326 C1 org.apache.poi.POIXMLProperties.<init>(Lorg/apache/poi/openxml4j/opc/OPCPackage;)V (212 bytes) # 0x00007f16d6af7374 [0x00007f16d6af6300+0x1074]
J 100022 C1 org.apache.poi.POIXMLDocument.getProperties()Lorg/apache/poi/POIXMLProperties; (40 bytes) # 0x00007f16cd79ddfc [0x00007f16cd79dce0+0x11c]
J 67174 C1 org.apache.poi.POIXMLDocument.write(Ljava/io/OutputStream;)V (35 bytes) # 0x00007f16cd89404c [0x00007f16cd893a80+0x5cc]
J 65014 C1 com.bulk.helper.ExcelUtility.saveWorkBook(Lorg/apache/poi/ss/usermodel/Workbook;Ljava/lang/String;Ljava/lang/String;)V (89 bytes) # 0x00007f16cd543754 [0x00007f16cd542ea0+0x8b4]
J 71211 C1 com.bulk.helper.ExcelAccess.save_userfile(Ljava/lang/String;Ljava/lang/String;)V (14 bytes) # 0x00007f16ce6e46ec [0x00007f16ce6e4640+0xac]
J 93237 C1
The following is the code:
Calling class:
accessFile.save_newFile(---);
Common Method Class:
#Override
public void save_userfile(String filePath , String fileName) {
utility.saveWorkBook(userWorkbook,filePath,fileName);
}
public void saveWorkBook(Workbook workbook ,String filePath, String fileName){
try
{
File directory = new File(filePath);
if (!directory.exists()) {
directory.mkdir();
}
File file = new File(directory,fileName);
OutputStream out = new FileOutputStream(file);
workbook.write(out);
out.flush();
out.close();
workbook.close();
}catch(Exception e){
LOG.error(Constants.ERROR_STRING,e);
}
}
I am aware of the solution of putting "-Dsun.zip.disableMemoryMapping=true" parameter.
Enabling this option will impact performance because the VM will have to conduct some additional disk IO every time it reads an entry from a JAR file (to interrogate the central directory structure).
Want to solve this issue programmatically in java 8 itself.
Any help will be appreciated,Thanks in advance..
I don't know if there is any solution in Java 8 other the one you have already mentioned; i.e. disabling memory mapping.
However if you look at the various JDK bug reports for native code crashes in getEntry, they are marked as "resolved in Java 9". So upgrading to Java 11 is a possible solution.
In Java 9 they have replaced the native implementation of ZipFile with a pure Java implementation.
For reference, here are some of related Java bug reports against Java 8 and earlier versions:
https://bugs.openjdk.org/browse/JDK-8142508
https://bugs.openjdk.org/browse/JDK-8144958
https://bugs.openjdk.org/browse/JDK-8145260
https://bugs.openjdk.org/browse/JDK-7142247
I'm trying to get into Vulkan with LWJGL.
Currently I'm creating some sort of window (wrapper) class, however whenever i try to invoke glfwGetWindowSize, glfwGetWindowPos or glfwGetMonitorPos the program crashes with a segmentation fault. The window creation itself works fine though, and i can also move the window programatically. I use default window hints (glfwDefaultWindowHints).
The code:
var wbuf = IntBuffer.allocate(1);
var hbuf = IntBuffer.allocate(1);
glfwGetWindowSize(this.handle, wbuf, hbuf);
this.width = wbuf.get();
this.height = hbuf.get();
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f29938156b5, pid=13791, tid=13797
#
# JRE version: OpenJDK Runtime Environment Temurin-17.0.5+8 (17.0.5+8) (build 17.0.5+8)
# Java VM: OpenJDK 64-Bit Server VM Temurin-17.0.5+8 (17.0.5+8, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# C [libglfw.so+0x156b5] glfwGetWindowSize+0x5
Environment: LWJGL v3.3.1 (with GLFW linux natives), Vulkan SDK v1.3.236.0 x86_64, Java 17 (Temurin), Fedora 36
As a side note: I'm also applying class loader tweaks before the GLFW init.
I was using non-direct buffers, while the LWJGL GLFW bidings only support direct ones.
Using direct buffers works fine:
try (var stack = MemoryStack.stackPush()) {
var width = stack.mallocInt(1);
var height = stack.mallocInt(1);
glfwGetWindowSize(this.handle, width, height);
this.width = width.get();
this.height = height.get();
}
MemoryUtil.memAllocInt(1) and ByteBuffer.allocateDirect(4).asIntBuffer() works as well.
I'm trying to code an opengl renderer with lwjgl. To open the window, I'm using glfw. However, when I call glfwCreateWindow, it crashes with this error:
A fatal error has been detected by the Java Runtime Environment:
SIGSEGV (0xb) at pc=0x00007fff2d732924, pid=64615, tid=775
JRE version: Java(TM) SE Runtime Environment (14.0.2+12) (build 14.0.2+12-46)
Java VM: Java HotSpot(TM) 64-Bit Server VM (14.0.2+12-46, mixed mode, sharing, tiered, compressed oops, g1 gc, bsd-amd64)
Problematic frame:
C [HIToolbox+0x27924] _ZNK22THIThemeTextInfoFinder10GetOptionsEv+0x8
No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
An error report file with more information is saved as:
/Users/vic/eclipse-workspace/Engine/hs_err_pid64615.log
If you would like to submit a bug report, please visit:
https://bugreport.java.com/bugreport/crash.jsp
Here is my code:
package main;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWVidMode;
public class Main {
public static void main(String[] args) {
if(!GLFW.glfwInit()) {
System.err.println("Failed to initialize glfw");
System.exit(-1);
}
GLFW.glfwDefaultWindowHints();
GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE);
GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, GLFW.GLFW_TRUE);
long window = GLFW.glfwCreateWindow(640, 480, "My window", 0, 0);
if(window == 0) {
System.err.println("Failed to create window");
System.exit(-1);
}
GLFWVidMode videoMode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());
GLFW.glfwSetWindowPos(window, (videoMode.width() - 640) / 2, (videoMode.height() - 480) / 2);
GLFW.glfwShowWindow(window);
while(!GLFW.glfwWindowShouldClose(window)) {
GLFW.glfwPollEvents();
}
GLFW.glfwTerminate();
}
}
I'm using mac and eclipse.
Thanks!
The solution is to add -XstartOnFirstThread to the JVM arguments.
1 - I downloaded tesdata on the git hub https://github.com/tesseract-ocr/tessdata
2 - Extract the folder and passed the path to the Tesseract class
3 - When running the application the following error is displayed
Extract the folder and passed the path to the Tesseract class
When running the application the following error is displayed
Code snippet executed
public class TesseractOcrTest {
private final String tesseractPath = "/home/tessdata/";
#Test
public void shouldReturnTrueIfRunOcrEquals() throws Exception {
String result = new TesseractOcr(tesseractPath).runOcr("bw_HighResolution_en.jpeg").trim();
assertEquals(
"Optical Character Recognition in Java\nis made easy with the help of Tesseract", result);
}
}
Error
Error: Illegal Parameter specification!
"Fatal error encountered!" == NULL:Error:Assert failed:in file globaloc.cpp, line 75
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f52a582d69b, pid=8957, tid=8966
#
# JRE version: OpenJDK Runtime Environment (11.0.7+10) (build 11.0.7+10-post-Ubuntu-2ubuntu218.04)
# Java VM: OpenJDK 64-Bit Server VM (11.0.7+10-post-Ubuntu-2ubuntu218.04, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# C [libtesseract.so.4+0x25969b] ERRCODE::error(char const*, TessErrorLogCode, char const*, ...) const+0x16b
Note: When I change the path from tesdata to the OS installation path (private final String tesseractPath = "/usr/share/tesseract-ocr/4.00/tessdata/";) I can do it perfectly. It just doesn't work if I point to the tesdata downloaded from the git hub.
What am I doing wrong? When downloaded from github do you need to do any more configuration?
You've probably used incompatible language data. For the current Tesseract verion, use tessdata_best or tessdata_fast, which comes with Linux distros. (You can verify by checking the file size.)
https://github.com/tesseract-ocr
Make sure you have installed only one version of tesseract
Fist check with version of tesseract you used (installed). Use the latest version (4.x or 5 alpha)
Test OCR with tesseract executable instead of wrapper - it can provide more information for finding problem.
I'm trying to make JCEF to work in a swingNode in a simple JavaFX Application
public class MainApp extends Application {
#Override
public void start(Stage stage) throws Exception {
SwingNode swingNode = new SwingNode();
SwingUtilities.invokeAndWait(() -> {
String startURL = "https://www.google.com/";
boolean useOSR = OS.isLinux();
boolean isTransparent = false;
CefSettings settings = new CefSettings();
settings.windowless_rendering_enabled = useOSR;
CefApp cefApp_ = CefApp.getInstance(settings);
CefClient client_ = cefApp_.createClient();
CefBrowser browser_ = client_.createBrowser(startURL, useOSR, isTransparent);
Component browerUI_ = browser_.getUIComponent();
JPanel panel = new JPanel();
panel.setSize(800, 600);
panel.add(browerUI_, BorderLayout.CENTER);
swingNode.setContent(panel);
});
stage.setScene(new Scene(new javafx.scene.Group(swingNode)));
stage.show();
}
public static void main(String[] args) {
launch(args);
}
I'm getting a fatal error at client_.createBrowser(startURL, useOSR, isTransparent);
initialize on Thread[AWT-EventQueue-0,6,main] with library path /path/to/jcef/lib/linux64
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f3d07fced50, pid=22843, tid=0x00007f3ca5991700
#
# JRE version: Java(TM) SE Runtime Environment (8.0_111-b14) (build 1.8.0_111-b14)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.111-b14 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [ld-linux-x86-64.so.2+0x9d50]
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /path/to/jcef-javafx-maven/hs_err_pid22843.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
#
however, the provided JCEF awt test examples runs perfectly.
JCEF Version = 3.2840.147
CEF Version = 3.2840.1511
Chromium Version = 54.0.2840.59
Oracle JDK version = 1.8.0_111
edit1: digging into the jcef java code, the fatal error happens at CefBrowserOsr.java line 134
private void createGLCanvas() {
GLProfile glprofile = GLProfile.getMaxFixedFunc(true); // here
edit2: error log hs_err_pid.log content.
Upgrading to JOGL 2.3.2 and rebuilding JCEF again partially fixes the problem (no jvm crash happens anymore)
however, it seems that the SwingNode would not render a very complicated stuff like a GLCanvas, reference.