Kelzama
Kelzama

Reputation: 107

CXF- FileNotFoundException with Maven and Tomcat 7

I try to get a web-app running within Tomcat 7. I'm using Maven and with the jetty-Plugin everything works fine. When building the war and deploying it to Tomcat7, I get a FileNotFoundException for the Keystore-File.

Where do I have to put the File and what path do I have to use in cxfClient.xml?

pom.xml Snippet:

            <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>

Line from the Logfile:

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)

I tried src/main/resources, src/main/webapp with different paths in the cxfClient, but always get the FileNotFoundException.

Thanks in advance

Upvotes: 1

Views: 2311

Answers (1)

Balint Bako
Balint Bako

Reputation: 2560

Keystores (as identified by the sec:keyStore element above) can be identified via any one of three ways: via a file, resource, or url attribute. File locations are either an absolute path or relative to the working directory, the resource attribute is relative to the classpath, and URLs must be a valid URL such as "http://..." "file:///...", etc. Only one attribute of "url", "file", or "resource" is allowed.

Source: http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html

Upvotes: 1

Related Questions