Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to start Java VM, second time. Linux #88

Closed
johncookds opened this issue Jul 6, 2016 · 5 comments

Comments

@johncookds
Copy link

commented Jul 6, 2016

Hello,

I have been running a python function that uses javabridge for some time on my mac and have had no problems. I have switched over to linux and have a bug where the Java VM fails to start on the second iteration. I have performed every check and tested every version of java, javabridge and the other packages I'm using that I can think of. The problem is below:

***Before this error the function is called once and performs very well
It uses this to start the VM:
javabridge.start_vm(run_headless=True, max_heap_size = java_max_heap_size)
javabridge.attach()

and this at the end to close it:
javabridge.detach()
javabridge.kill_vm()

***During the second iteration this problem occurs
This does not occur on my mac I believe because there is a separate process for starting a VM on a mac in jutil.py.

***This is the problem:
env = vm.create(args)
File "_javabridge.pyx", line 615, in _javabridge.JB_VM.create (_javabridge.c:6647)
RuntimeError: Failed to create Java VM. Return code = -1
No handlers could be found for logger "javabridge.jutil"
Traceback:
javabridge.start_vm(run_headless=True, max_heap_size = java_max_heap_size)

File "javabridge/jutil.py", line 312, in start_vm
raise RuntimeError("Failed to start Java VM")

RuntimeError: Failed to start Java VM.

Any help would be greatly appreciated.

@LeeKamentsky

This comment has been minimized.

Copy link
Owner

commented Jul 6, 2016

Yup - that is a fundamental limitation - you can call javabridge.start_vm at most one time. I am really surprised you managed to restart the JVM on the Mac - it's not at all supported. It's very tricky to manage the JVM's scope so that it is instantiated only once and killed only once and unfortunately requires more thought than it deserves.

For more information, see http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4712793 which documents a simple test case that fails to restart the JVM after shutting it down.

In any case, thanks for using Javabridge, John and good luck.

@rupav

This comment has been minimized.

@LeeKamentsky

This comment has been minimized.

Copy link
Owner

commented Aug 21, 2018

I'm afraid it's not under our control. It's a limitation of the JVM itself. I would look at where the javabridge initialization is done in your app (or in the library that's starting the javabridge) and make sure it's done only once.

@amber0309

This comment has been minimized.

Copy link

commented Aug 8, 2019

Yup - that is a fundamental limitation - you can call javabridge.start_vm at most one time. I am really surprised you managed to restart the JVM on the Mac - it's not at all supported. It's very tricky to manage the JVM's scope so that it is instantiated only once and killed only once and unfortunately requires more thought than it deserves.

For more information, see http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4712793 which documents a simple test case that fails to restart the JVM after shutting it down.

In any case, thanks for using Javabridge, John and good luck.

Just ran into this problem. I was wondering whether there were any ways to fix this now (Aug. 2019)? Much appreciated!

@LeeKamentsky

This comment has been minimized.

Copy link
Owner

commented Aug 8, 2019

Nope, I wish there were, but you will have to find some way to work around it if you plan to use the JVM at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.