question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting a org.xml.sax.SAXParseException "is already defined"

See original GitHub issue

I am getting the following Exceptions on my *.xsd files: link to error

It says that there is a double definition on line 47, with the first appearance being at line 10.

When looking at the file itself I don’t notice any double names. The line to which the exception occurs contains: <xs:complexType name="AfzenderAdresType"> while the “first definition” contains <xs:complexType name="OntvangerAdresType">. (You can find the file itself here)

The both have similar but different names and their definition is nearly identical. What is going on here? Any help as to how I can fix this?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
bukocommented, Aug 8, 2017

BTW this happens when the same schema is being compiled twice. For example, xsd:imports and schemas and episodes defined in the pom.xml. It’s very confusing. I spent quite a while figuring out how to do modular schema builds with the plugin that don’t produce errors like that. Work is documented in https://github.com/bubblegumproject/scrum4j-model

0reactions
maffecommented, Jan 8, 2020

I got the same exception with these two XSD files:

It worked after I added a unique targetNamespace to each of the XSD files. This doesn’t appear to change the generated Java files in any way.

Update: adding namespaces to the XSD files will cause package-info.java with namespace information to be generated. I use the maven-clean-plugin to remove those files because in my case the generated XML must not use namespaces:

<plugin>
    <artifactId>maven-clean-plugin</artifactId>
    <version>3.1.0</version>
    <executions>
        <execution>
            <id>remove-namespaces</id>
            <phase>process-sources</phase>
            <goals>
                <goal>clean</goal>
            </goals>
            <configuration>
                <excludeDefaultDirectories>true</excludeDefaultDirectories>
                <verbose>true</verbose>
                <filesets>
                    <fileset>
                        <directory>${project.build.directory}/generated-sources/xjc</directory>
                        <includes>
                            <include>**/package-info.java</include>
                        </includes>
                        <followSymlinks>false</followSymlinks>
                    </fileset>
                </filesets>
            </configuration>
        </execution>
    </executions>
</plugin>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Generating JAXB class from XSDs with similar attribute names
Creating an XML element with xsi:nil and attributes in .Net/Jaxb. 0. XML XSD Error : org.xml.sax.SAXParseException: s4s-elt-schema-ns: The ...
Read more >
(MJAXB-31) jaxb2:xjc throws "org.xml.sax.SAXParseException
jaxb2:xjc throws "org.xml.sax.SAXParseException: 'xyz' is already defined" on schema files located in directories with embedded tilde character
Read more >
trying to use seperate schema compilation using maven-jaxb2 ...
sax.SAXParseException: 'address' is already defined'. Hopes this helps. I think Manual is right about the internal map with namespaces of
Read more >
Mapping between Java language, WSDL and XML for JAX ...
ns, user-defined namespace. apache, http://xml.apache.org/xml-soap ... Not all Java classes and constructs have mappings to WSDL files.
Read more >
JAXB Users Guide - Java EE
[ERROR] Property "MiOrMoOrMn" is already defined. line 132 of ... SYSTEM "http://www.w3.org/2001/xml.xsd" "xml.xsd" PUBLIC "-//W3C//DTD XMLSCHEMA ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found