Lee Yang created CXF-5951:
-----------------------------

             Summary: wadl2java jaxb binding bug
                 Key: CXF-5951
                 URL: https://issues.apache.org/jira/browse/CXF-5951
             Project: CXF
          Issue Type: Bug
            Reporter: Lee Yang


If you specify the jaxb binding file using the <bindingFile> tag (see the pom 
configuration section),  then wadl2java throws the following error:

[INFO] java.lang.RuntimeException: Error compiling schema from WADL : 
"file:/C:/webdev/cygwin/tmp/xsd/MyTypes.xsd" is not a part of this compilation. 
Is this a mistake for 
"file:/C:/webdev/cygwin/tmp/cxf-tmp-699471/jaxbbinding5875176368914084138.xml"?

However, if you specify the same jaxb binding file using the -xjc -b option via 
the <extraarg> tag, then the binding works. The relevant files (pom, 
xsd-binding, and wadl) are enclosed below.

1.  The relevant pom configuration section:

<plugin>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-wadl2java-plugin</artifactId>
        <version>${cxf.version}</version>  <!-- 3.0.0 or 3.0.1 -->
        <executions>
                <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                                
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
                                
<inheritResourceParams>true</inheritResourceParams>
                                <wadlOptions>
                                        <wadlOption>
                                                <wadl>
                                                        
${basedir}/src/main/resources/wadl/MyService-wadl.xml
                                                </wadl>
                                                <!-- The following 
commented-out binding causes errors. The same binding works
                                                         fine when using the 
-xjc options via the extraarg tag.
                                                <bindingFiles>
                                                        
<bindingFile>${basedir}/src/main/resources/binding/xsd-binding.xml</bindingFile>
                                                </bindingFiles>
                                                -->
                                                
<packagename>com.mycomp.myservice</packagename>
                                                <extraargs>
                                                        
<extraarg>-xjc-b</extraarg>
                                                        
<extrarrg>-xjc${basedir}/src/main/resources/binding/xsd-binding.xml</extrarrg>
                                                </extraargs>                    
                                        </wadlOption>
                                </wadlOptions>
                        </configuration>
                        <goals>
                                <goal>wadl2java</goal>
                        </goals>
                </execution>
        </executions>
</plugin>


2.  The xsd-binding.xml:

<jxb:bindings version="2.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb";
        xmlns:xs="http://www.w3.org/2001/XMLSchema";>
        <jxb:bindings schemaLocation="../xsd/MyTypes.xsd" node="/xs:schema">
                <jxb:schemaBindings>
                        <jxb:package name="com.mycomp.ws.rs.myservice.types" />
                </jxb:schemaBindings>
        </jxb:bindings>
</jxb:bindings>


3.  The MyService-wadl.xml:

<wadl:application xmlns:wadl="http://wadl.dev.java.net/2009/02"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns="http://www.mycomp.com/rs/MyService/types"; 
xsi:schemaLocation="http://wadl.dev.java.net/2009/02 
http://wadl.java.net/wadl20090202.xsd";>
        <wadl:grammars>
                <wadl:include href="../xsd/MyTypes.xsd"/>
        </wadl:grammars>
        <wadl:resources base="http://HOST:PORT/WEB_APP_CONTEXT_ROOT/services";>
        ...
</wadl>




--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to