Spring Boot Web java.lang.NoSuchFieldError:IS_SECURITY_ENABLED Jetty

时间:2017-04-20 23:07:02

标签: maven jetty embedded-jetty

我收到此错误

  

2017-04-20 22:58:08.573 ERROR 11463 --- [main] o.s.boot.SpringApplication:应用程序启动失败

     

java.lang.NoSuchFieldError:IS_SECURITY_ENABLED       在org.apache.jasper.compiler.JspRuntimeContext。(JspRuntimeContext.java:197)〜[jsp-2.1-6.1.14.jar!/:na]       在org.apache.jasper.servlet.JspServlet.init(JspServlet.java:150)〜[jsp-2.1-6.1.14.jar!/:na]       在org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:640)〜[jetty-servlet-9.3.14.v20161028.jar!/:9.3.14.v20161028]       在org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:419)〜[jetty-servlet-9.3.14.v20161028.jar!/:9.3.14.v20161028]       在org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:892)〜[jetty-servlet-9.3.14.v20161028.jar!/:9.3.14.v20161028]       at org.springframework.boot.context.embedded.jetty.JettyEmbeddedWebAppContext $ JettyEmbeddedServletHandler.deferredInitialize(JettyEmbeddedWebAppContext.java:46)〜[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]       at org.springframework.boot.context.embedded.jetty.JettyEmbeddedWebAppContext.deferredInitialize(JettyEmbeddedWebAppContext.java:36)〜[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]       在org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainer.handleDeferredInitialize(JettyEmbeddedServletContainer.java:186)〜[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]       在org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainer.start(JettyEmbeddedServletContainer.java:121)〜[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]       在org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:297)〜[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]       在org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:145)〜[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]       在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545)〜[spring-context-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]       在org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)〜[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]       在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761)[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]       在org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371)[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]       在org.springframework.boot.SpringApplication.run(SpringApplication.java:315)[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]       在org.springframework.boot.SpringApplication.run(SpringApplication.java:1186)[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]       在org.springframework.boot.SpringApplication.run(SpringApplication.java:1175)[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]       在com.analytics.bi.App.main(App.java:91)[classes!/:0.0.1-SNAPSHOT]       at sun.reflect.NativeMethodAccessorImpl.invoke0(java.base@9-internal/Native Method)〜[na:na]       at sun.reflect.NativeMethodAccessorImpl.invoke(java.base@9-internal/NativeMethodAccessorImpl.java:62)〜[na:na]       at sun.reflect.DelegatingMethodAccessorImpl.invoke(java.base@9-internal/DelegatingMethodAccessorImpl.java:43)~ [na:na]       在java.lang.reflect.Method.invoke(java.base@9-internal/Method.java:531)~ [na:na]       在org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)[bi.jar:0.0.1-SNAPSHOT]       在org.springframework.boot.loader.Launcher.launch(Launcher.java:87)[bi.jar:0.0.1-SNAPSHOT]       在org.springframework.boot.loader.Launcher.launch(Launcher.java:50)[bi.jar:0.0.1-SNAPSHOT]       在org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58)[bi.jar:0.0.1- SNAPSHOT]

我的Pom:

<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>project-lyoko</groupId>
<artifactId>bi</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

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

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
    <!-- The main class to start by executing java -jar -->
    <start-class>com.analytics.bi.App</start-class>
</properties>


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

<dependencies>

    <!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
    <dependency>
        <groupId>com.googlecode.json-simple</groupId>
        <artifactId>json-simple</artifactId>
        <version>1.1</version>
    </dependency>


    <!-- https://mvnrepository.com/artifact/net.sourceforge.nekohtml/nekohtml -->
    <dependency>
        <groupId>net.sourceforge.nekohtml</groupId>
        <artifactId>nekohtml</artifactId>
        <version>1.9.22</version>
    </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>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
    </dependency>



    <!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>4.3.3.RELEASE</version>
    </dependency>

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


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


    <!-- https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc -->
    <dependency>
        <groupId>org.xerial</groupId>
        <artifactId>sqlite-jdbc</artifactId>
        <version>3.8.11.2</version>
    </dependency>

    <dependency>
        <groupId>org.quartz-scheduler</groupId>
        <artifactId>quartz</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.quartz-scheduler</groupId>
        <artifactId>quartz-jobs</artifactId>
        <version>2.2.1</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/commons-dbcp/commons-dbcp -->
    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>1.4</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.4</version>
    </dependency>



    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.amazon.redshift</groupId>
        <artifactId>redshift-jdbc42</artifactId>
        <version>1.2.1.1001</version>
    </dependency>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-core</artifactId>
        <version>1.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jetty</artifactId>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.7.4</version>
        <exclusions>
            <exclusion>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-core</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-annotations</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.7.4</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>2.7.4</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.4</version>
    </dependency>
    <dependency>
        <groupId>org.jgroups</groupId>
        <artifactId>jgroups</artifactId>
        <version>3.6.9.Final</version>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>6.0.5</version>
    </dependency>

</dependencies>

<repositories>

    <repository>
        <id>redshift</id>
        <url>http://redshift-maven-repository.s3-website-us-east-1.amazonaws.com/release</url>
    </repository>
</repositories>

<build>
    <!-- <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources> -->
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <addResources>false</addResources>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <!-- Maven Shade Plugin -->
        <!--<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> 
            <version>2.3</version> <executions> <execution> <phase>package</phase> <goals> 
            <goal>shade</goal> </goals> <configuration> <minimizeJar>false</minimizeJar> 
            <createDependencyReducedPom>true</createDependencyReducedPom> </configuration> 
            </execution> </executions> </plugin> -->
    </plugins>
</build>

我使用的是spring-boot-embedded-jetty。 我可以在我的本地运行应用程序但是当我mvn包并且我在远程实例(ec2)上运行它时它会给我这个错误。

我已经阅读了很多关于jar问题的评论,并且无法理解这意味着什么。

1 个答案:

答案 0 :(得分:1)

你有错误的jsp实现类。

jsp-2.1-6.1.14.jar对Jetty 9.3.x无效

请改用它......

<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>apache-jsp</artifactId>
    <version>9.3.14.v20161028</version> <!-- same version as jetty itself -->
</dependency>

找出你从jsp-2.1-6.1.14.jar获得6.1.14的位置(可能是一个短暂的依赖)并排除它。

注意:jsp jar中的boolean searchMatrix(int target, int[][] mat) { int i = 0, j = mat[0].length; while (i < mat.length && j >= 0) { if (mat[i][j] == target) { return true; } else if (mat[i][j] < target) { i++; } else { j--; } } return false; } 暗示你的依赖关系中还有Jetty 6.1.14,必须删除它,但它100%不能与Jetty 9.x向后兼容。如果你出于某种原因仍然需要Jetty 6.x,这可能是一件很难被删除的事情。

Jetty 6.x是Eclipse之前的版本。 Jetty从Jetty 7.x开始迁移到Eclipse Foundation,这种变化对代码库来说非常引人注目。