Jonathan Small
Jonathan Small

Reputation: 1079

NoClassDefFoundError generated from Spring Tool Suite wizard

I was instructed to make use of the STS (Spring Tool Suite) for a java course I am enrolled in. I have downloaded STS version 3.9.3 with platform Eclipse Oxygen 3 (4.7.3).

When I start up STS, I do the following:

  1. Click File -> New -> Import Spring Getting Started Content

  2. I do a search on rest

  3. I select rest services with a code set of initial and complete

  4. Once the application is generated, I navigate to the gs-rest-service-complete/src/main/java/hello subdirectory and I see Application.java, Greeting.java, and GreetingController.java.

  5. I click on the green run button and I get the following output in the console:

    Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/util/Assert
    at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:263)
    at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:247)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234)
    at hello.Application.main(Application.java:10)
    Caused by: java.lang.ClassNotFoundException: org.springframework.util.Assert
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 5 more
    

I did not make any modifications to any configuration settings or any code. I am brand new to this application and java programming. Why would I be getting this error? How do I resolve it?

Thank you. Jonathan

Upvotes: 0

Views: 1703

Answers (1)

Sounak Saha
Sounak Saha

Reputation: 933

As you are using Maven build type, you need to do this steps in your project.

  • Right click on gs-rest-service-complete project >> Run As >> Maven Build/ Maven install
    This steps will take few minutes to download all spring boot related jar. Make sure that maven build/install is successful.
  • After maven build successful right click on Application.java >> Run As >> Java Application / Spring Boot App
    Make sure 8080 port no application is running
  • You can test the rest call by 'http://localhost:8080/greeting' URL

Upvotes: 1

Related Questions