"无法从JAR文件中读取TLD"在heroku上运行spring boot app时

时间:2014-09-12 03:02:13

标签: java spring heroku spring-boot tld

我写了一个在Heroku运行的springboot应用程序。 当我在maven spring-boot:run进行本地运行时,可以正常运行。

但是当我将应用程序部署到Heroku时,页面显示错误:

There was an unexpected error (type=Internal Server Error, status=500).
/WEB-INF/jsp/login.jsp (line: 3, column: 0) /WEB-INF/jsp/common.jsp (line: 3, column: 64) Unable to read TLD "META-INF/spring.tld" from JAR file "jar:file:/app/target/slog-1.0-SNAPSHOT.jar!/lib/spring-webmvc-4.0.7.RELEASE.jar": java.io.IOException: Unable to open root Jar file 'jar:file:/app/target/slog-1.0-SNAPSHOT.jar'

我在本地运行jar,“java -jar target / * .jar”也有同样的错误。

这是我的pom.xml文件:

<?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/xsd/maven-4.0.0.xsd“&GT;     4.0.0

<groupId>ort.stv</groupId>
<artifactId>slog</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Spring Boot Blog System</name>

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

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

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

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-taglibs</artifactId>
    </dependency>


    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <scope>provided</scope>
    </dependency>
    <!-- JSR303 BeanValidator -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
    </dependency>


    <!-- GENERAL UTILS begin -->
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.3.2</version>
    </dependency>

    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>18.0</version>
    </dependency>
    <!-- GENERAL UTILS end -->


    <dependency>
        <groupId>postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.1-901-1.jdbc4</version>
        <classifier />
    </dependency>
    <!--<dependency>-->
        <!--<groupId>org.scala-lang</groupId>-->
        <!--<artifactId>scala-library</artifactId>-->
        <!--<version>2.10.4</version>-->
    <!--</dependency>-->
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

2 个答案:

答案 0 :(得分:2)

Spring Boot中有known limitation,而open issue与使用嵌入式容器的JSP有关。长话短说,它目前不受支持。但是,Spring Boot参考文档链接到他们声称能够正常工作的GitHub example project

答案 1 :(得分:0)

我找到了一种更好的方法将spring boot app部署到heroku。

首先将maven包改为战争。

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <warSourceExcludes>WEB-INF/lib/log4j-${log4j.version}.jar</warSourceExcludes>
            </configuration>
        </plugin>

然后将Procfile更改为 web: java $JAVA_OPTS -jar target/*.war

解决了:D。