[英]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.