I recently converted an eclipse Java project into a dynamic web project. The imported jars listed in both the before and after projects are the same, but the change to dynamic web project causes the following compilation error:
W3C_XML_SCHEMA_NS_URI cannot be resolved or is not a field
to be thrown by the following line of code:
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
I have researched this error, and it seems to be thrown by conflicting versions of javax.xml.XMLConstants
in different jars, but I compared the lists of jars in both projects and they are identical, so I think one has to change the order of the jars. How does one do this?
Part of the solution might logically involve figuring out which jars include a package named javax.xml.XMLConstants
. So I followed @DiogoSantana's advice and used the Type wizard to get the results in the following print screen:
I then followed DiogoSantana's advice and ran mvn dependency:tree
and got the following results:
I next made the following change to the pom.xml
:
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.7</version>
<exclusions>
<exclusion>
<groupId>jsr173_api</groupId>
</exclusion>
</exclusions>
</dependency>
And then I ran mvn clean install
before refreshing the eclipse project and even doing maven..update project
from within eclipse, but the error remains.
Note: a search for the string infoset
in the pom
did not produce any results, so I tried the next higher level jar
.