Search code examples
javahibernatehql

HQL return java.lang.NoSuchMethodError


I am trying to set parameter in HQL this way:

 Query query = session.createQuery("from Device d " +
                    "left join fetch d.tradeInOldDevice " +
                    "left join fetch d.tradeInNewDevice " +
                    "left join fetch d.warranty "  +
                    "where d.owningCompany.customerRefId =:customerId ");


              query.setString("customerId", "someHardCodeCustomerId");


            Set<Device> customerDevices= (Set<Device>) query.list();

I am gettig that error:

ספט 24, 2013

2:36:02 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [ServicesServlet] in context with path [] threw exception [Servlet execution threw an exception] with root cause
java.lang.NoSuchMethodError: antlr.collections.AST.getLine()I
    at org.hibernate.hql.ast.HqlSqlWalker.generateNamedParameter(HqlSqlWalker.java:945)

Hibernate dependcies:

 <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.0.1.Final</version>
        </dependency>


<!-- Hibernate -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-c3p0</artifactId>
            <version>3.6.10.Final</version>
        </dependency>

I am running hibernate on tomcat inside Spring container.

I checked maven dependencies in My project I have Maven: antlr:antlr:2.7.2.

What could be wrong here?

thanks.


Solution

  • Library conflict. I think you have another version of antlrXXX.jar loaded in web-inf/lib. This is loaded before the one on which hibernate depends on. Pleasse complete the question with the used hibernate version so that I can reply putting the correct dependency for completness.

    Update: After the comments the conflicting version is 2.7.2. Check who is importing 2.7.2 using mvn dependency:tree and exclude that transitive dependency in the pom.