0

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.

10
  • Looks like dependency version conflict. Analyze the classpath of the running application and check it against dependencies for Hibernate libraries. Commented Sep 24, 2013 at 11:40
  • Is there another way of setting this param? Because without setting params that works ok. Commented Sep 24, 2013 at 11:41
  • It's more likely about libraries provided with your application server then build script parameters, but you haven't specified what server you are using and how do you build your war/ear so it's hard to guess. Commented Sep 24, 2013 at 11:43
  • @rayman From where myId comes session ? Commented Sep 24, 2013 at 11:44
  • Think about myId as a hardcoded string Commented Sep 24, 2013 at 11:44

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Done. please check question again.
I checked maven dependencies in my project I have Maven: antlr:antlr:2.7.2
hibernate uses 2.7.6. remove the other. btw: are u using struts? if you do not declare it directly very likely struts bring it in.
ok then check who is importing 2.7.2 using mvn dependency:tree and exclude that transitive dependency. If it is not clear I describe the details in the answer above. Let em know
0

This is because the antlr-2.7.2.jar struts2 and Hibernate antlr-2.7.7.jar conflict, as long as the antlr-2.7.2.jar struts2 file can either remove this problem does not occur. You can try.

If such an error is reported: Then you go to your tomcat application under this WEB WEB-INF Under the lib antlr-2.7.2.jar will be deleted. .

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.