jaxb2-maven-plugin: 2.2: xjc — необъявленная проблема с префиксом — java 1.7

Я использую следующие зависимости в моем pom.xml

<dependency>
     <groupId>com.sun.xml.bind</groupId>
     <artifactId>jaxb-xjc</artifactId>
     <version>2.1.14</version>
     <scope>compile</scope>
 </dependency>
<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.2.7</version>
   <scope>compile</scope>
</dependency>
<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-core</artifactId>
    <version>2.2.7</version>
    <scope>compile</scope>
</dependency>
 <dependency>
  <groupId>com.sun.xml.bind</groupId>
  <artifactId>jaxb-impl</artifactId>
  <version>2.0</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>com.thoughtworks.xstream</groupId>
  <artifactId>xstream</artifactId>
  <version>1.3.1</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>xerces</groupId>
  <artifactId>xercesImpl</artifactId>
  <version>2.11.0</version>
  <scope>runtime</scope>
</dependency>
<dependency>
   <groupId>xml-apis</groupId>
   <artifactId>xml-apis</artifactId>
   <version>2.0.2</version>
   <scope>compile</scope>
</dependency>

привязка.xjb:

 <jxb:bindings version="1.0"
           xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
           xmlns:xs="http://www.w3.org/2001/XMLSchema">

 <jxb:bindings schemaLocation="../../../../xsd/icmarchitecture/mom/log/RetrieveExecutionInfo.xsd" node="/xs:schema">
<jxb:globalBindings>
    <jxb:javaType name="com.pcm.icm.architecture.util.Timestamp" xmlType="icm:Timestamp" printMethod="toXsdString" parseMethod="create"/>
</jxb:globalBindings>

ПолучитьExecutionInfo.xsd:

                     <?xml version="1.0" encoding="UTF-8"?>
                     <!-- edited with XMLSPY v2004 rel. 2 U (http://www.xmlspy.com) by pcm (pcm) -->
                     <!-- edited with XML Spy v4.4 U (http://www.xmlspy.com) by bbl (bbl) -->
                  <xs:schema 
        targetNamespace="http://www.pcm.com/icm/architecture/mom/log/payload" 
       xmlns="http://www.pcm.com/icm/architecture/mom/log/payload" 
       xmlns:xs="http://www.w3.org/2001/XMLSchema" 
        xmlns:ns1="http://www.pcm.com/icm/architecture/status/payload" 
       xmlns:icm="http://www.pcm.com/icm/architecture/common/payload" 
     elementFormDefault="qualified" attributeFormDefault="qualified">
               <xs:import 
        namespace="http://www.pcm.com/icm/architecture/status/payload" 
        schemaLocation="../../status/status.xsd"/>
                <xs:import 
         namespace="http://www.pcm.com/icm/architecture/common/payload" 
         schemaLocation="../../common/ICMTypedefinitions.xsd"/>
                <xs:complexType name="FilterKeyValueType">
               <xs:annotation>
                <xs:documentation>Filter on key value pair</xs:documentation>
              </xs:annotation>
    <xs:sequence>
        <xs:element name="Key" type="xs:string"/>
        <xs:element ref="Operator"/>
        <xs:element name="Value" type="xs:string"/>
    </xs:sequence>
</xs:complexType>
<xs:element name="FilterKey">
    <xs:annotation>
        <xs:documentation>Filter on Key</xs:documentation>
    </xs:annotation>
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="Operator"/>
            <xs:element name="Value" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
<xs:complexType name="KeyValueType">
    <xs:annotation>
        <xs:documentation>Key value pair</xs:documentation>
    </xs:annotation>
    <xs:sequence>
        <xs:element name="Key" type="xs:string"/>
        <xs:element name="Value" type="xs:string" minOccurs="0"/>
    </xs:sequence>
</xs:complexType>
<xs:element name="Operator">
    <xs:annotation>
        <xs:documentation>Operator for a filter</xs:documentation>
    </xs:annotation>
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:enumeration value="greater_equal"/>
            <xs:enumeration value="greater"/>
            <xs:enumeration value="less"/>
            <xs:enumeration value="less_equal"/>
            <xs:enumeration value="not_equal"/>
            <xs:enumeration value="equal"/>
            <xs:enumeration value="like"/>
        </xs:restriction>
    </xs:simpleType>
</xs:element>
<xs:element name="FilterService">
    <xs:annotation>
        <xs:documentation>Filter on service</xs:documentation>
    </xs:annotation>
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="ServiceAddress"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
<xs:element name="FilterTimestamp">
    <xs:annotation>
        <xs:documentation>Filter on timestamp</xs:documentation>
    </xs:annotation>
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="Operator"/>
            <xs:element name="Value" type="icm:Timestamp"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
<xs:element name="ExecutionInfoElement">
    <xs:annotation>
        <xs:documentation>Reply element</xs:documentation>
    </xs:annotation>
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="ServiceAddress"/>
            <xs:element name="RequestTimestamp" type="icm:Timestamp" minOccurs="0"/>
            <xs:element name="DurationInMillis" type="xs:long" minOccurs="0"/>
            <xs:element name="RequestLogMsgId" type="xs:string" minOccurs="0"/>
            <xs:element name="KeyValue" type="KeyValueType" minOccurs="0" maxOccurs="999"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
<xs:element name="FilterMillis">
    <xs:annotation>
        <xs:documentation>Filter on millis</xs:documentation>
    </xs:annotation>
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="Operator"/>
            <xs:element name="Value" type="xs:long"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
<xs:element name="ServiceAddress">
    <xs:annotation>
        <xs:documentation>Service address</xs:documentation>
    </xs:annotation>
    <xs:complexType>
        <xs:sequence>
            <xs:element name="service" type="xs:string" minOccurs="0"/>
            <xs:element name="protocol" type="xs:string" minOccurs="0"/>
        </xs:sequence>
        <xs:attribute name="id" type="xs:string" use="optional"/>
    </xs:complexType>
</xs:element>
<xs:element name="RetrieveExecutionInfoRq">
    <xs:annotation>
        <xs:documentation>Request to get execution info elements</xs:documentation>
    </xs:annotation>
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="FilterService" minOccurs="0" maxOccurs="999"/>
            <xs:element ref="FilterTimestamp" minOccurs="0" maxOccurs="999"/>
            <xs:element ref="FilterMillis" minOccurs="0" maxOccurs="999"/>
            <xs:element name="AndFilterKeyValue" type="FilterKeyValueType" minOccurs="0" maxOccurs="999"/>
            <xs:element name="OrFilterKeyValue" type="FilterKeyValueType" minOccurs="0" maxOccurs="999"/>
            <xs:element ref="FilterKey" minOccurs="0" maxOccurs="999"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
<xs:element name="RetrieveExecutionInfoRs">
    <xs:annotation>
        <xs:documentation>Reply with execution info elements</xs:documentation>
    </xs:annotation>
    <xs:complexType>
        <xs:sequence>
            <xs:element name="statusInfo" type="ns1:statusType"/>
            <xs:element ref="ExecutionInfoElement" minOccurs="0" maxOccurs="999"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
      </xs:schema>

Версия Maven — 3.1 Версия Java — 1.7

Ошибка :

org.xml.sax.SAXParseException; системный идентификатор: файл:/C:/Data/NewGitRepo/TestICMGitRepo/ICMTrunk/icmarchitecture/src/main/resources/xjb/icmarchitecture/mom/log/binding.xjb; номер строки: 7; номер столбца: 136; UndeclaredPrefix: не удается разрешить «icm:Timestamp» как QName: префикс «icm» не объявлен. на com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198) на com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134) на com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:437) на com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368) на com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)

org.xml.sax.SAXParseException; системный идентификатор: файл:/binding.xjb; номер строки: 7; номер столбца: 136; cvc-attribute.3: значение icm:Timestamp атрибута xmlType элемента jxb:javaType недопустимо по отношению к его типу QName. на com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198) на com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134) на com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:437) на com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368) на com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)

Я получаю указанное выше исключение, когда делаю чистую установку maven через eclipse с компилятором java 1.7.

Но если я изменю компилятор Java на 1.8, он будет работать нормально. но я хочу развернуть этот jar на сервере JBoss с версией java 1.7.

Пожалуйста, помогите в этом. Заранее спасибо.


person SM.Venkat    schedule 02.08.2018    source источник
comment
Опубликуйте свой binding.xjb файл.   -  person lexicore    schedule 02.08.2018
comment
Спасибо за ваш комментарий   -  person SM.Venkat    schedule 03.08.2018
comment
Вы должны объявить свой префикс icm в файле привязок. Добавьте xmlns:icm="<URI of the icm namespace here>" к корневому элементу.   -  person lexicore    schedule 03.08.2018
comment
Лексикор большое спасибо. Это сработало :)   -  person SM.Venkat    schedule 06.08.2018


Ответы (1)


Вы должны объявить свой префикс icm в файле привязок.

Добавьте xmlns:icm="<URI of the icm namespace here>" к корневому элементу.

Это меньше связано с JAXB и больше с XML. JAXB ожидает "полное имя" как @xmlType. «Полное имя» означает, что префикс должен быть определен и указывать на правильное пространство имен.

person lexicore    schedule 06.08.2018