The wsdl2java command line tool has a "-wsdlLocation" flag that can be used to override the location that is output into the various places. I think the "extraArgs" thing can be used with the plugin to specify that.

Dan



On Jul 1, 2008, at 11:35 AM, Gary Weaver wrote:

Hello again,

Anyone know why the client code generated by cxf-codegen-plugin v2.1 + JAXB is hardcoding the original WSDL file's path into the client classes, and then looking for that file when the client is used?

Any idea how to keep it from doing that?

For example, in one of the autogenerated client service classes it has a static block that looks like:

...
  static {
      URL url = null;
      try {
url = new URL("file:/path/to/my/project/trunk/src/main/ wsdl/MyService.wsdl");
      } catch (MalformedURLException e) {
System.err.println("Can not initialize the default wsdl from file:/path/to/my/project/trunk/src/main/wsdl/MyService.wsdl");
          // e.printStackTrace();
      }
      WSDL_LOCATION = url;
  }
...

And in the pom.xml looks like:

...
          <plugin>
              <groupId>org.apache.cxf</groupId>
              <artifactId>cxf-codegen-plugin</artifactId>
              <version>${cxf.version}</version>
              <executions>
                  <execution>
                      <id>checklist</id>
                      <phase>generate-sources</phase>
                      <configuration>
<sourceRoot>${basedir}/target/generated/ src/main/java</sourceRoot>
                          <wsdlOptions>
                              <wsdlOption>
<wsdl>${basedir}/src/main/wsdl/ MyService.wsdl</wsdl>
                              </wsdlOption>
                          </wsdlOptions>
                      </configuration>
                      <goals>
                          <goal>wsdl2java</goal>
                      </goals>
                  </execution>
                  ...
              </executions>
          </plugin>
...


And the error that occurs when you run this in an environment where that path/file (/path/to/my/project/trunk/src/main/wsdl/ MyService.wsdl) doesn't exist is:

javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
      at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:134)
at org .apache .cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java: 65)
      at javax.xml.ws.Service.<init>(Service.java:56)
      at ... (autogenerated client code)
      at ...
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service. at org .apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java: 83) at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:140)
      at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:132)
      ...
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: Problem parsing 'file:/path/to/my/project/ trunk/src/main/wsdl/MyService.wsdl'.: java.io.FileNotFoundException: /path/to/my/project/trunk/src/main/ wsdl/MyService.wsdl (No such file or directory)
      at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(Unknown Source)
      at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
      at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at org .apache .cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:206) at org .apache .cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:170) at org .apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java: 81)
      ...
Caused by: java.io.FileNotFoundException: /path/to/my/wsdl/ MyService.wsdl (No such file or directory)
      at java.io.FileInputStream.open(Native Method)
      at java.io.FileInputStream.<init>(FileInputStream.java:106)
      at java.io.FileInputStream.<init>(FileInputStream.java:66)
at sun .net .www.protocol.file.FileURLConnection.connect(FileURLConnection.java: 70) at sun .net .www .protocol .file.FileURLConnection.getInputStream(FileURLConnection.java:161) at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source) at org .apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
      at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
      ...

Thanks in advance!

Gary

--
Gary Weaver
Internet Framework Services
Office of Information Technology
Duke University


---
Daniel Kulp
[EMAIL PROTECTED]
http://www.dankulp.com/blog




Reply via email to