0
votes

I'm using Maven 3.3.3 and maven-jaxb2-plugin version 0.12.1 to generate java classes from XSD schema. The address where the XSD is returns HTTP 302 and the plugin throws:

[ERROR] Error while parsing schema(s).Location [ http://www.gzs.si/e-poslovanje/sheme/eSlog_1-5_EnostavniRacun_signature.xsd{1,30}].
org.xml.sax.SAXParseException; systemId: http://www.gzs.si/e-poslovanje/sheme/eSlog_1-5_EnostavniRacun_signature.xsd; lineNumber: 1; columnNumber: 30; s4s-elt-character: Non-whitespace characters are not allowed in schema elements o
ther than 'xs:appinfo' and 'xs:documentation'. Saw 'Document Moved'.

Is is possible to specify, and how, that the xjc compiler follows 302 to the correct link or not to go and try downloading the XSD?

2
What about surfing up to the XSD with your browser, check where it's redirecting you and update the URL in your POM?Daniel
Hmm, and how do I do that, because now I don't have it in my pom. And besides the XSD has a link to another XSD that also return 302kovica

2 Answers

0
votes

I solved this by using a catalog.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>                                                                                                                                                                                  
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public">                                                                                                                                                           
     <rewriteSystem systemIdStartString="http://www.gzs.si" rewritePrefix="https://www.gzs.si"/>                                                                                                                                        
</catalog>

and then in my pom.xml:

<plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.12.1</version>
                <executions>
                    ...
                </executions>
                <configuration>
                    <strict>false</strict>
                    <catalog>src/main/resources/jaxb/catalog.xml</catalog>
                    <catalogResolver>org.jvnet.jaxb2.maven2.resolver.tools.ClasspathCatalogResolver</catalogResolver>
                    <generateDirectory>${project.build.directory}/generated-sources/xjc</generateDirectory>
                    <verbose>true</verbose>
                </configuration>
            </plugin>
0
votes

Disclaimer: Author of the maven-jaxb2-plugin here.

You're hitting the following problem:

Which is by design.

Your solution with catalogs is the right one. But you most probably don't need ClasspathCatalogResolver.