【发布时间】:2013-06-20 13:13:26
【问题描述】:
我尝试在 Tomcat 7 中运行一个网络应用程序。我正在使用 Maven,并且使用 jetty-Plugin 一切正常。在构建战争并将其部署到 Tomcat7 时,我得到 Keystore-File 的 FileNotFoundException。
在 cxfClient.xml 中我必须将文件放在哪里以及我必须使用什么路径?
pom.xml 片段:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-xjc-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>xsdtojava</goal>
</goals>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<xsdOptions>
<xsdOption>
<xsd>${basedir}/src/main/resources/xsd/template1.xsd</xsd>
<packagename>some.packagename</packagename>
</xsdOption>
</xsdOptions>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.7.3</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<!-- <wsdl>URLTOWSDL</wsdl> -->
<wsdl>${basedir}/src/test/resources/somewsdl.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
cxfClient.xml:
<sec:keyManagers>
<sec:keyStore file="truststore.jks" password="test1234" type="JKS"/>
</sec:keyManagers>
<sec:trustManagers>
<sec:keyStore file="truststore.jks" password="test1234" type="JKS"/>
</sec:trustManagers>
日志文件中的行:
Error creating bean with name 'servicename.http-conduit': Cannot create inner bean '(inner bean)' of type [org.apache.cxf.configuration.jsse.TLSClientParametersConfig] while setting bean property 'tlsClientParameters'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public static java.lang.Object org.apache.cxf.configuration.jsse.TLSClientParametersConfig.createTLSClientParameters(java.lang.String)] threw exception; nested exception is java.lang.RuntimeException: java.io.FileNotFoundException: src\main\resources\truststore.jks (Das System kann den angegebenen Pfad nicht finden)
我在 cxfClient 中尝试了使用不同路径的 src/main/resources、src/main/webapp,但总是得到 FileNotFoundException。
提前致谢
【问题讨论】:
-
默认不需要keystore文件,这是什么keystore文件?堆栈跟踪也不会受到伤害。
-
我看到你更新了问题:) 定义 jks 文件的绝对路径,否则它必须位于类路径的根目录中(
WEB-INF/classes,即src/main/resources)。 cxf-client.xml 通常在META-INF中,所以它可能必须在那个文件夹中,如果它是相对于 xml 的。 -
已经试过了 :( 我已将 cxfClient.xml 和 truststore.jks 放入 src/main/resources。我在 tomcat-Folder 的 WEB-INF/classes 中看到它们。我设置了“ file="src/main/resources/truststore.jks"。但仍然得到异常...
-
现在这是一个问题 :) 如果你把它们放在那里,那么它们将被复制到类路径的根目录,这意味着下面的设置应该可以工作
file="truststore.jks" -
这是我之前的设置(你可以在上面的代码中看到)。我使用
mvn clean tomcat7:deploy进行部署,我在WEB-INF/classes中看到了文件,我得到了异常。当我使用mvn jetty:run时,一切都按预期工作..
标签: java maven tomcat cxf filenotfoundexception