Closed kr1zz closed 5 years ago
I cannot reproduce this. Can you provide more information about how you run the example? E.g. from an IDE like eclipse or from the command line?
I use eclipse.
It keeps throwing the same exception. However, I tried starting a new Maven project from scratch, and it works smoothly. I wonder if it is a configuration issue.
Please find below the pom.xml
for the new small project, whereas here is the one from the project I was working on.
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>kr1zzTmpTests</groupId>
<artifactId>kr1zzPreliminaryTests</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Preliminary Tests</name>
<dependencies>
<dependency>
<groupId>org.n52.geoprocessing</groupId>
<artifactId>wps-client-lib</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>n52-releases</id>
<name>52n Releases</name>
<url>http://52north.org/maven/repo/releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>
This is a dependency issue. The client example will work, if you add this line to the code (e.g. in as first statement in the main method):
System.setProperty("javax.xml.stream.XMLOutputFactory", "com.sun.xml.internal.stream.XMLOutputFactoryImpl");
For further explanation, you could look at the javadoc of the javax.xml.stream.XMLOutputFactory.newFactory()-method.
Great, it worked! :-) 🥇
For the sake of getting better at spotting issues, what line of reasoning allowed you to detect it?
Well, this needed some debugging. I looked at the method org.n52.iceland.util.XmlFactories.createOutputFactory() In this method, a new XMLOutputFactory is created via XMLOutputFactory.newFactory(). The newFactory()-method has different ways to find a matching factory class. The first way is to look for a specific system property. So I simply used this to solve the issue.
Some more background: In your project, you have a woodstox dependency that has the WstxOutputFactory class. I didn't thoroughly check why, but this class is found and used by the newFactory()-method I mentioned above. I checked what factory was found and used when the client example worked and this was com.sun.xml.internal.stream.XMLOutputFactoryImpl. So, I used this for the value of the javax.xml.stream.XMLOutputFactor system property.
I tried running the example, but it stopped early when parsing the response to
GetCapabilities
, with the following exception:I tried also different WPS providers and changing the version from
2.0.0
to1.0.0
but it doesn't seem to affect the issue.I tried it on a machine running Windows 10 Enterprise