Search code examples
hibernateclasspathantlrclassnotfoundexception

java.lang.ClassNotFoundException: antlr.ANTLRException but I have antlr-2.7.6 in folder lib of project


I have this in .classpath:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
    ...
    ...
<classpathentry kind="lib" path="lib/hibernate3.jar"/>
<classpathentry kind="lib" path="lib/antlr-2.7.6.jar"/>
    ...
</classpath>

Some .jar added. When I try this:

Query query2 = session.createQuery(sql2);

throw exception in question name:

java.lang.ClassNotFoundException: antlr.ANTLRException

Any idea?

Thanks in advance.

Greetings.


Solution

  • This is related to the Hibernate API. Hibernate 3.0 uses ANTLR (Another Tool for Language Recognition) for processing HSQL queries - if I remember correctly.
    You need to add an additional jar (ANTLR-2.7.5H3.jar) to your classpath.

    Or you can add the below maven dependency to the pom.xml

    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>antlr</artifactId>
    <version>2.7.5H3</version>
    </dependency>