Open evan-zhangbo opened 2 years ago
You have to regenerate lexer or parser with the new ANTLR 4.10.1.
same problem, any ideas?
same problem, any ideas?
regenerate it with the new version or force the old (e.g. 4.9.3) version with (e.g. gradle):
runtimeOnly("org.antlr:antlr4-runtime") {
version {
strictly '4.9.3'
}
}
I have the same issue, How can I fix this on Maven POM. I have tried several options to exclude antlr and nothing helped. I need to pin antlr-runtime in my hibernate-core. Please let me know how to do that. Thanks!
Caused by: java.lang.UnsupportedOperationException: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with version 4 (expected 3).
at org.antlr.v4.runtime.atn.ATNDeserializer.deserialize(ATNDeserializer.java:146)
at org.hibernate.grammars.hql.HqlLexer.
Hi, I had the same issue. I upgraded to 4.10. Then I deleted my generated code and seems to works so far.
Using antlr4-maven-plugin (version 4.10+) and it generates _serializedATN witch cannot be deserialized
While migrating JDK 8 to JDK17 , Spring boot 2.x to SpringBoot 3.x , Spring framework from 5 to 6.. I got this issue in my local.
Caused by: java.lang.UnsupportedOperationException: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with version 4 (expected 3).
at org.antlr.v4.runtime.atn.ATNDeserializer.deserialize(ATNDeserializer.java:187)
at org.hibernate.grammars.hql.HqlLexer.
Could you please help me with this.. This is the dependency i am using currently ..along with Latest spring boot ,hibernate, jpa jars .
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.9.2</version>
</dependency>
While migrating JDK 8 to JDK17 , Spring boot 2.x to SpringBoot 3.x , Spring framework from 5 to 6.. I got this issue in my local.
Caused by: java.lang.UnsupportedOperationException: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with version 4 (expected 3). at org.antlr.v4.runtime.atn.ATNDeserializer.deserialize(ATNDeserializer.java:187) at org.hibernate.grammars.hql.HqlLexer.(HqlLexer.java:1412) ... 64 more Caused by: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with version 4 (expected 3). ... 66 more
Could you please help me with this.. This is the dependency i am using currently ..along with Latest spring boot ,hibernate, jpa jars . org.antlr antlr4 4.9.2 org.antlr antlr4-runtime 4.9.2
Solution for my issue: I could able to resolve by commenting antlr jar from my pom.xml..As i had already generated parser and lexer class with my jdk 8 version part of my project..now when i am upgrading spring boot2.x to spring boot 3.x this issue was coming because i had excluded hibernate antlr compile time jar that also came with spring jpa. Hibernate required its own antlr jar at run time to parse the query etc, i had excluded that runtime antlr jar , that was giving the issue, so don't exclude antlr from hibernate side. This solves my issue.
Solution for my issue: I could able to resolve by commenting antlr jar from my pom.xml..As i had already generated parser and lexer class with my jdk 8 version part of my project..now when i am upgrading spring boot2.x to spring boot 3.x this issue was coming because i had excluded hibernate antlr compile time jar that also came with spring jpa. Hibernate required its own antlr jar at run time to parse the query etc, i had excluded that runtime antlr jar , that was giving the issue, so don't exclude antlr from hibernate side. This solves my issue.
I don't have antlr4 in my pom.xml but still having issues. I have upgraded java 8 to java 17 and spring boot to 3.x
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.UnsupportedOperationException: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with version 3 (expected 4).
by: java.lang.ExceptionInInitializerError: Exception java.lang.UnsupportedOperationException: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with
Hey @bndeshpande, Is this issue open for you? You comment starts with "Solution for my issue:", could you please let me know if you are facing this issue as well. As the title doesn't match with the description. I am assuming you still have this issue, please correct my asssumption.
still an issue, there's not a workaround atm
Doesn't parser regeneration with new generator help?
not in my case, in my pom.xml i don't have any dependency linked to antlr, if i add it manually it changes only the runtime version of antlr, the version used in "code generation" is still the same... mvn clean install says version 4.13.1 is being used, but when i run the unit tests it says v4.10.1 for code generation, and v4.13.1 for runtime...
+1 Spring Boot 3.5.1 + mssql-jdbc-12.4.1.jre11.
at com.microsoft.sqlserver.jdbc.SQLServerFMTQuery.<init>(SQLServerFMTQuery.java:100) ~[mssql-jdbc-12.4.1.jre11.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerParameterMetaData.<init>(SQLServerParameterMetaData.java:357) ~[mssql-jdbc-12.4.1.jre11.jar:na]
...
Caused by: java.lang.UnsupportedOperationException: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with version 3 (expected 4).
at org.antlr.v4.runtime.atn.ATNDeserializer.deserialize(ATNDeserializer.java:56) ~[antlr4-runtime-4.10.1.jar:4.10.1]
at org.antlr.v4.runtime.atn.ATNDeserializer.deserialize(ATNDeserializer.java:48) ~[antlr4-runtime-4.10.1.jar:4.10.1]
at com.microsoft.sqlserver.jdbc.SQLServerLexer.<clinit>(SQLServerLexer.java:425) ~[mssql-jdbc-12.4.1.jre11.jar:na]
@KvanTTT I guess it's not a massive amount of work to support both v3 and v4 deserialization (like we do in C#, js and python) ? Is that something you could consider in order to reduce the "noise" ?
It's a massive amount of work because it requires changing code of all targets and writing tests. Moreover, if it's supported, both versions (v3 and v4) should be maintained in future. It's a lot of effort without big benefit.
Again. You need to fix your maven plugin. IT generates ATN in old version. I can test it again with new antlr version, but my last tests (reported here) shows it clearly. We use maven plug-in to generate classes based on grammar during the each build. Classes are not stored in git. We got runtime exception with the same version of antlr
pon., 23 paź 2023, 23:23 użytkownik Ivan Kochurkin @.***> napisał:
It's a massive amount of work because it requires changing code of all targets and writing tests. Moreover, if it's supported, both versions (v3 and v4) should be maintained in future. It's a lot of effort without big benefit.
— Reply to this email directly, view it on GitHub https://github.com/antlr/antlr4/issues/3895#issuecomment-1776043056, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABO7WDCNGTW6JRUENWGW4ATYA3N3NAVCNFSM6AAAAAAQSWXXYOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZWGA2DGMBVGY . You are receiving this because you commented.Message ID: @.***>
The plug-in version needs to match the runtime version. Have you tried 4.13.1 ?
Hi, I have the same issue. May I know if anyone has any solution?
I stumbled upon this problem when I migrated our project from Spring Boot 2.7 -> Spring Boot 3.0.
We didn't have any direct antlr dependencies in our pom.xml
.
What helped me after reading this comment was to add this dependency to our pom.xml
:
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.9.3</version>
</dependency>
Maybe it will help someone else too.
Details: