我正在使用 flask-appbuilder 来构建一个应用程序。为了提交一个表单来执行ddl,我在startJVM()的时候给jpype添加了一个jar文件,但是java总是崩溃。下面是我的代码:
import jaydebeapi
from flask import flash
def execute_ddl(dic):
def set_up_conn(dic):
conn = jaydebeapi.connect(jclassname=dic['jclass'],
url=dic['url'],
driver_args=[dic['driver_name'],
dic['driver_params']],
jars=dic['jars'])
curs = conn.cursor()
curs.execute(dic['ddl'])
output = curs.fetchall()
print(output)
curs.close()
conn.close()
try:
import jpype
if not jpype.isJVMStarted():
jvmPath = jpype.getDefaultJVMPath()
flash(str(jvmPath), 'info')
jpype.startJVM(jvmPath, "-ea", "-Djava.class.path=/lib/uber-hive-jdbc-1.2.1.jar")
if not jpype.isThreadAttachedToJVM():
jpype.attachThreadToJVM()
jpype.java.lang.Thread.currentThread().\
setContextClassLoader(jpype.java.lang.ClassLoader.getSystemClassLoader())
set_up_conn(dic)
# post process form
flash('{} is submitted!'.format(dic['ddl']), 'info')
except Exception as e:
flash(str(e), 'info')
这是崩溃错误,我尝试了“ulimit -c unlimited”但没有运气。
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007fce15f978b9, pid=12, tid=0x00007fce0f7fe700
#
# JRE version: OpenJDK Runtime Environment (8.0_181-b13) (build 1.8.0_181-8u181-b13-2~deb9u1-b13)
# Java VM: OpenJDK 64-Bit Server VM (25.181-b13 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [_jpype.cpython-37m-x86_64-linux-gnu.so+0x3f8b9]
JPJavaEnv::NewLocalRef(_jobject*)+0x9
#
# 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_pid12.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp