Fix #100 - HAPI failed to initialize in an environment without Woodstox
on the classpath. Will deploy a new snapshot shortly.
This commit is contained in:
parent
a474870a1e
commit
37e2abb4e2
|
@ -210,11 +210,15 @@ public class XmlUtil {
|
|||
* Note that these properties are Woodstox specific and they cause a crash in environments where SJSXP is
|
||||
* being used (e.g. glassfish) so we don't set them there.
|
||||
*/
|
||||
|
||||
try {
|
||||
Class.forName("com.ctc.wstx.stax.WstxOutputFactory");
|
||||
if (inputFactory instanceof com.ctc.wstx.stax.WstxInputFactory) {
|
||||
// inputFactory.setProperty(WstxInputFactory.IS_REPLACING_ENTITY_REFERENCES, false);
|
||||
inputFactory.setProperty(WstxInputProperties.P_UNDECLARED_ENTITY_RESOLVER, XML_RESOLVER);
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
ourLog.debug("WstxOutputFactory (Woodstox) not found on classpath");
|
||||
}
|
||||
ourInputFactory = inputFactory;
|
||||
}
|
||||
return ourInputFactory;
|
||||
|
@ -317,9 +321,14 @@ public class XmlUtil {
|
|||
* Note that these properties are Woodstox specific and they cause a crash in environments where SJSXP is
|
||||
* being used (e.g. glassfish) so we don't set them there.
|
||||
*/
|
||||
try {
|
||||
Class.forName("com.ctc.wstx.stax.WstxOutputFactory");
|
||||
if (outputFactory instanceof WstxOutputFactory) {
|
||||
outputFactory.setProperty(XMLOutputFactory2.P_TEXT_ESCAPER, new MyEscaper());
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
ourLog.debug("WstxOutputFactory (Woodstox) not found on classpath");
|
||||
}
|
||||
ourOutputFactory = outputFactory;
|
||||
}
|
||||
return ourOutputFactory;
|
||||
|
|
|
@ -41,17 +41,43 @@
|
|||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-base</artifactId>
|
||||
<version>0.9-SNAPSHOT</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>woodstox-core-asl</artifactId>
|
||||
<groupId>org.codehaus.woodstox</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu</artifactId>
|
||||
<version>0.9-SNAPSHOT</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>woodstox-core-asl</artifactId>
|
||||
<groupId>org.codehaus.woodstox</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dev</artifactId>
|
||||
<version>0.9-SNAPSHOT</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>woodstox-core-asl</artifactId>
|
||||
<groupId>org.codehaus.woodstox</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>java-hamcrest</artifactId>
|
||||
<version>${hamcrest_version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package ca.uhn.fhir.parser;
|
|||
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -23,11 +24,13 @@ public class MultiVersionXmlParserTest {
|
|||
String str;
|
||||
str = FhirContext.forDstu1().newXmlParser().encodeResourceToString(p);
|
||||
ourLog.info(str);
|
||||
assertThat(str,StringContains.containsString("<extension url=\"http://foo#ext\"><valueQuantity><value value=\"2.2\"/><comparator value=\"<\"/><units value=\"g/L\"/></valueQuantity></extension>"));
|
||||
assertThat(str, Matchers.stringContainsInOrder("<extension url=\"http://foo#ext\"><valueQuantity><value value=\"2.2\"", "<comparator value=\"<\"", "<units value=\"g/L\"",
|
||||
"</valueQuantity></extension>"));
|
||||
|
||||
str = FhirContext.forDev().newXmlParser().encodeResourceToString(p);
|
||||
ourLog.info(str);
|
||||
assertThat(str,StringContains.containsString("<extension url=\"http://foo#ext\"><valueQuantity><value value=\"2.2\"/><comparator value=\"<\"/><units value=\"g/L\"/></valueQuantity></extension>"));
|
||||
assertThat(str, Matchers.stringContainsInOrder("<extension url=\"http://foo#ext\"><valueQuantity><value value=\"2.2\"", "<comparator value=\"<\"", "<units value=\"g/L\"",
|
||||
"</valueQuantity></extension>"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package ca.uhn.fhir.testmindeps;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class SetupTest {
|
||||
|
||||
/**
|
||||
* Ensure that Woodstox is not on the classpath (we're testing that the library works ok without it
|
||||
* elsewhere)
|
||||
*/
|
||||
@Test(expected=ClassNotFoundException.class)
|
||||
public void testValidateEnvironment() throws ClassNotFoundException {
|
||||
Class.forName("com.ctc.wstx.stax.WstxOutputFactory");
|
||||
}
|
||||
|
||||
}
|
|
@ -118,7 +118,7 @@ public class TinderJpaRestServerMojo extends AbstractMojo {
|
|||
throw new MojoFailureException("Failed to generate server", e);
|
||||
}
|
||||
|
||||
myProject.addCompileSourceRoot(directoryBase.getAbsolutePath());
|
||||
myProject.addCompileSourceRoot(targetDirectory.getAbsolutePath());
|
||||
|
||||
try {
|
||||
VelocityContext ctx = new VelocityContext();
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -123,6 +123,10 @@
|
|||
<id>twilson650</id>
|
||||
<name>Tom Wilson</name>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>sweetnavelorange</id>
|
||||
<name>James Butler</name>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<licenses>
|
||||
|
|
|
@ -96,6 +96,11 @@
|
|||
DateClientParam#second() incorrectly used DAY precision instead
|
||||
of SECOND precision. Thanks to Tom Wilson for the pull request!
|
||||
</action>
|
||||
<action type="fix" issue="100" due-to="sweetnavelorange">
|
||||
Fix issue where HAPI failed to initialize correctly if Woodstox library was not on the classpath, even
|
||||
if StAX API was configured to use a different provider. Thanks to
|
||||
James Butler for reporting and figuring out where the issue was!
|
||||
</action>
|
||||
</release>
|
||||
<release version="0.8" date="2014-Dec-17">
|
||||
<action type="add">
|
||||
|
|
Loading…
Reference in New Issue