无法初始化GraphQL:ANTLR工具运行时版本错误

huangapple go评论81阅读模式
英文:

Can't initialize GraphQL: wrong ANTLR Tool runtime version

问题

我的应用在尝试初始化GraphQL时出现了第一个查询失败,并显示以下错误:

>ANTLR工具版本4.7.2用于代码生成,与当前运行时版本4.5.1不匹配

我在项目中并未显式使用此库,我尝试将更新版本添加到pom中,但没有任何变化。
原始问题:<https://github.com/graphql-java-kickstart/graphql-java-servlet/issues/241>

完整的堆栈跟踪:

ANTLR工具版本4.7.2用于代码生成,与当前运行时版本4.5.1不匹配ANTLR运行时版本4.7.2用于解析器编译,与当前运行时版本4.5.1不匹配2020年4月6日下午4:54:41,org.apache.catalina.core.ApplicationContext日志
严重:StandardWrapper.Throwable
java.lang.ExceptionInInitializerError
at graphql.parser.Parser.parseDocument(Parser.java:57)
at graphql.parser.Parser.parseDocument(Parser.java:39)
at graphql.kickstart.tools.SchemaParserBuilder.parseDocuments(SchemaParserBuilder.kt:181)
at graphql.kickstart.tools.SchemaParserBuilder.parseDefinitions(SchemaParserBuilder.kt:169)
at graphql.kickstart.tools.SchemaParserBuilder.scan(SchemaParserBuilder.kt:162)
at graphql.kickstart.tools.SchemaParserBuilder.build(SchemaParserBuilder.kt:207)
at it.cims30.core.api.graphql.GraphQLEndpoint.createSchema(GraphQLEndpoint.java:23)
at it.cims30.core.api.graphql.GraphQLEndpoint.getConfiguration(GraphQLEndpoint.java:17)
at graphql.kickstart.servlet.AbstractGraphQLHttpServlet.init(AbstractGraphQLHttpServlet.java:85)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1124)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1079)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:761)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:133)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:611)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:407)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2300)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:830)
由于:java.lang.UnsupportedOperationException: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; 无法使用UUID 59627784-3be5-417a-b9eb-8131a7286089反序列化ATN(预期为aadb8d7e-aeef-4415-ad2b-8204d6cf042e或遗留UUID)。
at org.antlr.v4.runtime.atn.ATNDeserializer.deserialize(ATNDeserializer.java:153)
at graphql.parser.antlr.GraphqlLexer.&lt;clinit&gt;(GraphqlLexer.java:276)
... 30 more
由于:java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; 无法使用UUID 59627784-3be5-417a-b9eb-8131a7286089反序列化ATN(预期为aadb8d7e-aeef-4415-ad2b-8204d6cf042e或遗留UUID)。
... 32 more
2020年4月6日下午4:54:41,org.apache.catalina.core.StandardWrapperValve调用
严重:servlet [it.cims30.core.api.graphql.GraphQLEndpoint]的分配异常
java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; 无法使用UUID 59627784-3be5-417a-b9eb-8131a7286089反序列化ATN(预期为aadb8d7e-aeef-4415-ad2b-8204d6cf042e或遗留UUID)。
at org.antlr.v4.runtime.atn.ATNDeserializer.deserialize(ATNDeserializer.java:153)
at graphql.parser.antlr.GraphqlLexer.&lt;clinit&gt;(GraphqlLexer.java:276)
at graphql.parser.Parser.parseDocument(Parser.java:57)
at graphql.parser.Parser.parseDocument(Parser.java:39)
at graphql.kickstart.tools.SchemaParserBuilder.parseDocuments(SchemaParserBuilder.kt:181)
at graphql.kickstart.tools.SchemaParserBuilder.parseDefinitions(SchemaParserBuilder.kt:169)
at graphql.kickstart.tools.SchemaParserBuilder.scan(SchemaParserBuilder.kt:162)
at graphql.kickstart.tools.SchemaParserBuilder.build(SchemaParserBuilder.kt:207)
at it.cims30.core.api.graphql.GraphQLEndpoint.createSchema(GraphQLEndpoint.java:23)
at it.cims30.core.api.graphql.GraphQLEndpoint.getConfiguration(GraphQLEndpoint.java:17)
at graphql.kickstart.servlet.AbstractGraphQLHttpServlet.init(AbstractGraphQLHttpServlet.java:85)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1124)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1079)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:761)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:133)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:611)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve
<details>
<summary>英文:</summary>
My application fails at the first query trying to initialize GraphQL with this error:
&gt;ANTLR Tool version 4.7.2 used for code generation does not match the current runtime version 4.5.1
I don&#39;t explicitely use this library in my project, I tried to add a newer version to the pom nothing changed.
Original issue: &lt;https://github.com/graphql-java-kickstart/graphql-java-servlet/issues/241&gt;
Full stack trace:
```log
ANTLR Tool version 4.7.2 used for code generation does not match the current runtime version 4.5.1ANTLR Runtime version 4.7.2 used for parser compilation does not match the current runtime version 4.5.1Apr 06, 2020 4:54:41 PM org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
java.lang.ExceptionInInitializerError
at graphql.parser.Parser.parseDocument(Parser.java:57)
at graphql.parser.Parser.parseDocument(Parser.java:39)
at graphql.kickstart.tools.SchemaParserBuilder.parseDocuments(SchemaParserBuilder.kt:181)
at graphql.kickstart.tools.SchemaParserBuilder.parseDefinitions(SchemaParserBuilder.kt:169)
at graphql.kickstart.tools.SchemaParserBuilder.scan(SchemaParserBuilder.kt:162)
at graphql.kickstart.tools.SchemaParserBuilder.build(SchemaParserBuilder.kt:207)
at it.cims30.core.api.graphql.GraphQLEndpoint.createSchema(GraphQLEndpoint.java:23)
at it.cims30.core.api.graphql.GraphQLEndpoint.getConfiguration(GraphQLEndpoint.java:17)
at graphql.kickstart.servlet.AbstractGraphQLHttpServlet.init(AbstractGraphQLHttpServlet.java:85)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1124)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1079)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:761)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:133)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:611)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:407)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2300)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:830)
Caused by: java.lang.UnsupportedOperationException: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with UUID 59627784-3be5-417a-b9eb-8131a7286089 (expected aadb8d7e-aeef-4415-ad2b-8204d6cf042e or a legacy UUID).
at org.antlr.v4.runtime.atn.ATNDeserializer.deserialize(ATNDeserializer.java:153)
at graphql.parser.antlr.GraphqlLexer.&lt;clinit&gt;(GraphqlLexer.java:276)
... 30 more
Caused by: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with UUID 59627784-3be5-417a-b9eb-8131a7286089 (expected aadb8d7e-aeef-4415-ad2b-8204d6cf042e or a legacy UUID).
... 32 more
Apr 06, 2020 4:54:41 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet [it.cims30.core.api.graphql.GraphQLEndpoint]
java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with UUID 59627784-3be5-417a-b9eb-8131a7286089 (expected aadb8d7e-aeef-4415-ad2b-8204d6cf042e or a legacy UUID).
at org.antlr.v4.runtime.atn.ATNDeserializer.deserialize(ATNDeserializer.java:153)
at graphql.parser.antlr.GraphqlLexer.&lt;clinit&gt;(GraphqlLexer.java:276)
at graphql.parser.Parser.parseDocument(Parser.java:57)
at graphql.parser.Parser.parseDocument(Parser.java:39)
at graphql.kickstart.tools.SchemaParserBuilder.parseDocuments(SchemaParserBuilder.kt:181)
at graphql.kickstart.tools.SchemaParserBuilder.parseDefinitions(SchemaParserBuilder.kt:169)
at graphql.kickstart.tools.SchemaParserBuilder.scan(SchemaParserBuilder.kt:162)
at graphql.kickstart.tools.SchemaParserBuilder.build(SchemaParserBuilder.kt:207)
at it.cims30.core.api.graphql.GraphQLEndpoint.createSchema(GraphQLEndpoint.java:23)
at it.cims30.core.api.graphql.GraphQLEndpoint.getConfiguration(GraphQLEndpoint.java:17)
at graphql.kickstart.servlet.AbstractGraphQLHttpServlet.init(AbstractGraphQLHttpServlet.java:85)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1124)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1079)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:761)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:133)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:611)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:407)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2300)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:830)

答案1

得分: 1

现有的解决方案如下(来自已关闭的问题):

> 将 graphql-java-tools 回滚到 5.7.1 版本,将 graphql-java 回滚到 13.0 版本。

当前版本与 graphql-java 14.0 不兼容。
我还需要在我的 pom 中添加以下内容:

&lt;dependency&gt;
  &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
  &lt;artifactId&gt;commons-lang3&lt;/artifactId&gt;
  &lt;version&gt;3.10&lt;/version&gt;
&lt;/dependency&gt;

我回滚到的 graphql-java-tools 使用了一个不同版本的 commons-lang3,如果 JDK 版本太新,会导致 NullPointerException(我正在使用 13 版本)。

英文:

The current solution is (from the closed issue):

>Revert graphql-java-tools to 5.7.1 and graphql-java to 13.0

The current version isn't compatible with graphql-java 14.0.
I also needed to add to my pom this:

&lt;dependency&gt;
  &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
  &lt;artifactId&gt;commons-lang3&lt;/artifactId&gt;
  &lt;version&gt;3.10&lt;/version&gt;
&lt;/dependency&gt;

The graphql-java-tools I reverted to used a different version of commons-lang3 that gave a NullPointerException if the JDK version was too new (I'm using 13).

huangapple
  • 本文由 发表于 2020年4月6日 23:23:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/61063188.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定