问题
I am newbie to OSGi and working on some java application with eclipse and need to use XSLT processor. I need to use Saxon processor. I have included it's dependency in OSGi bundle classpath and MANIFEST.MF like below:
but I am getting following error:
c.p.s.x.SchematronProviderXSLTFromSCH - Schematron preprocessor error
java.lang.ExceptionInInitializerError: null
at com.phloc.schematron.xslt.SchematronProviderXSLTFromSCH.<init>(SchematronProviderXSLTFromSCH.java:121) ~[phloc-schematron-2.7.1.jar:2.7.1]
at com.phloc.schematron.xslt.SchematronResourceSCHCache.createSchematronXSLTProvider(SchematronResourceSCHCache.java:115) [phloc-schematron-2.7.1.jar:2.7.1]
at com.phloc.schematron.xslt.SchematronResourceSCHCache.getSchematronXSLTProvider(SchematronResourceSCHCache.java:192) [phloc-schematron-2.7.1.jar:2.7.1]
at com.phloc.schematron.xslt.SchematronResourceSCH.<init>(SchematronResourceSCH.java:181) [phloc-schematron-2.7.1.jar:2.7.1]
at com.phloc.schematron.xslt.SchematronResourceSCH.<init>(SchematronResourceSCH.java:139) [phloc-schematron-2.7.1.jar:2.7.1]
at com.phloc.schematron.xslt.SchematronResourceSCH.<init>(SchematronResourceSCH.java:49) [phloc-schematron-2.7.1.jar:2.7.1]
at com.phloc.schematron.xslt.SchematronResourceSCH.fromClassPath(SchematronResourceSCH.java:202) [phloc-schematron-2.7.1.jar:2.7.1]
at ca.uhn.fhir.validation.schematron.SchematronBaseValidator.getSchematronAndCache(SchematronBaseValidator.java:147) [hapi-fhir-base-3.3.0.jar:na]
at ca.uhn.fhir.validation.schematron.SchematronBaseValidator.getSchematron(SchematronBaseValidator.java:125) [hapi-fhir-base-3.3.0.jar:na]
at ca.uhn.fhir.validation.schematron.SchematronBaseValidator.validateResource(SchematronBaseValidator.java:70) [hapi-fhir-base-3.3.0.jar:na]
at ca.uhn.fhir.validation.FhirValidator.validateWithResult(FhirValidator.java:209) [hapi-fhir-base-3.3.0.jar:na]
at com.project.bw.palette.fhir.runtime.validator.helper.ResourceValidatorHelper.performValidation(ResourceValidatorHelper.java:175) [com.project.bw.palette.fhir.runtime/:na]
at com.project.bw.palette.fhir.runtime.validator.helper.ResourceValidatorHelper.resourceValidation(ResourceValidatorHelper.java:110) [com.project.bw.palette.fhir.runtime/:na]
at com.project.bw.palette.fhir.runtime.validator.FhirValidatorActivity.execute(FhirValidatorActivity.java:59) [com.project.bw.palette.fhir.runtime/:na]
at com.project.bw.core.runtime.bx.BWBxActivityBridgeImpl.doEval(BWBxActivityBridgeImpl.java:833) [com.project.bw.core.runtime_6.3.802.001.jar:na]
at com.project.bw.core.runtime.bx.BWBxActivityBridgeImpl.eval(BWBxActivityBridgeImpl.java:695) [com.project.bw.core.runtime_6.3.802.001.jar:na]
at com.project.bx.core.behaviors.activity.BxExtensionBehavior.doEval(BxExtensionBehavior.java:162) [com.project.bx.core_2.1.206.004.jar:na]
at com.project.bx.core.behaviors.activity.BxActivityBaseBehavior.eval(BxActivityBaseBehavior.java:817) [com.project.bx.core_2.1.206.004.jar:na]
at com.project.bx.core.behaviors.activity.BxActivityBaseBehavior.eval(BxActivityBaseBehavior.java:1) [com.project.bx.core_2.1.206.004.jar:na]
at com.project.pvm.infra.api.impl.util.director.IpmEventDirectorBase.handleModelEvent(IpmEventDirectorBase.java:195) [com.project.pvm.core.infra_4.1.202.001.jar:na]
at com.project.pvm.infra.api.impl.util.director.IpmEventDirectorBase.handleEvent(IpmEventDirectorBase.java:111) [com.project.pvm.core.infra_4.1.202.001.jar:na]
at com.project.pvm.infra.support.work.impl.WorkItemAbstract.execute(WorkItemAbstract.java:177) [com.project.pvm.core.infra_4.1.202.001.jar:na]
at com.project.pvm.im.rt.xm.util.work.ImxSTWorkRunnable.doWorkBlock(ImxSTWorkRunnable.java:170) [com.project.pvm.im.rt.xm_4.1.200.004.jar:na]
at com.project.pvm.infra.services.engine.impl.STWorkRunnable.run(STWorkRunnable.java:50) [com.project.pvm.core.infra_4.1.202.001.jar:na]
at com.project.pvm.im.rt.xm.util.work.ImxSTWorkRunnable.run(ImxSTWorkRunnable.java:62) [com.project.pvm.im.rt.xm_4.1.200.004.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_121]
at java.lang.Thread.run(Unknown Source) [na:1.8.0_121]
Caused by: com.phloc.commons.exceptions.InitializationException: Failed to create XML TransformerFactory
at com.phloc.commons.xml.transform.XMLTransformerFactory.createTransformerFactory(XMLTransformerFactory.java:80) ~[phloc-commons-4.3.3.jar:4.3.3]
at com.phloc.commons.xml.transform.XMLTransformerFactory.<clinit>(XMLTransformerFactory.java:54) ~[phloc-commons-4.3.3.jar:4.3.3]
... 28 common frames omitted
Caused by: javax.xml.transform.TransformerFactoryConfigurationError: Provider net.sf.saxon.TransformerFactoryImpl not found
at javax.xml.transform.FactoryFinder.newInstance(Unknown Source) ~[na:1.8.0_121]
at javax.xml.transform.FactoryFinder.find(Unknown Source) ~[na:1.8.0_121]
at javax.xml.transform.TransformerFactory.newInstance(Unknown Source) ~[na:1.8.0_121]
at com.phloc.commons.xml.transform.XMLTransformerFactory.createTransformerFactory(XMLTransformerFactory.java:71) ~[phloc-commons-4.3.3.jar:4.3.3]
... 29 common frames omitted
Caused by: java.lang.ClassNotFoundException: net/sf/saxon/TransformerFactoryImpl
at java.lang.Class.forName0(Native Method) ~[na:1.8.0_121]
at java.lang.Class.forName(Unknown Source) ~[na:1.8.0_121]
at javax.xml.transform.FactoryFinder.getProviderClass(Unknown Source) ~[na:1.8.0_121]
... 33 common frames omitted
Can anyone help me here?
Regards, Amit.
回答1:
You are probably initializing your transformer factory as:
TransformerFactory fact = TransformerFactory.newInstance();
which uses service loading mechanisms that are not compatible with OSGi.
Try using:
TransformerFactory fact = new net.sf.saxon.TransformerFactoryImpl();
来源:https://stackoverflow.com/questions/51687871/unable-to-force-eclipse-to-use-saxon-xslt-processor