e-info128
e-info128

Reputation: 4082

Error: java.lang.NoClassDefFoundError: antlr/RecognitionException

I have Spring Boot project with JPA + MySQL + Thymeleaf but the eclipse says the error.

In marven dependencies have found antlr 2.7.7 jar library.

My dependencies in pom.xml:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

antlr is a dependencie for JPA and Hibernate, but the console says:

java.lang.ClassNotFoundException: antlr.RecognitionException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_111]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_111]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_111]
...

I make the model and repository but when call the findAll() function crash the web app.

In the controller:

@Autowired
private CategoryRepository categoryRepository;
...
Iterable<CategoryModel> categories = categoryRepository.findAll();

In the repository:

public interface CategoryRepository extends CrudRepository<CategoryModel, BigInteger>{

    List<CategoryModel> findById(BigInteger id);
}

What happens?

Upvotes: 2

Views: 3023

Answers (1)

e-info128
e-info128

Reputation: 4082

My solution: the local repository is corrupt, from Linux delete the folder ~/.m2/ and reload eclipse.

Upvotes: 4

Related Questions