我尝试在Tomcat 7中运行一个Web应用程序。我使用的是Maven和jetty-Plugin,一切都可以正常工作。在构建战争并将其部署到Tomcat7时,我收到了Keystore文件的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/资源、src/main/webapp,但总是得到FileNotFoundException。
提前谢谢
密钥存储库(由上面的sec: keyStore元素标识)可以通过以下三种方式中的任何一种来标识:通过文件、资源或url属性。文件位置要么是绝对路径,要么是相对于工作目录的路径,资源属性是相对于类路径的,URL必须是有效的URL例如"超文本传输协议://…""file:///…"等。只允许使用"url"、"file"或"资源"的一个属性。
来源:http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html