Reputation: 3946
I am using Spring and Hibernate and i always get this error message:
java.lang.NoSuchMethodError: antlr.collections.AST.getLine()
It happens when i make custom definitions in my repositories:
public interface UserRepository extends JpaRepository<User, Long>
{
@Query("select u from User u where username = ?1")
List<User> findByUsername(String username);
@Query("select u from User u where username = ?1 and password = ?2")
List<User> findByUsernameAndPassword(String username, String password);
}
If i remove the 2 queries then everything works just fine.
I also added antlr as a dependency:
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr</artifactId>
<version>3.5.2</version>
</dependency>
but this was unsuccessful to solve my issue.
Spring: 3.2.3 RELEASE
Hibernate:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.0.1.Final</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>1.2.0.Final</version>
<scope>compile</scope>
</dependency>
Upvotes: 1
Views: 5027
Reputation: 3868
I'm using Spring Boot and this error happened because antlr-2.7.7 used by hibernate-core-4.3.7 was overridden by antlr-2.7.2 used by struts-core-1.3.8.
If someone has this issue in Spring Tool Suite IDE, this is what I did:
Upvotes: 2
Reputation: 170278
The class antlr.collections.AST
is an ANTLR v2 class.
For the record, these are the packages of the ANTLR versions:
antlr...
org.antlr...
org.antlr.v4...
Upvotes: 0