3
respostas

Problema com ANTRL

Não consegui resolver este problema, já joguei na net porém sem resultado.

nov. 07, 2022 4:29:16 PM org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation
INFO: HHH000204: Processing PersistenceUnitInfo [name: loja]
nov. 07, 2022 4:29:16 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate ORM core version 6.0.0.Alpha7
nov. 07, 2022 4:29:17 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH10001002: Using built-in connection pool (not intended for production use)
nov. 07, 2022 4:29:17 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001005: Loaded JDBC driver class: com.mysql.cj.jdbc.Driver
nov. 07, 2022 4:29:17 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001012: Connecting with JDBC URL [jdbc:mysql://localhost:3306/loja]
nov. 07, 2022 4:29:17 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001001: Connection properties: {password=****, user=root}
nov. 07, 2022 4:29:17 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001003: Autocommit mode: false
nov. 07, 2022 4:29:17 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections <init>
INFO: HHH10001115: Connection pool size: 20 (min=1)
nov. 07, 2022 4:29:17 PM org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl logSelectedDialect
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
nov. 07, 2022 4:29:17 PM org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection
INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@50448409] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
nov. 07, 2022 4:29:17 PM org.hibernate.engine.transaction.jta.platform.internal.JtaPlatformInitiator initiateService
INFO: HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
800.00
ANTLR Tool version 4.9.1 used for code generation does not match the current runtime version 4.10
ANTLR Runtime version 4.9.1 used for parser compilation does not match the current runtime version 4.10
Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.hibernate.query.hql.internal.HqlParseTreeBuilder.buildHqlLexer(HqlParseTreeBuilder.java:34)
    at org.hibernate.query.hql.internal.StandardHqlTranslator.parseHql(StandardHqlTranslator.java:101)
    at org.hibernate.query.hql.internal.StandardHqlTranslator.translate(StandardHqlTranslator.java:76)
    at org.hibernate.internal.AbstractSharedSessionContract.lambda$createQuery$1(AbstractSharedSessionContract.java:653)
    at org.hibernate.query.internal.QueryInterpretationCacheStandardImpl.resolveHqlInterpretation(QueryInterpretationCacheStandardImpl.java:123)
    at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:651)
    at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:23)
    at br.com.robson.loja.dao.ProdutoDao.buscarTodos(ProdutoDao.java:36)
    at br.com.robson.loja.testes.CadastroDeProduto.main(CadastroDeProduto.java:24)
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)
    at org.antlr.v4.runtime.atn.ATNDeserializer.deserialize(ATNDeserializer.java:48)
    at org.hibernate.grammars.hql.HqlLexer.<clinit>(HqlLexer.java:910)
    ... 9 more
Caused by: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with version 3 (expected 4).
    ... 12 more

Pelo o que entendi do erro é que a versão utilizada para criar o programa não condiz com a versão em runtime, mas não sei como mudar. Alguém pode me ajudar?

3 respostas

Oi Robson,

Posta aqui o pom.xml do seu projeto.

Boa tarde Professor, estou com o mesmo problema do Robson, vi que ele não retornou o post mas postarei meu pom.xml aqui se puder me ajudar eu agradeço!

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>br.com.jhonata</groupId>
  <artifactId>loja</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <release>11</release>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>6.1.5.Final</version>
        <type>pom</type>
    </dependency>

<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>6.0.0.Alpha7</version>
            <type>pom</type>    
    </dependency>

<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.31</version>
    </dependency>
</dependencies>  
</project>

Oi Jhonata,

No seu caso o problema é porque a dependência do hibernate está duplicada(são 2 distintas, mas vai dar conflito) e com versões distintas.

Deixa assim as dependências no pom.xml

<dependencies>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>6.0.0.Alpha7</version>
    </dependency>

<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.31</version>
    </dependency>
</dependencies>