2014-02-23 36 views
0

我在將JSTL作爲JAR執行時工作困難(如果我直接使用類文件,則工作正常)。當執行網站作爲JAR文件時,JSTL導致「ERROR 500絕對URI無法解析」

當我運行mvn包依賴目錄和網站1.0-SNAPSHOT.jar在目標目錄中創建。我曾嘗試用以下兩個命令啓動的網站:

java -Dspring.profiles.active=dev -classpath "/home/tom/workspace/website/target/classes:/home/tom/workspace/website/target/dependency/*" -jar target/website-1.0-SNAPSHOT.jar 

java -Dspring.profiles.active=dev -jar target/website-1.0-SNAPSHOT.jar 

這些都導致以下情況例外,當我試圖訪問的網站(啓動,沒有任何例外自身完成)。

org.apache.jasper.JasperException:/WEB-INF/pages/index.jsp(1,1)/WEB-INF/pages/header.jsp(1,61)PWC6188:絕對URI: http://java.sun.com/jsp/jstl/core不能在web.xml或與該應用程序

現在部署的jar文件,如果我嘗試啓動使用下面的命令(或通過的IntelliJ)一切工作正常的網站來解決。

java -Dspring.profiles.active=dev -classpath "/home/tom/workspace/website/target/classes:/home/tom/workspace/website/target/dependency/*" com.website.server.WebServer 

我可以看到javax.servlet.jsp.jstl-1.2.0.v201105211821.jar在清單中引用(並且是在相關目錄存在),所以我不相信與缺失的依賴有什麼關係(在MANIFEST,依賴目錄和IntelliJ生成的類路徑之間的差異是不確定的,儘管我很累,所以明天將不得不重新訪問這個)。

運行jar文件時是否有其他人遇到過這個問題?或者建議進一步調試。我正在使用Java 7,Jetty 9(嵌入式),Spring MVC 3.2.4,JSTL 1.2和Maven 3.1.0。

我的pom和web.xml如下。

的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/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.website</groupId> 
    <artifactId>website</artifactId> 
    <packaging>jar</packaging> 
    <version>1.0-SNAPSHOT</version> 
    <name>website</name> 
    <url>http://maven.apache.org</url> 
    <repositories> 
     <repository> 
      <id>maven-db-plugin-repo</id> 
      <name>maven db plugin repository</name> 
      <url>http://maven-db-plugin.googlecode.com/svn/maven/repo</url> 
      <layout>default</layout> 
     </repository> 
    </repositories> 
    <dependencies> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.11</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.mockito</groupId> 
      <artifactId>mockito-all</artifactId> 
      <version>1.9.5</version> 
     </dependency> 
     <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-java</artifactId> 
      <version>2.39.0</version> 
     </dependency> 
     <dependency> 
      <groupId>log4j</groupId> 
      <artifactId>log4j</artifactId> 
      <version>1.2.17</version> 
     </dependency> 
     <dependency> 
      <groupId>com.google.collections</groupId> 
      <artifactId>google-collections</artifactId> 
      <version>1.0</version> 
     </dependency> 
     <dependency> 
      <groupId>org.codehaus.jackson</groupId> 
      <artifactId>jackson-mapper-asl</artifactId> 
      <version>1.9.13</version> 
     </dependency> 
     <dependency> 
      <groupId>org.codehaus.jackson</groupId> 
      <artifactId>jackson-core-asl</artifactId> 
      <version>1.9.13</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-core</artifactId> 
      <version>3.2.4.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-jdbc</artifactId> 
      <version>3.2.4.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-web</artifactId> 
      <version>3.2.4.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-webmvc</artifactId> 
      <version>3.2.4.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-core</artifactId> 
      <version>3.1.4.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-web</artifactId> 
      <version>3.1.4.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-config</artifactId> 
      <version>3.1.4.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-taglibs</artifactId> 
      <version>3.1.4.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.eclipse.jetty</groupId> 
      <artifactId>jetty-server</artifactId> 
      <version>9.0.5.v20130815</version> 
     </dependency> 
     <dependency> 
      <groupId>org.eclipse.jetty</groupId> 
      <artifactId>jetty-webapp</artifactId> 
      <version>9.0.5.v20130815</version> 
     </dependency> 
     <dependency> 
      <groupId>org.eclipse.jetty</groupId> 
      <artifactId>jetty-jsp</artifactId> 
      <version>9.0.5.v20130815</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.mail</groupId> 
      <artifactId>mail</artifactId> 
      <version>1.4.7</version> 
     </dependency> 
     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
      <version>5.1.26</version> 
     </dependency> 
     <dependency> 
      <groupId>org.mindrot</groupId> 
      <artifactId>jbcrypt</artifactId> 
      <version>0.3m</version> 
     </dependency> 
     <dependency> 
      <groupId>joda-time</groupId> 
      <artifactId>joda-time</artifactId> 
      <version>2.3</version> 
     </dependency> 
    </dependencies> 
    <build> 
     <plugins> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-jar-plugin</artifactId> 
       <configuration> 
        <archive> 
         <manifest> 
          <addClasspath>true</addClasspath> 
          <mainClass>com.website.server.WebServer</mainClass> 
          <classpathPrefix>dependency/</classpathPrefix> 
         </manifest> 
        </archive> 
       </configuration> 
      </plugin> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-dependency-plugin</artifactId> 
       <executions> 
        <execution> 
         <id>copy-dependencies</id> 
         <phase>package</phase> 
         <goals> 
          <goal>copy-dependencies</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <configuration> 
        <excludes> 
         <exclude>**/*IntegrationTest.java</exclude> 
        </excludes> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-failsafe-plugin</artifactId> 
       <version>2.16</version> 
       <configuration> 
        <includes> 
         <include>**/*IntegrationTest.java</include> 
        </includes> 
       </configuration> 
       <executions> 
        <execution> 
         <id>integration-test</id> 
         <goals> 
          <goal>integration-test</goal> 
         </goals> 
        </execution> 
        <execution> 
         <id>verify</id> 
         <goals> 
          <goal>verify</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>build-helper-maven-plugin</artifactId> 
       <version>1.7</version> 
       <executions> 
        <execution> 
         <id>add-test-source</id> 
         <phase>generate-test-sources</phase> 
         <goals> 
          <goal>add-test-source</goal> 
         </goals> 
         <configuration> 
          <sources> 
           <source>src/test/java</source> 
           <source>src/integration/java</source> 
          </sources> 
         </configuration> 
        </execution> 
        <execution> 
         <id>add-test-resource</id> 
         <phase>generate-test-resources</phase> 
         <goals> 
          <goal>add-test-resource</goal> 
         </goals> 
         <configuration> 
          <resources> 
           <resource> 
            <directory>src/integration/resources</directory> 
            <directory>src/test/resources</directory> 
           </resource> 
          </resources> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>org.eclipse.jetty</groupId> 
       <artifactId>jetty-maven-plugin</artifactId> 
       <version>9.0.5.v20130815</version> 
       <configuration> 
        <stopPort>9016</stopPort> 
        <stopKey>jetty-stop</stopKey> 
        <stopWait>10</stopWait> 
       </configuration> 
       <executions> 
        <execution> 
         <id>start-jetty</id> 
         <phase>pre-integration-test</phase> 
         <goals> 
          <goal>start</goal> 
         </goals> 
         <configuration> 
          <scanIntervalSeconds>0</scanIntervalSeconds> 
          <daemon>true</daemon> 
          <systemProperties> 
           <systemProperty> 
            <name>spring.profiles.active</name> 
            <value>dev</value> 
           </systemProperty> 
          </systemProperties> 
         </configuration> 
        </execution> 
        <execution> 
         <id>stop-jetty</id> 
         <phase>post-integration-test</phase> 
         <goals> 
          <goal>stop</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-checkstyle-plugin</artifactId> 
       <version>2.11</version> 
       <configuration> 
        <includeTestSourceDirectory>true</includeTestSourceDirectory> 
        <configLocation>checkstyle.xml</configLocation> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

的web.xml

<web-app xmlns="http://java.sun.com/xml/ns/javaee" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
     version="2.5"> 

    <display-name>website</display-name> 

    <servlet> 
     <servlet-name>mvc-dispatcher</servlet-name> 
     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
     <load-on-startup>1</load-on-startup> 
    </servlet> 

    <servlet-mapping> 
     <servlet-name>mvc-dispatcher</servlet-name> 
     <url-pattern>/</url-pattern> 
    </servlet-mapping> 
    <servlet-mapping> 
     <servlet-name>default</servlet-name> 
     <url-pattern>/css/*</url-pattern> 
    </servlet-mapping> 
    <servlet-mapping> 
     <servlet-name>default</servlet-name> 
     <url-pattern>/js/*</url-pattern> 
    </servlet-mapping> 
    <servlet-mapping> 
     <servlet-name>default</servlet-name> 
     <url-pattern>/img/*</url-pattern> 
    </servlet-mapping> 


    <listener> 
     <listener-class> 
      org.springframework.web.context.ContextLoaderListener 
     </listener-class> 
    </listener> 

    <context-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value> 
      /WEB-INF/mvc-dispatcher-servlet.xml, 
      /WEB-INF/spring-security.xml, 
      /WEB-INF/mail-service.xml 
     </param-value> 
    </context-param> 

    <!-- Spring Security --> 
    <filter> 
     <filter-name>springSecurityFilterChain</filter-name> 
     <filter-class> 
      org.springframework.web.filter.DelegatingFilterProxy 
     </filter-class> 
    </filter> 

    <filter-mapping> 
     <filter-name>springSecurityFilterChain</filter-name> 
     <url-pattern>/*</url-pattern> 
    </filter-mapping> 
</web-app> 
+0

因此暗示...... JSTL不能與嵌入式Jetty一起使用,我必須將我的Web應用程序部署到Jetty環境中嗎? – Tom

+0

你沒有說你正在使用嵌入式碼頭。 –

回答