Results 1 to 7 of 7

Thread: Switch xerces version in pom.xml

  1. #1

    Default Switch xerces version in pom.xml

    Hello.


    I'm working on app using SWS.

    PayloadValidatingInterceptor fails to validate the following request:
    Code:
    ...
    <sch:transport xmlns:sch="http://www.invito.ru/ws/schemas">
      <sch:transportType code="0"/>
      <sch:details xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"                                 xsi:type="sch:Flight">
         <sch:commonTransportInfo>String</sch:commonTransportInfo>
         <sch:airline code="0"/>
           <sch:departureAirports>
             <sch:airport code="0"/>
           </sch:departureAirports>
       </sch:details>
    </sch:transport>
    ...
    which is based on schema:
    Code:
    <xsd:element name="transport" nillable="true" minOccurs="0">
      <xsd:complexType>
        <xsd:sequence>
          <xsd:element name="transportType" type="ReferenceItem"/>
          <xsd:element name="details" type="TransportDetails"/>
        </xsd:sequence>
      </xsd:complexType>
    </xsd:element>
    <xsd:complexType name="TransportDetails" abstract="true">
      <xsd:sequence>
        <xsd:element name="commonTransportInfo" type="xsd:string"/>
      </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="Flight">
      <xsd:complexContent>
        <xsd:extension base="TransportDetails">
          <xsd:sequence>
            <xsd:element name="airline" type="ReferenceItem" minOccurs="0"/>
    	<xsd:element name="departureAirports" type="ArrayOfAirportCode" minOccurs="0"/>
          </xsd:sequence>
        </xsd:extension>
      </xsd:complexContent>
    </xsd:complexType>
    Stacktrace:
    Code:
    2007-08-15 15:40:19,880 WARN [org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor] - XML validation error on request: UndeclaredPrefix: C
    annot resolve 'sch:Flight' as a QName: the prefix 'sch' is not declared.
    2007-08-15 15:40:19,880 WARN [org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor] - XML validation error on request: cvc-elt.4.1: The va
    lue 'sch:Flight' of attribute 'http://www.w3.org/2001/XMLSchema-instance,type' of element 'sch:details' is not a valid QName.
    2007-08-15 15:40:19,880 WARN [org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor] - XML validation error on request: cvc-type.2: The typ
    e definition cannot be abstract for element sch:details.
    2007-08-15 15:40:19,880 WARN [org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor] - XML validation error on request: UndeclaredPrefix: C
    annot resolve 'sch:Flight' as a QName: the prefix 'sch' is not declared.
    2007-08-15 15:40:19,880 WARN [org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor] - XML validation error on request: cvc-attribute.3: Th
    e value 'sch:Flight' of attribute 'xsi:type' on element 'sch:details' is not valid with respect to its type, 'QName'.
    2007-08-15 15:40:19,880 WARN [org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor] - XML validation error on request: cvc-complex-type.2.
    4.d: Invalid content was found starting with element 'sch:airline'. No child element is expected at this point.

    I can switch off the validation and this message is getting unmarshelled with JAXB without errors.


    I've found the same issue with validation on this forum and the advise was to change the parser version.

    The problem is that i don't know how to change the parser version with pom.
    I'm using spring-ws-1.0-rc3-SNAPSHOT, jdk 1.5.0_12, jetty 6.1.5

    My pom:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    	<modelVersion>4.0.0</modelVersion>
    	<groupId>ru.invito.ws</groupId>
    	<artifactId>invito-ws</artifactId>
    	<packaging>war</packaging>
    	<version>1.0-SNAPSHOT</version>
    	<name>invito-ws Spring-WS Application</name>
    	<url>http://www.springframework.org/spring-ws</url>
    	<build>
    		<finalName>invito-ws</finalName>
    		<plugins>
    			<plugin>
    				<groupId>com.sun.tools.xjc.maven2</groupId>
    				<artifactId>maven-jaxb-plugin</artifactId>
    				<executions>
    					<execution>
    						<goals>
    							<goal>generate</goal>
    						</goals>
    					</execution>
    				</executions>
    				<configuration>
    					<schemaDirectory>${basedir}/src/main/webapp/WEB-INF</schemaDirectory>
    					<generateDirectory>src/main/java</generateDirectory>
    					<includeSchemas>
    						<includeSchema>**/*.xsd</includeSchema>
    						<includeSchema>**/*.dtd</includeSchema>
    					</includeSchemas>
    					<excludeSchemas>
    						<excludeSchema>test*.xsd</excludeSchema>
    						<excludeSchema>FS_OTA_Ping.xsd</excludeSchema>
    					</excludeSchemas>
    					<includeBindings>
    						<includeBinding>*.xjb</includeBinding>
    					</includeBindings>
    					<strict>true</strict>
    					<verbose>true</verbose>
    					<extension>true</extension>
    				</configuration>
    			</plugin>
    			<plugin>
    				<groupId>org.apache.maven.plugins</groupId>
    				<artifactId>maven-compiler-plugin</artifactId>
    				<configuration>
    					<source>1.5</source>
    					<target>1.5</target>
    				</configuration>
    			</plugin>
    			<plugin>
    				<groupId>org.mortbay.jetty</groupId>
    				<artifactId>maven-jetty-plugin</artifactId>
    			</plugin>
    		</plugins>
    	</build>
    	<dependencies>
    		<!-- Spring-WS dependencies -->
    		<dependency>
    			<groupId>org.springframework.ws</groupId>
    			<artifactId>spring-xml</artifactId>
    			<version>1.0-rc3-SNAPSHOT</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework.ws</groupId>
    			<artifactId>spring-ws-core</artifactId>
    			<version>1.0-rc3-SNAPSHOT</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework.ws</groupId>
    			<artifactId>spring-ws-core-tiger</artifactId>
    			<version>1.0-rc3-SNAPSHOT</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework.ws</groupId>
    			<artifactId>spring-oxm</artifactId>
    			<version>1.0-rc3-SNAPSHOT</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework.ws</groupId>
    			<artifactId>spring-oxm-tiger</artifactId>
    			<version>1.0-rc3-SNAPSHOT</version>
    			<scope>runtime</scope>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework.ws</groupId>
    			<artifactId>spring-ws-security</artifactId>
    			<version>1.0-rc3-SNAPSHOT</version>
    		</dependency>
    		<!-- /Spring-WS dependencies -->
    		<!-- Spring dependencies -->
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-context</artifactId>
    			<version>2.0.5</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-beans</artifactId>
    			<version>2.0.5</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-aop</artifactId>
    			<version>2.0.5</version>
    			<scope>runtime</scope>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-web</artifactId>
    			<version>2.0.5</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-webmvc</artifactId>
    			<version>2.0.5</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-remoting</artifactId>
    			<version>2.0.5</version>
    		</dependency>
    		<!-- /Spring dependencies -->
    		<dependency>
    			<groupId>junit</groupId>
    			<artifactId>junit</artifactId>
    			<version>4.1</version>
    			<scope>test</scope>
    		</dependency>
    		<!-- O/X Mapping + XJC dependencies -->
    		<dependency>
    			<groupId>javax.xml.bind</groupId>
    			<artifactId>jaxb-api</artifactId>
    			<version>2.1</version>
    		</dependency>
    		<dependency>
    			<groupId>com.sun.xml.bind</groupId>
    			<artifactId>jaxb-impl</artifactId>
    			<version>2.1.3</version>
    			<scope>runtime</scope>
    		</dependency>
    		<!-- /O/X Mapping + XJC dependencies -->
    		<dependency>
    			<groupId>javax.xml.soap</groupId>
    			<artifactId>saaj-api</artifactId>
    			<version>1.3</version>
    			<scope>runtime</scope>
    		</dependency>
    		<dependency>
    			<groupId>com.sun.xml.messaging.saaj</groupId>
    			<artifactId>saaj-impl</artifactId>
    			<version>1.3</version>
    			<scope>runtime</scope>
    		</dependency>
    	</dependencies>
    	<repositories>
    		<repository>
    			<id>spring-s3</id>
    			<name>Springframework Maven SNAPSHOT Repository</name>
    			<url>http://s3.amazonaws.com/maven.springframework.org/snapshot</url>
    		</repository>
    		<repository>
    			<id>java.net</id>
    			<name>java.net Maven Repository</name>
    			<url>https://maven-repository.dev.java.net/nonav/repository</url>
    			<layout>legacy</layout>
    		</repository>
    	</repositories>
    </project>
    How to specify a version of xerces/xalan here?

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    How about the same as all other dependencies? Why would it differ?
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    Well, before asking here i've added the following:

    Code:
    <dependency>
      <groupId>xerces</groupId>
       <artifactId>xercesImpl</artifactId>
       <version>2.8.1</version>
    </dependency>
    <dependency>
      <groupId>xalan</groupId>
      <artifactId>xalan</artifactId>
      <version>2.7.0</version>
    </dependency>
    and this does not help. The xercesImpl-2.8.1.jar and xalan-2.7.0.jar are now in the WEB-INF/lib but error persists.

    I've deployed war on tomcat 6.0.13 with the same result.

    The contents of generated WEB-INF/lib folder are:
    Code:
    acegi-security-1.0.3.jar
    activation-1.1.jar
    aopalliance-1.0.jar
    commons-logging-1.1.jar
    jaxb-api-2.1.jar
    jaxb-impl-2.1.3.jar
    log4j-1.2.12.jar
    mail-1.4.jar
    oro-2.0.8.jar
    saaj-api-1.3.jar
    saaj-impl-1.3.jar
    spring-aop-2.0.5.jar
    spring-beans-2.0.5.jar
    spring-context-2.0.5.jar
    spring-core-2.0.6.jar
    spring-dao-2.0.6.jar
    spring-oxm-1.0-rc3-SNAPSHOT.jar
    spring-oxm-tiger-1.0-rc3-20070815.014704-28.jar
    spring-remoting-2.0.5.jar
    spring-support-2.0.5.jar
    spring-web-2.0.5.jar
    spring-webmvc-2.0.5.jar
    spring-ws-core-1.0-rc3-SNAPSHOT.jar
    spring-ws-core-tiger-1.0-rc3-20070815.014704-28.jar
    spring-ws-security-1.0-rc3-20070815.014704-28.jar
    spring-xml-1.0-rc3-SNAPSHOT.jar
    stax-api-1.0-2.jar
    stax-api-1.0.1.jar
    wsdl4j-1.6.1.jar
    xalan-2.7.0.jar
    xercesImpl-2.8.1.jar
    xml-apis-1.3.03.jar
    xmldsig-1.0.jar
    xmlsec-1.3.0.jar
    xmlsec-2.0.jar
    xws-security-2.0-FCS.jar
    What i'm doing wrong? May be there's a "hidden dependency" that must be "excluded" or so?

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    I guess that there is a version loaded before the version of y our web application.l So you probably have 2 version of the parser on your classpath. Make sure that there is only one.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5

    Smile

    I've validated the schema instance document against the schema with jdk parser :

    Code:
    import java.io.File;
    import java.io.IOException;
    import javax.xml.XMLConstants;
    import javax.xml.transform.stream.StreamSource;
    import javax.xml.validation.Schema;
    import javax.xml.validation.SchemaFactory;
    import javax.xml.validation.Validator;
    import org.xml.sax.SAXException;
    
    public class Main {
    	public static void main(String[] args) throws SAXException, IOException {
    		SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    		Schema schema = factory.newSchema(new File("test.xsd"));
    		Validator validator = schema.newValidator();
    		validator.validate(new StreamSource(new File("test.xml")));
    	}
    }
    It was valid!!!

    The test.xml:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <sch:SearchRequest xmlns:sch="http://www.invito.ru/ws/schemas" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.invito.ru/ws/schemas test.xsd">
        <sch:criteria>
            <sch:startCity code="3" />
            <sch:targetCountry code="3" />
            <sch:targetCities>
                <sch:city code="3" />
            </sch:targetCities>
            <sch:hotelCategories>
                <sch:hotelCategory code="3" />
            </sch:hotelCategories>
            <sch:hotels>
                <sch:hotel code="3" />
            </sch:hotels>
            <sch:accomodationType code="3" />
            <sch:duration>3</sch:duration>
            <sch:tourType code="3" />
            <sch:transport>
                <sch:transportType code="0" />
                <sch:details xsi:type="sch:Flight">
                    <sch:commonTransportInfo>String</sch:commonTransportInfo>
                    <sch:airline code="0" />
                    <sch:departureAirports>
                        <sch:airport code="0" />
                    </sch:departureAirports>
                </sch:details>
            </sch:transport>
            <sch:tourStartDateRange>
                <sch:dateFrom>2014-06-09+04:00</sch:dateFrom>
                <sch:dateTo>2008-11-15</sch:dateTo>
            </sch:tourStartDateRange>
            <sch:tourEndDateRange>
                <sch:dateFrom>2017-05-15</sch:dateFrom>
                <sch:dateTo>2013-12-21+03:00</sch:dateTo>
            </sch:tourEndDateRange>
            <sch:roomTypes>
                <sch:roomType code="3" />
            </sch:roomTypes>
            <sch:operators>
                <sch:operator code="3" />
            </sch:operators>
            <sch:roomFeatures>
                <sch:roomFeature code="3" />
            </sch:roomFeatures>
            <sch:buildingTypes>
                <sch:buildingType code="3" />
            </sch:buildingTypes>
            <sch:spo>
                <sch:spo code="3" />
            </sch:spo>
            <sch:currency code="3" />
            <sch:typeQuantity>byRoom</sch:typeQuantity>
        </sch:criteria>
    </sch:SearchRequest>

    How to explain that?

    Why does native jdk's parser validates the doc (via command) while the same doc is handed to the parser via http (web service) it's not valid?


    2mdeinum: thanx for replies, but could you please guide me how to check loaded jars to make sure which versions of parser are on classpath when i'm running jetty with "mvn jetty:run" or tomcat with startup.bat?

  6. #6
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Quote Originally Posted by exgorth View Post
    Why does native jdk's parser validates the doc (via command) while the same doc is handed to the parser via http (web service) it's not valid?
    Well, Xerces 2.8.1 is a lot more recent than whatever is in the JDK. What you could do is run your command with Xerces 2.8.1 on the classpath, and see how that works.

    This is on JDK 1.5, I presume? JDK 1.4 has major issues with JAXP.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  7. #7

    Default

    This discussion was completed on this branch

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •