Hibernate and antlr.RecognitionException not found

戏子无情 提交于 2021-02-19 08:27:11

问题


I want to learn Hibernate. I found some tutorial, but I have one issue with launching the project. This is my pom:

    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc</artifactId>
        <version>6.2.1.jre8</version>

    </dependency>


    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.3.5.Final</version>
    </dependency>

    <dependency>
        <groupId>antlr</groupId>
        <artifactId>antlr</artifactId>
        <version>2.7.7</version>
    </dependency>

</dependencies>

This is my class:

public static void main(String[] args) {

    Session session = HibernateUtilWapro.getSessionFactory().openSession();

    Query q = session.createQuery("From Employee ");

    List<Employee> resultList = q.list();
    System.out.println("num of employess:" + resultList.size());
    for (Artykul next : resultList) {
        System.out.println("next employee: " + next);
    }
}

I run it in Eclipse Oxygen as a Java application, but I am getting the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: antlr/RecognitionException at org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory.createQueryTranslator(ASTQueryTranslatorFactory.java:57) at org.hibernate.engine.query.spi.HQLQueryPlan.(HQLQueryPlan.java:124) at org.hibernate.engine.query.spi.HQLQueryPlan.(HQLQueryPlan.java:88) at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:190) at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301) at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236) at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1800)

What dependency do it need? Thanks a lot for help


回答1:


You can try to add the following dependency. It solved my issue.

<dependency>
 <groupId>org.antlr</groupId>
 <artifactId>antlr-complete</artifactId>
 <version>3.5.2</version>
</dependency>   


来源:https://stackoverflow.com/questions/46433222/hibernate-and-antlr-recognitionexception-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!