Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot with Jetty error

I have an web application using Spring Boot and a jetty server. I am making calls through ajax but instead of them getting mapped to my Spring Controller they are resulting in an error.

The error:

2016-06-16 18:55:25.450  WARN 11772 --- [tp1170788511-19] o.eclipse.jetty.servlet.ServletHandler   : Error for /test
java.lang.NoClassDefFoundError: org/eclipse/jetty/http/HttpMethod

and:

2016-06-16 18:55:25.451  WARN 11772 --- [tp1170788511-19] o.e.jetty.server.AbstractHttpConnection  : /test
java.lang.NoClassDefFoundError: org/eclipse/jetty/http/HttpMethod

The Ajax:

 $.ajax({
    url: "/test",
    type: "POST",
    async: false,,
    success: function (response) {
    ...
    }

The Controller:

@Controller
public class LoginController {

@RequestMapping(value="/test", method=RequestMethod.POST)
public String countingForm(Model model) {
    System.out.println("test");
    return "test";
}

}

If anyone could shine some light on whats going wrong that would be greatly appreciated.

like image 528
James Avatar asked Mar 06 '26 15:03

James


1 Answers

Did you excluded tomcat from spring-boot-starter-web?

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jetty</artifactId>
    </dependency>
like image 69
Planck Constant Avatar answered Mar 09 '26 05:03

Planck Constant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!