问题
I'm trying to integrate Spring Data within our Vaadin project. So I tried running the following sample code which uses the same technologies:
https://github.com/henrikerola/vaadin-spring-boot-todo
The only thing I changed is that I added jetty as we need to use it for our project.
Unfortunately, after jetty:run
I'm getting the following exception:
Exception in thread "main" java.util.ServiceConfigurationError:
org.apache.juli.logging.Log: Provider org.eclipse.jetty.apache.jsp.JuliLog not a subtype
My pom.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>...
<modelVersion>4.0.0</modelVersion>
<groupId>org.test</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>demo.DemoApplication</start-class>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
<version>1.0.0.beta2</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>7.4.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.10.v20150310</version>
</plugin>
</plugins>
</build>
回答1:
I haven't had the chance to dig up the actual reason for this, but I suspect a classpath issue between jetty & tomcat which is preferred by spring-boot.
- Anyhow, if you plan on further using spring-boot which is probably easiest, the spring-boot documentation offers an example of replacing tomcat with jetty, and it's simple as adding the following to your pom:
<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>
Also, instead of running mvn jetty-run
you'd probably want to run the demo.DemoApplication
so it can properly discover the spring configuration and initialize the context.
- If you plan on avoiding spring-boot, then remove the parent definition as well as the other boot dependencies and plugins. Also, remember to manually setup the application to initialize the spring context on starup.
回答2:
For what it's worth after two years: The error message tells you that org.eclipse.jetty.apache.jsp.JuliLog
is not a subclass/implementation of org.apache.juli.logging.Log
.
This happens if there are multiple jars containing the same class (org.apache.juli.logging.Log
in this case I suppose) and multiple classloaders providing the same class (that are regarded as different in instance-of
and isAssignableFrom-checks
).
Check the jars that were downloaded for the occurrence of org.apache.juli.logging.Log.class
and see where they are coming from. After adjusting that in your pom, you should be able to get rid off the error.
来源:https://stackoverflow.com/questions/30143618/vaadin-jetty-spring-data-maven-exception