简体   繁体   English

升级到 Java 17 throws java.lang.RuntimeException: Error creating extended parser class: Could not determine whether class has already been loaded

[英]Upgrade to Java 17 throws java.lang.RuntimeException: Error creating extended parser class: Could not determine whether class has already been loaded

I am using jtwig lib and the code was working fine but when we upgraded to Java 17, I am getting the below mention runtime exception.我正在使用 jtwig lib 并且代码工作正常但是当我们升级到 Java 17 时,我收到下面提到的运行时异常。

Below is the method and throws RuntimeException while calling template.render()下面是调用 template.render() 时抛出 RuntimeException 的方法

 String renderDescription(String templatePath,String userId, String caseId) {

       JtwigTemplate template = 
       JtwigTemplate.classpathTemplate(templatePath);

       JtwigModel model = JtwigModel.newModel()
                         .with("userId", userId)
                        .with("caseId", caseId)
                        .with("statusPageUrlTemplate", 
                         config.getStatusPageUrlTemplate());

       return template.render(model);
 }
java.lang.RuntimeException: Error creating extended parser class: Could not determine whether class 'org.jtwig.parser.parboiled.base.BooleanParser$$parboiled' has already been loaded
    at org.parboiled.Parboiled.createParser(Parboiled.java:58)
    at org.jtwig.parser.parboiled.ParserContext.instance(ParserContext.java:31)
    at org.jtwig.parser.parboiled.ParboiledJtwigParser.parse(ParboiledJtwigParser.java:37)
    at org.jtwig.parser.cache.InMemoryConcurrentPersistentTemplateCache.get(InMemoryConcurrentPersistentTemplateCache.java:39)
    at org.jtwig.parser.CachedJtwigParser.parse(CachedJtwigParser.java:19)
    at org.jtwig.JtwigTemplate.render(JtwigTemplate.java:98)
    at org.jtwig.JtwigTemplate.render(JtwigTemplate.java:74)

I was facing a similar issue after upgrading JVM version, and I found that adding this environment variable helped:升级 JVM 版本后我遇到了类似的问题,我发现添加这个环境变量有帮助:

JDK_JAVA_OPTIONS=--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED

I believe it has something to do with stricter default limits on reflection when trying to inspect built-in classes.我相信这与在尝试检查内置类时对反射的更严格的默认限制有关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在jmeter:java.lang.RuntimeException中:找不到TestPlan类 - in jmeter:java.lang.RuntimeException: Could not find the TestPlan class Android:将主类扩展到Actionbar Activity时发生错误(java.lang.RuntimeException:无法启动活动ComponentInfo) - Android: error (java.lang.RuntimeException: Unable to start activity ComponentInfo) occured when main class is extended to Actionbar Activity 可理解的错误java.lang.RuntimeException:无法实例化活动ComponentInfo且未找到类 - Understandable error java.lang.RuntimeException: Unable to instantiate activity ComponentInfo & Didn't find class java.lang.RuntimeException:无法启动活动错误膨胀类<unknown> - java.lang.RuntimeException: Unable to start activity Error inflating class <unknown> Android 应用程序 java.lang.RuntimeException 错误 - Android app java.lang.RuntimeException error android-java.lang.RuntimeException - android - java.lang.RuntimeException NotifyBuilder上的java.lang.RuntimeException - java.lang.RuntimeException on NotifyBuilder 数据库中的java.lang.RuntimeException - java.lang.RuntimeException in database java.lang.RuntimeException:不支持的文字类型类org.joda.time.DateTime - java.lang.RuntimeException: Unsupported literal type class org.joda.time.DateTime java.lang.RuntimeException:无法初始化Visualizer引擎,错误:-4 - java.lang.RuntimeException: Cannot initialize Visualizer engine, error: -4
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM