我在RAD 7.5上有一个Web应用程序。我正在使用Maven构建应用程序并在WebSphere 6.1上进行部署。java.io.FileNotFoundException的原因:类路径资源[services.xml]无法打开,因为它不存在
我的web.xml的部分是:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:services.xml</param-value>
</context-param>
这是我引用的services.xml的唯一地方。
我的services.xml是在文件夹
FruitApplication/src/main/resources/services.xml
与Maven构建后,services.xml的是在目标文件夹
target/FruitApplication-1.0.0/WEB-INF/classes/services.xml
在部署下面的路径,我不断得到下面提到错误。但是,在构建应用程序两次时,它会自行消失,然后再次随意再次出现。
这个错误的真正原因是什么? 如何解决这个错误?
我的services.xml的顶部看起来像:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">
是,这里需要改变的东西???
下面是我使用的“行家安装”完整的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>FruitApplication</groupId>
<artifactId>FruitApplication</artifactId>
<packaging>war</packaging>
<version>1.0.0</version>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.1</version>
<configuration>
<archive>
<manifestFile>
src/main/webapp/META-INF/MANIFEST.MF
</manifestFile>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
... dependencies here ...
</dependencies>
</project>
:
<param-value>classpath:services.xml</param-value>
<param-value>classpath:/services.xml</param-value>
<param-value>WEB-INF/classes/services.xml</param-value>
如何我部署:
我通过右键单击服务器并“添加或删除应用程序”从服务器删除应用程序
我正在执行“maven-clean”,然后在应用程序中运行为“maven-install”,并通过右键单击服务器并“添加或删除应用程序”再次添加应用程序。
当您收到该错误时,您是否检查WAR文件以查看文件是否确实存在于您期望的位置? – dbreaux
你如何部署?只要放下Maven在容器中产生的战争?你可以在你的问题中包含你的pom的build-> resources部分吗? – smp7d
您是否在RAD,Websphere或两者中遇到错误?由于@ smp7d建议使用资源阶段并包含将services.xml复制到显式WEB-INF/classes和WEB-INF目录的路径。虽然WEB-INF不在classpath中,但可以尝试使用它。 – Rajendra