jaxb2: Ignores annotation

157 views Asked by At

This is my maven-jaxb2-plugin configuration:

<build>
   <plugins>
      <plugin>
         <groupId>org.jvnet.jaxb2.maven2</groupId>
         <artifactId>maven-jaxb2-plugin</artifactId>
         <version>0.14.0</version>
         <executions>
            <execution>
               <goals>
                  <goal>generate</goal>
               </goals>
               <configuration>
                  <schemaLanguage>WSDL</schemaLanguage>
                  <generateDirectory>${project.basedir}/src/main/java</generateDirectory>
                  <generatePackage>cat.gencat.catsalut.hes.visor.api.common.domain.incidencies</generatePackage>
                  <!-- <forceRegenerate>true</forceRegenerate> -->
                  <schemaDirectory>${basedir}/wsdl/incidencies</schemaDirectory>
                  <schemaIncludes>
                     <include>InformarIncidencia_v02_00.xsd</include>
                  </schemaIncludes>
                  <args>
                     <arg>-npa</arg>
                     <arg>-no-header</arg>
                  </args>
                  <bindingDirectory>${project.basedir}/wsdl/incidencies</bindingDirectory>
                  <bindingIncludes>*.xml</bindingIncludes>
                  <verbose>true</verbose>
                  <debug>true</debug>
               </configuration>
            </execution>
         </executions>
      </plugin>
   </plugins>
</build>

My bindings.xml file is:

<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:annox="http://annox.dev.java.net" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:xs="http://www.w3.org/2001/XMLSchema" jaxb:extensionBindingPrefixes="annox xjc" version="2.1">
   <!-- xmlrootelement -->
   <jaxb:bindings schemaLocation="InformarIncidencia_v02_00.xsd">
      <jaxb:bindings node="//xs:complexType[@name='informarIncidenciaRequest']">
         <annox:annotate target="class">
            <annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement" name="informarIncidencia" namespace="http://salut.gencat.cat/hc3/informarincidencia" />
         </annox:annotate>
      </jaxb:bindings>
   </jaxb:bindings>
</jaxb:bindings>

And my xsd is:

<?xml version="1.0" encoding="UTF-8"?>
<WL5G3N0:definitions xmlns:WL5G3N0="http://schemas.xmlsoap.org/wsdl/" xmlns:WL5G3N1="http://salut.gencat.cat/hc3/informarincidencia" name="InformarIncidencia-v2.1" targetNamespace="http://salut.gencat.cat/hc3/informarincidencia">
   <WL5G3N0:types>
      <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://salut.gencat.cat/hc3/informarincidencia" xmlns:tns="http://salut.gencat.cat/hc3/response" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://salut.gencat.cat/hc3/response" version="1.0">
         <xsd:element name="UpdateResponseDocument" type="tns:updateResponseDocument" />
         <xsd:complexType name="updateResponseDocument">
            <xsd:sequence>
               <xsd:element minOccurs="0" name="codiDocument" type="xs:string" />
               <xsd:element minOccurs="0" name="code" type="xs:string" />
               <xsd:element minOccurs="0" name="resultCode" type="xs:string" />
               <xsd:element maxOccurs="unbounded" minOccurs="0" name="result" nillable="true" type="tns:wsMessage" />
            </xsd:sequence>
         </xsd:complexType>
         <xsd:complexType name="wsMessage">
            <xsd:sequence>
               <xsd:element minOccurs="0" name="executionCode" type="xs:string" />
               <xsd:element minOccurs="0" name="executionDetails" type="xs:string" />
            </xsd:sequence>
         </xsd:complexType>
         <xsd:complexType name="updateResponse">
            <xsd:sequence>
               <xsd:element minOccurs="0" name="code" type="xs:string" />
               <xsd:element minOccurs="0" name="resultCode" type="xs:string" />
               <xsd:element maxOccurs="unbounded" minOccurs="0" name="result" nillable="true" type="tns:wsMessage" />
            </xsd:sequence>
         </xsd:complexType>
      </xsd:schema>
      <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://salut.gencat.cat/hc3/response" xmlns:tns="http://salut.gencat.cat/hc3/informarincidencia" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://salut.gencat.cat/hc3/informarincidencia">
         <xsd:import namespace="http://salut.gencat.cat/hc3/response" />
         <xsd:element name="informarIncidencia" type="tns:informarIncidenciaRequest" />
         <xsd:element name="informarIncidenciaClinicaResponse" type="tns:informeResponse" />
         <xsd:complexType name="informarIncidenciaRequest">
            <xsd:sequence>
               <xsd:element name="codiEp" type="xs:string" />
               <xsd:element name="codiUp" type="xs:string" />
               <xsd:element name="codiCentre" type="xs:string" />
               <xsd:element name="cip" type="xs:string" />
               <xsd:element minOccurs="0" name="cpc" type="xs:string" />
               <xsd:element minOccurs="0" name="informesDuplicats">
                  <xsd:complexType>
                     <xsd:sequence>
                        <xsd:element maxOccurs="unbounded" minOccurs="0" name="cpcd" type="xs:string" />
                     </xsd:sequence>
                  </xsd:complexType>
               </xsd:element>
               <xsd:element minOccurs="0" name="email" type="xs:string" />
               <xsd:element minOccurs="0" name="telefon" type="xs:string" />
               <xsd:element name="nomMetge" type="xs:string" />
               <xsd:element name="cognom1Metge" type="xs:string" />
               <xsd:element name="cognom2Metge" type="xs:string" />
               <xsd:element name="dniMetge" type="xs:string" />
               <xsd:element name="codiColegiat" type="xs:string" />
               <xsd:element name="motiu" type="xs:string" />
               <xsd:element minOccurs="0" name="altres" type="xs:string" />
               <xsd:element minOccurs="0" name="observacions" type="xs:string" />
            </xsd:sequence>
         </xsd:complexType>
         <xsd:complexType final="extension restriction" name="informeResponse">
            <xsd:sequence>
               <xsd:element minOccurs="0" ref="ns1:UpdateResponseDocument" />
            </xsd:sequence>
         </xsd:complexType>
         <xsd:element name="informarincidenciaResponse" nillable="true" type="tns:informeResponse" />
      </xsd:schema>
   </WL5G3N0:types>
   <WL5G3N0:message name="informarIncidenciaResponse">
      <WL5G3N0:part element="WL5G3N1:informarincidenciaResponse" name="parameters" />
   </WL5G3N0:message>
   <WL5G3N0:message name="informarIncidencia">
      <WL5G3N0:part element="WL5G3N1:informarIncidencia" name="parameters" />
   </WL5G3N0:message>
   <WL5G3N0:portType name="InformarIncidencia-v2.1">
      <WL5G3N0:operation name="informarIncidencia">
         <WL5G3N0:input message="WL5G3N1:informarIncidencia" name="informarIncidencia" />
         <WL5G3N0:output message="WL5G3N1:informarIncidenciaResponse" name="informarIncidenciaResponse" />
      </WL5G3N0:operation>
   </WL5G3N0:portType>
</WL5G3N0:definitions>

Nevertheless, my class InformarIncidenciaRequest is not annotated with XmlRootElement:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "informarIncidenciaRequest", namespace = "http://salut.gencat.cat/hc3/informarincidencia", propOrder = {
    ...
})
public class InformarIncidenciaRequest {

Any ideas?

1

There are 1 answers

0
Jordi Cabré On

I've solved this using:

...
   <args>
      <arg>-npa</arg>
      <arg>-no-header</arg>
      <arg>-Xannotate</arg>
   </args>
   <plugins>
      <plugin>
         <groupId>org.jvnet.jaxb2_commons</groupId>
         <artifactId>jaxb2-basics-annotate</artifactId>
         <version>1.1.0</version>
      </plugin>
   </plugins>
...