-1

Hi I am currently having an error with running tests on my spring application.

The error is:

java.lang.ClassNotFoundException: org/eclipse/jetty/util/FutureCallback

This is my first time using spring and maven so I am quite confused.
I think it is an issue with my pom file, but I am not sure. Here is my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org</groupId>
<artifactId>CountdownCustomer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>CountdownCustomer</name>
<url>http://maven.apache.org</url>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.0.RELEASE</version>
</parent>

<properties>
    <java.version>1.8</java.version>
    <servlet.container.port>10000</servlet.container.port>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jackson-provider</artifactId>
    <version>3.0.12.Final</version>
</dependency>
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jaxrs</artifactId>
    <version>3.0.12.Final</version>
</dependency>
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-client</artifactId>
    <version>3.0.12.Final</version>
</dependency>
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>jaxrs-api</artifactId>
    <version>3.0.12.Final</version>
</dependency>
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-servlet-initializer</artifactId>
    <version>3.0.12.Final</version>
</dependency>
<!-- Hibernate -->
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
</dependency>
<!-- H2 embedded database. -->
<dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
</dependency>
<!-- Spring -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-rest</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-data-jpa</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-test</artifactId>
    <scope>test</scope>
    <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>
<dependency>
    <groupId>com.jayway.jsonpath</groupId>
    <artifactId>json-path</artifactId>
    <scope>test</scope>
</dependency>
<!-- Junit -->
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <scope>test</scope>
</dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <skip>true</skip>
            </configuration>
            <executions>
                <execution>
                    <id>surefire-it</id>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <skip>false</skip>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.1.4.v20140401</version>
            <configuration>
                <httpConnector>
                    <port>${servlet.container.port}</port>
                </httpConnector>
                <webApp>
                    <contextPath>/</contextPath>
                </webApp>
                <scanIntervalSeconds>10</scanIntervalSeconds>
                <stopKey>foo</stopKey>
                <stopPort>9999</stopPort>
                <stopWait>1</stopWait>
            </configuration>
            <executions>
                <execution>
                    <id>start-jetty</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <scanIntervalSeconds>0</scanIntervalSeconds>
                        <daemon>true</daemon>
                    </configuration>
                </execution>
                <execution>
                    <id>stop-jetty</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<repositories>
    <repository>
        <id>spring-releases</id>
        <url>https://repo.spring.io/libs-release</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-releases</id>
        <url>https://repo.spring.io/libs-release</url>
    </pluginRepository>
</pluginRepositories>

Update:

Issue was fixed by changing the jetty version to a more recent one

t77
  • 1
  • 1

3 Answers3

0

You have to add the following dependency to your Project:

<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-util -->
<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-util</artifactId>
    <version>9.3.10.v20160621</version>
</dependency>
Jens
  • 67,715
  • 15
  • 98
  • 113
0

Well, Spring Boot out-of-the-box includes Tomcat as its embedded server, you need to remove that dependency

<exclusions>
    <exclusion>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
    </exclusion>
</exclusions>

and replace it with Jetty

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jetty</artifactId>
</dependency>

Also, you don't need all of those Boot dependencies. spring-boot-starter-data-rest already includes spring-boot-starter-data-jpa and spring-boot-starter-web, you can remove those, too.

rorschach
  • 2,871
  • 1
  • 17
  • 20
  • I made these changes, my application is now running on jetty, but when i run my tests they fail with the same error – t77 Sep 20 '16 at 06:45
  • You also have to make the same changes in the `spring-boot-starter-test` dependency. – rorschach Sep 20 '16 at 06:46
  • I added that exclusion, it still fails on test – t77 Sep 20 '16 at 06:50
  • It's practically impossible to diagnose the problem based on "it still fails". Show us your `.pom` – rorschach Sep 20 '16 at 06:51
  • updated the pom file, i left in spring-boot-starter-data-jpa as without it my application crashes with a different exception – t77 Sep 20 '16 at 06:57
  • It's **impossible** to diagnose the problem based on "it still fails". Show us your `.pom` – rorschach Sep 20 '16 at 06:58
  • oh sorry, .pom not pom.xml, what do you mean by .pom file? – t77 Sep 20 '16 at 07:01
  • I apologize, the dot was accidental. Of course I mean `pom.xml` because that's where all of your dependencies are listed. – rorschach Sep 20 '16 at 07:02
  • oh ok, I have updated my question with my current pom.xml file – t77 Sep 20 '16 at 07:04
  • oh, I guess i dont have one, when you say scope test, do you mean a jetty dependency with scope test? is that not handled by the eclipse.jetty plugin? – t77 Sep 20 '16 at 07:10
0

Make sure that the jar file have the class which you are using. You can open you repository (C:\Users\.m2\repository) navigate to you jar location, open the jar and see. If that jar doesn't have the class,look for some other dependency which has that class and add that in you pom.xml.

Sudha Velan
  • 633
  • 8
  • 24