wsdltojava错误:找不到velocity模板文件:org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm

zvokhttg  于 2021-07-06  发布在  Java
关注(0)|答案(2)|浏览(339)

我正在将apachecxf从3.2.14升级到3.3.8,在构建wdsl客户机时遇到以下异常。

[echo] TOTAL_MIB_ISAM_3.1.0.7.txt
     [java] Nov 19, 2020 4:26:42 PM org.apache.velocity.runtime.log.JdkLogChute log
     [java] SEVERE: ResourceManager : unable to find resource 'org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm' in any resource loader.
     [java] 
     [java] WSDLToJava Error: Could not find Velocity template file: org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm
     [java] 
     [java] org.apache.cxf.tools.common.ToolException: Could not find Velocity template file: org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm
     [java]     at org.apache.cxf.tools.common.VelocityGenerator.doWrite(VelocityGenerator.java:101)
     [java]     at org.apache.cxf.tools.wsdlto.core.AbstractGenerator.doWrite(AbstractGenerator.java:54)
     [java]     at org.apache.cxf.tools.wsdlto.frontend.jaxws.generators.FaultGenerator.generate(FaultGenerator.java:133)
     [java]     at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:288)
     [java]     at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:156)
     [java]     at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:404)
     [java]     at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:105)
     [java]     at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
     [java]     at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
     [java]     at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:185)
     [java] Caused by: org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm'
     [java]     at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:474)
     [java]     at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:352)
     [java]     at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1533)
     [java]     at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1514)
     [java]     at org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleton.java:299)
     [java]     at org.apache.velocity.app.Velocity.getTemplate(Velocity.java:358)
     [java]     at org.apache.cxf.tools.common.VelocityGenerator.doWrite(VelocityGenerator.java:98)
     [java]     ... 9 more
[INFO] ------------------------------------------------------------------------

使用下面的任务使用wsdltojava生成wdsl客户机,并在其cxf.classpath中指定所有与cxf相关的jar。但它仍然无法在org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm中找到资源
cxf.xml文件

<java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true" failonerror="true">
       <jvmarg value="-Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"/>
       <jvmarg value="-Dorg.apache.cxf.stax.allowInsecureParser=true"/>
       <arg line="${cxf_args}"/>
       <classpath>
           <path refid="cxf.classpath"/>
       </classpath>
  </java>

<path id="cxf.classpath">
        <fileset file="${org.apache.cxf:cxf-common-schemas:jar}"/>
        <fileset file="${org.apache.cxf:cxf-core:jar}"/>
        <fileset file="${org.apache.cxf:cxf-rt-bindings-soap:jar}"/>
        <fileset file="${org.apache.cxf:cxf-rt-bindings-xml:jar}"/>
        <fileset file="${org.apache.cxf:cxf-rt-databinding-jaxb:jar}"/>
        <fileset file="${org.apache.cxf:cxf-rt-frontend-jaxrs:jar}"/>
        <fileset file="${org.apache.cxf:cxf-rt-frontend-jaxws:jar}"/>
        <fileset file="${org.apache.cxf:cxf-rt-frontend-simple:jar}"/>
        <fileset file="${org.apache.cxf:cxf-rt-rs-client:jar}"/>
        <fileset file="${org.apache.cxf:cxf-rt-transports-http:jar}"/>
        <fileset file="${org.apache.cxf:cxf-rt-transports-http-jetty:jar}"/>
        <fileset file="${org.apache.cxf:cxf-rt-transports-local:jar}"/>
        <fileset file="${org.apache.cxf:cxf-rt-ws-addr:jar}"/>
        <fileset file="${org.apache.cxf:cxf-rt-wsdl:jar}"/>
        <fileset file="${org.apache.cxf:cxf-rt-ws-policy:jar}"/>
        <fileset file="${org.apache.cxf:cxf-tools-common:jar}"/>
        <fileset file="${org.apache.cxf:cxf-tools-validator:jar}"/>
        <fileset file="${org.apache.cxf:cxf-tools-wsdlto-core:jar}"/>
        <fileset file="${org.apache.cxf:cxf-tools-wsdlto-databinding-jaxb:jar}"/>
        <fileset file="${org.apache.cxf:cxf-tools-wsdlto-frontend-jaxws:jar}"/>
        ....
</path>

我需要添加其他依赖项吗?

tv6aics1

tv6aics11#

与cxf团队进行了同样的检查。https://issues.apache.org/jira/browse/cxf-8390
添加或升级速度到最新的解决了这个问题。

<dependency>
    <groupId>org.apache.velocity</groupId>
    <artifactId>velocity-engine-core</artifactId>
    <version>2.2</version>
</dependency>
vsmadaxz

vsmadaxz2#

我在构建应用程序时遇到了类似的问题,并最终将其追溯到cxf工具公共jar。从3.3.4开始,velocitygenerator类中的方法dowrite有两个更改:
3.3.0
props.put("resource.loader", "class"); props.put("class.resource.loader.class", clzName); 3.3.4
props.put("resource.loaders", "class"); props.put("resource.loader.class.class", clzName); 在我的应用程序中,如果我将更改还原到这一个文件,我的生成将完成。这可能是cxf的一个bug。

相关问题