我正在使用带有 Jetty 插件的 Maven 3.0.3。我收到以下错误:
java.io.FileNotFoundException:无法打开 ServletContext 资源 [/WEB-INF/applicationContext.xml
我不明白,因为文件存在于target/mywar/WEB-INF/applicationContext.xml
. 我在我的web.xml
:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4">
<display-name>/jx-production-1.0-SNAPSHOT</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>Any ideas what I'm missing? Here is my Jetty plugin definition in my pom.xml …
<profile>
<id>jetty</id>
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.2.2.v20101205</version>
<configuration>
<webAppConfig>
<contextPath>/all-new-jx</contextPath>
<descriptor>target/jx-1.0-SNAPSHOT/WEB-INF/web.xml</descriptor>
</webAppConfig>
<jettyConfig>config/jetty7/jetty.xml</jettyConfig>
<scanIntervalSeconds>10</scanIntervalSeconds>
<contextHandlers>
<contextHandler implementation="org.eclipse.jetty.server.handler.ContextHandler">
<contextPath>/all-new-jx-web</contextPath>
<resourceBase>${project.basedir}/target/web</resourceBase>
<handler implementation="org.eclipse.jetty.server.handler.ResourceHandler" />
</contextHandler>
</contextHandlers>
</configuration>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-rewrite</artifactId>
<version>7.2.2.v20101205</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
这是我得到的长而讨厌的错误:
2011-08-04 14:08:56.677:WARN:: 上下文 omjpJettyWebAppContext{/all-new-jx,file:/Users/davea/Documents/workspace/NissanUSA2/Technology/nna/mycousa/jx/src/ 启动失败main/webapp/},file:/Users/davea/Documents/workspace/NissanUSA2/Technology/nna/mycousa/jx/src/main/webapp/org.springframework.beans.factory.BeanDefinitionStoreException: IOException 解析来自 ServletContext 资源的 XML 文档[/WEB-INF/applicationContext.xml]; 嵌套异常是 java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml] at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:641) at org.eclipse。 jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:228) 在 org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:
谢谢你的建议。