From 16a8c6fb04043162a981f6c1ea593de86e2f43cb Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Wed, 30 Mar 2016 11:52:54 +0200 Subject: Fallback to depreceated factory method for Stax in case new method is not found --- .../src/main/java/at/gv/egiz/sl/util/SLMarschaller.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'pdf-as-lib/src/main') diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/SLMarschaller.java b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/SLMarschaller.java index e53fc230..8e84b491 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/SLMarschaller.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/SLMarschaller.java @@ -72,7 +72,13 @@ public class SLMarschaller { } public static Object unmarshal(InputStream is) throws JAXBException { - XMLInputFactory xif = XMLInputFactory.newFactory(); + XMLInputFactory xif = null; + try { + xif = XMLInputFactory.newFactory(); + } catch(java.lang.NoSuchMethodError e) { + // Fallback for old STAX implementations + xif = XMLInputFactory.newInstance(); + } xif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false); xif.setProperty(XMLInputFactory.SUPPORT_DTD, false); XMLStreamReader xmlStreamReader; @@ -87,7 +93,14 @@ public class SLMarschaller { public static Object unmarshalFromString(String message) throws JAXBException { StringReader sr = new StringReader(message); - XMLInputFactory xif = XMLInputFactory.newFactory(); + XMLInputFactory xif = null; + try { + xif = XMLInputFactory.newFactory(); + } catch(java.lang.NoSuchMethodError e) { + // Fallback for old STAX implementations + xif = XMLInputFactory.newInstance(); + } + xif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false); xif.setProperty(XMLInputFactory.SUPPORT_DTD, false); XMLStreamReader xmlStreamReader; -- cgit v1.2.3