Search code examples
javaweb-servicescxfwsdl2java

Unable to generate java code for webservice using WSDLToJava with Apache CXF 3.1.6


I am trying to generate the java code for webservice using WSDLToJava in Apache CXF 3.1.6, but I am getting this exception and I don't know from where the Velocity templates are coming into picture.

WSDLToJava Error: Could not find Velocity template file: org/apache/cxf/tools/wsdlto/frontend/jaxws/template/service.vm

I was trying to locate the file in my project or in the generated code, but I don't see it anywhere.

Do I need to include the velocity jars in my project or do I need to create a service.vm velocity template?


Solution

  • The service.vm file is part cxf-tools-wsdlto-frontend-jaxws.jar, make sure its part of lib directory when running Wsdl2Java command. I would recommand you to use all the jars present as part of cxf binary distribution shown below or use any build script such as maven and use cxf-codegen-maven plugin such the it resolves jar dependencies and downloads automatically.

    enter image description here