httl项目报错Please run with JDK (NOT JVM),compiler=httl.spi.compilers.JavassistCompiler

 

环境:

服务器:本地机器,Windows10,64位

JDK1.8

 背景:

接手公司原来框架项目,发布打包发布到本地后出现下放报错,百度搜索报错信息,并未找到解决方案。写下此内容,希望能够帮助其他不幸遇到此问题的小伙伴解决此报错。

主要报错信息:

Caused by: java.lang.IllegalStateException: Can not get system java compiler. Please run with JDK (NOT JVM), or configure the httl.properties: compiler=httl.spi.compilers.JavassistCompiler, and add javassist.jar.

完整报错信息: 

ameba.container.ContainerException: java.lang.reflect.InvocationTargetException
        at ameba.container.Container.create(Container.java:65)
        at ameba.Ameba.bootstrap(Ameba.java:164)
        at ameba.Ameba.bootstrap(Ameba.java:149)
        at ameba.Ameba.main(Ameba.java:120)
Caused by: java.lang.reflect.InvocationTargetException: null
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at ameba.container.Container.create(Container.java:63)
        ... 3 common frames omitted
Caused by: java.lang.IllegalStateException: Failed to init property value. key: engine, value: httl.spi.engines.DefaultEngine, cause: Failed to init properties of bean class httl.spi.engines.DefaultEngine, cause: Failed to init property value. key: map.converter, value: httl.spi.converters.MultiMapConverter, cause: Failed to init properties of bean class httl.spi.converters.MultiMapConverter, cause: Failed to init property value. key: map.converters, value: httl.spi.converters.StringMapConverter, cause: Failed to init properties of bean class httl.spi.converters.StringMapConverter, cause: Failed to init property value. key: codecs, value: httl.spi.codecs.JsonCodec, cause: Failed to init properties of bean class httl.spi.codecs.JsonCodec, cause: Failed to init property value. key: compiler, value: httl.spi.compilers.AdaptiveCompiler, cause: Failed to init properties of bean class httl.spi.compilers.AdaptiveCompiler, cause: Can not get system java compiler. Please run with JDK (NOT JVM), or configure the httl.properties: compiler=httl.spi.compilers.JavassistCompiler, and add javassist.jar.
        at httl.util.BeanFactory.getInstance(BeanFactory.java:323)
        at httl.util.BeanFactory.createBean(BeanFactory.java:139)
        at ameba.mvc.template.httl.HttlMvcFeature.configure(HttlMvcFeature.java:103)
        at org.glassfish.jersey.model.internal.CommonConfig.configureFeatures(CommonConfig.java:730)
        at org.glassfish.jersey.model.internal.CommonConfig.configureMetaProviders(CommonConfig.java:648)
        at org.glassfish.jersey.server.ResourceConfig.configureMetaProviders(ResourceConfig.java:829)
        at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:453)
        at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:184)
        at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:350)
        at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:347)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
        at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255)
        at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:347)
        at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:311)
        at ameba.container.grizzly.server.http.GrizzlyHttpContainer.<init>(GrizzlyHttpContainer.java:104)
        at ameba.container.grizzly.server.http.GrizzlyHttpContainerProvider.createContainer(GrizzlyHttpContainerProvider.java:18)
        at org.glassfish.jersey.server.ContainerFactory.createContainer(ContainerFactory.java:81)
        at ameba.container.grizzly.server.GrizzlyContainer.configureHttpContainer(GrizzlyContainer.java:235)
        at ameba.container.Container.<init>(Container.java:44)
        at ameba.container.grizzly.server.GrizzlyContainer.<init>(GrizzlyContainer.java:78)
        ... 8 common frames omitted
Caused by: java.lang.IllegalStateException: Failed to init properties of bean class httl.spi.engines.DefaultEngine, cause: Failed to init property value. key: map.converter, value: httl.spi.converters.MultiMapConverter, cause: Failed to init properties of bean class httl.spi.converters.MultiMapConverter, cause: Failed to init property value. key: map.converters, value: httl.spi.converters.StringMapConverter, cause: Failed to init properties of bean class httl.spi.converters.StringMapConverter, cause: Failed to init property value. key: codecs, value: httl.spi.codecs.JsonCodec, cause: Failed to init properties of bean class httl.spi.codecs.JsonCodec, cause: Failed to init property value. key: compiler, value: httl.spi.compilers.AdaptiveCompiler, cause: Failed to init properties of bean class httl.spi.compilers.AdaptiveCompiler, cause: Can not get system java compiler. Please run with JDK (NOT JVM), or configure the httl.properties: compiler=httl.spi.compilers.JavassistCompiler, and add javassist.jar.
        at httl.util.BeanFactory.injectInstance(BeanFactory.java:255)
        at httl.util.BeanFactory.getInstance(BeanFactory.java:275)
        ... 28 common frames omitted
Caused by: java.lang.IllegalStateException: Failed to init property value. key: map.converter, value: httl.spi.converters.MultiMapConverter, cause: Failed to init properties of bean class httl.spi.converters.MultiMapConverter, cause: Failed to init property value. key: map.converters, value: httl.spi.converters.StringMapConverter, cause: Failed to init properties of bean class httl.spi.converters.StringMapConverter, cause: Failed to init property value. key: codecs, value: httl.spi.codecs.JsonCodec, cause: Failed to init properties of bean class httl.spi.codecs.JsonCodec, cause: Failed to init property value. key: compiler, value: httl.spi.compilers.AdaptiveCompiler, cause: Failed to init properties of bean class httl.spi.compilers.AdaptiveCompiler, cause: Can not get system java compiler. Please run with JDK (NOT JVM), or configure the httl.properties: compiler=httl.spi.compilers.JavassistCompiler, and add javassist.jar.
        at httl.util.BeanFactory.getInstance(BeanFactory.java:323)
        at httl.util.BeanFactory.parseValue(BeanFactory.java:349)
        at httl.util.BeanFactory.injectInstance(BeanFactory.java:219)
        ... 29 common frames omitted
Caused by: java.lang.IllegalStateException: Failed to init properties of bean class httl.spi.converters.MultiMapConverter, cause: Failed to init property value. key: map.converters, value: httl.spi.converters.StringMapConverter, cause: Failed to init properties of bean class httl.spi.converters.StringMapConverter, cause: Failed to init property value. key: codecs, value: httl.spi.codecs.JsonCodec, cause: Failed to init properties of bean class httl.spi.codecs.JsonCodec, cause: Failed to init property value. key: compiler, value: httl.spi.compilers.AdaptiveCompiler, cause: Failed to init properties of bean class httl.spi.compilers.AdaptiveCompiler, cause: Can not get system java compiler. Please run with JDK (NOT JVM), or configure the httl.properties: compiler=httl.spi.compilers.JavassistCompiler, and add javassist.jar.
        at httl.util.BeanFactory.injectInstance(BeanFactory.java:255)
        at httl.util.BeanFactory.getInstance(BeanFactory.java:275)
        ... 31 common frames omitted
Caused by: java.lang.IllegalStateException: Failed to init property value. key: map.converters, value: httl.spi.converters.StringMapConverter, cause: Failed to init properties of bean class httl.spi.converters.StringMapConverter, cause: Failed to init property value. key: codecs, value: httl.spi.codecs.JsonCodec, cause: Failed to init properties of bean class httl.spi.codecs.JsonCodec, cause: Failed to init property value. key: compiler, value: httl.spi.compilers.AdaptiveCompiler, cause: Failed to init properties of bean class httl.spi.compilers.AdaptiveCompiler, cause: Can not get system java compiler. Please run with JDK (NOT JVM), or configure the httl.properties: compiler=httl.spi.compilers.JavassistCompiler, and add javassist.jar.
        at httl.util.BeanFactory.getInstance(BeanFactory.java:323)
        at httl.util.BeanFactory.parseValue(BeanFactory.java:349)
        at httl.util.BeanFactory.injectInstance(BeanFactory.java:198)
        ... 32 common frames omitted
Caused by: java.lang.IllegalStateException: Failed to init properties of bean class httl.spi.converters.StringMapConverter, cause: Failed to init property value. key: codecs, value: httl.spi.codecs.JsonCodec, cause: Failed to init properties of bean class httl.spi.codecs.JsonCodec, cause: Failed to init property value. key: compiler, value: httl.spi.compilers.AdaptiveCompiler, cause: Failed to init properties of bean class httl.spi.compilers.AdaptiveCompiler, cause: Can not get system java compiler. Please run with JDK (NOT JVM), or configure the httl.properties: compiler=httl.spi.compilers.JavassistCompiler, and add javassist.jar.
        at httl.util.BeanFactory.injectInstance(BeanFactory.java:255)
        at httl.util.BeanFactory.getInstance(BeanFactory.java:275)
        ... 34 common frames omitted
Caused by: java.lang.IllegalStateException: Failed to init property value. key: codecs, value: httl.spi.codecs.JsonCodec, cause: Failed to init properties of bean class httl.spi.codecs.JsonCodec, cause: Failed to init property value. key: compiler, value: httl.spi.compilers.AdaptiveCompiler, cause: Failed to init properties of bean class httl.spi.compilers.AdaptiveCompiler, cause: Can not get system java compiler. Please run with JDK (NOT JVM), or configure the httl.properties: compiler=httl.spi.compilers.JavassistCompiler, and add javassist.jar.
        at httl.util.BeanFactory.getInstance(BeanFactory.java:323)
        at httl.util.BeanFactory.parseValue(BeanFactory.java:349)
        at httl.util.BeanFactory.injectInstance(BeanFactory.java:198)
        ... 35 common frames omitted
Caused by: java.lang.IllegalStateException: Failed to init properties of bean class httl.spi.codecs.JsonCodec, cause: Failed to init property value. key: compiler, value: httl.spi.compilers.AdaptiveCompiler, cause: Failed to init properties of bean class httl.spi.compilers.AdaptiveCompiler, cause: Can not get system java compiler. Please run with JDK (NOT JVM), or configure the httl.properties: compiler=httl.spi.compilers.JavassistCompiler, and add javassist.jar.
        at httl.util.BeanFactory.injectInstance(BeanFactory.java:255)
        at httl.util.BeanFactory.getInstance(BeanFactory.java:275)
        ... 37 common frames omitted
Caused by: java.lang.IllegalStateException: Failed to init property value. key: compiler, value: httl.spi.compilers.AdaptiveCompiler, cause: Failed to init properties of bean class httl.spi.compilers.AdaptiveCompiler, cause: Can not get system java compiler. Please run with JDK (NOT JVM), or configure the httl.properties: compiler=httl.spi.compilers.JavassistCompiler, and add javassist.jar.
        at httl.util.BeanFactory.getInstance(BeanFactory.java:323)
        at httl.util.BeanFactory.parseValue(BeanFactory.java:349)
        at httl.util.BeanFactory.injectInstance(BeanFactory.java:219)
        ... 38 common frames omitted
Caused by: java.lang.IllegalStateException: Failed to init properties of bean class httl.spi.compilers.AdaptiveCompiler, cause: Can not get system java compiler. Please run with JDK (NOT JVM), or configure the httl.properties: compiler=httl.spi.compilers.JavassistCompiler, and add javassist.jar.
        at httl.util.BeanFactory.injectInstance(BeanFactory.java:255)
        at httl.util.BeanFactory.getInstance(BeanFactory.java:275)
        ... 40 common frames omitted
Caused by: java.lang.IllegalStateException: Can not get system java compiler. Please run with JDK (NOT JVM), or configure the httl.properties: compiler=httl.spi.compilers.JavassistCompiler, and add javassist.jar.
        at httl.spi.compilers.JdkCompiler.<init>(JdkCompiler.java:75)
        at httl.spi.compilers.AdaptiveCompiler.setCompileVersion(AdaptiveCompiler.java:78)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at httl.util.BeanFactory.injectInstance(BeanFactory.java:223)
        ... 41 common frames omitted
22:19:11.143 [main] INFO  ameba.Ameba - 关闭服务器...
22:19:11.143 [main] INFO  ameba.Ameba - 服务器已关闭

根据报错提示,需要指定使用jdk环境运行,而不是使用jre。如果使用jre,需要在httl.properties配置文件中增加配置项:compiler=httl.spi.compilers.JavassistCompiler,并增加相应jar包。

查找资料,在httl作者写的配置中找到了原文:http://httl.github.io/zh/config.html(如下图),因为公司已经将相关代码做了封装,并打上了jar包。所以未验证参照作者所说的方案是否能解决报错。分析此问题,发现运行项目时,指定java运行环境使用JDK就能解决此问题。

 

解决方案:

方案1.在启动项目的配置文件中,设置JDK运行环境路径,将运行环境强制指向JDK。(验证可行)

方案2.修改本地环境变量,由于我本地使用的是JDK1.8,安装时自动增加了一个“C:\ProgramData\Oracle\Java\javapath”的环境,此路径下的java.exe是一个快捷方式,指向了java安装路径下jre的exe执行程序,将此环境变量去掉,重新配置JDK环境变量运行即可。(验证可行)

方案3.参考作者配置文档描述,修改对应配置项,增加相关jar包依赖。(未验证)

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值