无法通过Hibernate 5.2.2升级在Websphere Application Server中实例化javax.xml.parsers.DocumentBuilderFactory

时间:2019-01-09 09:09:10

标签: hibernate websphere

将Hibernate 4.2升级到Hibernate 5.2版本

在以Websphere 8.5.5.13版本部署应用程序时,抛出以下错误

  

00000001 ContainerHelp E WSVR0501E:创建组件时出错   com.ibm.ws.runtime.component.CompositionUnitMgrImpl@b9dc2b3a   com.ibm.ws.exception.RuntimeWarning:   com.ibm.ws.exception.RuntimeError:com.ibm.ws.exception.RuntimeError:   java.lang.RuntimeException:   javax.xml.parsers.FactoryConfigurationError:提供程序   无法实例化javax.xml.parsers.DocumentBuilderFactory:   java.util.ServiceConfigurationError:   javax.xml.parsers.DocumentBuilderFactory:提供者   org.apache.xerces.jaxp.DocumentBuilderFactoryImpl不是位于的子类型   com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCUList(CompositionUnitMgrImpl.java:1303)     在   com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:275)

我尝试了删除xml-api jar和maven排除

         <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>${hibernate-core.version}</version>
            <exclusions>
                <exclusion>
                <groupId>xml-apis</groupId>
                <artifactId>xml-apis</artifactId>
                </exclusion>
            </exclusions>
        </dependency> 

但是,在不做任何更改的情况下,在Tomcat 9中成功部署了Web应用程序。

堆栈跟踪:

00000001 ContainerHelp E   WSVR0501E: Error creating component com.ibm.ws.runtime.component.CompositionUnitMgrImpl@b9dc2b3a
com.ibm.ws.exception.RuntimeWarning: com.ibm.ws.exception.RuntimeError: com.ibm.ws.exception.RuntimeError: java.lang.RuntimeException: javax.xml.parsers.FactoryConfigurationError: Provider javax.xml.parsers.DocumentBuilderFactory could not be instantiated: java.util.ServiceConfigurationError: javax.xml.parsers.DocumentBuilderFactory: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not a subtype
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCUList(CompositionUnitMgrImpl.java:1303)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:275)
    at com.ibm.ws.runtime.component.ContainerHelper.startComponents(ContainerHelper.java:540)
    at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:627)
    at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:618)
    at com.ibm.ws.runtime.component.ApplicationServerImpl.start(ApplicationServerImpl.java:252)
    at com.ibm.ws.runtime.component.ContainerHelper.startComponents(ContainerHelper.java:540)
    at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:627)
    at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:618)
    at com.ibm.ws.runtime.component.ServerImpl.start(ServerImpl.java:540)
    at com.ibm.ws.runtime.WsServerImpl.bootServerContainer(WsServerImpl.java:316)
    at com.ibm.ws.runtime.WsServerImpl.start(WsServerImpl.java:229)
    at com.ibm.ws.runtime.WsServerImpl.main(WsServerImpl.java:702)
    at com.ibm.ws.runtime.WsServer.main(WsServer.java:59)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
    at java.lang.reflect.Method.invoke(Method.java:508)
    at com.ibm.wsspi.bootstrap.WSLauncher.launchMain(WSLauncher.java:234)
    at com.ibm.wsspi.bootstrap.WSLauncher.main(WSLauncher.java:96)
    at com.ibm.wsspi.bootstrap.WSLauncher.run(WSLauncher.java:77)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
    at java.lang.reflect.Method.invoke(Method.java:508)
    at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
    at java.lang.reflect.Method.invoke(Method.java:508)
    at org.eclipse.core.launcher.Main.invokeFramework(Main.java:340)
    at org.eclipse.core.launcher.Main.basicRun(Main.java:282)
    at org.eclipse.core.launcher.Main.run(Main.java:981)
    at com.ibm.wsspi.bootstrap.WSPreLauncher.launchEclipse(WSPreLauncher.java:407)
    at com.ibm.wsspi.bootstrap.WSPreLauncher.main(WSPreLauncher.java:170)
Caused by: com.ibm.ws.exception.RuntimeError: com.ibm.ws.exception.RuntimeError: java.lang.RuntimeException: javax.xml.parsers.FactoryConfigurationError: Provider javax.xml.parsers.DocumentBuilderFactory could not be instantiated: java.util.ServiceConfigurationError: javax.xml.parsers.DocumentBuilderFactory: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not a subtype
    at com.ibm.wsspi.runtime.component.WsComponentImpl.join(WsComponentImpl.java:436)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCUList(CompositionUnitMgrImpl.java:1295)
    ... 39 more
Caused by: com.ibm.ws.exception.RuntimeError: java.lang.RuntimeException: javax.xml.parsers.FactoryConfigurationError: Provider javax.xml.parsers.DocumentBuilderFactory could not be instantiated: java.util.ServiceConfigurationError: javax.xml.parsers.DocumentBuilderFactory: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not a subtype
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:818)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl$5.run(ApplicationMgrImpl.java:2279)
    at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5554)
    at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5680)
    at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2284)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:436)
    at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:379)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$500(CompositionUnitMgrImpl.java:127)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:985)
    at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:524)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1892)
Caused by: java.lang.RuntimeException: javax.xml.parsers.FactoryConfigurationError: Provider javax.xml.parsers.DocumentBuilderFactory could not be instantiated: java.util.ServiceConfigurationError: javax.xml.parsers.DocumentBuilderFactory: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not a subtype
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:1063)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:795)
    ... 12 more
Caused by: javax.xml.parsers.FactoryConfigurationError: Provider javax.xml.parsers.DocumentBuilderFactory could not be instantiated: java.util.ServiceConfigurationError: javax.xml.parsers.DocumentBuilderFactory: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not a subtype
    at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source)
    at com.ibm.ws.webservices.engine.utils.XMLUtils.getDocumentBuilderFactory(XMLUtils.java:460)
    at com.ibm.ws.webservices.engine.utils.XMLUtils.newDocument(XMLUtils.java:539)
    at com.ibm.ws.webservices.engine.utils.XMLUtils.newDocument(XMLUtils.java:557)
    at com.ibm.ws.webservices.engine.encoding.custom.Utils.loadCustomProviders(Utils.java:267)
    at com.ibm.ws.webservices.tools.resource.ToolEnv$3.run(ToolEnv.java:332)
    at java.security.AccessController.doPrivileged(AccessController.java:638)
    at com.ibm.ws.webservices.tools.resource.ToolEnv.loadCustomProviders(ToolEnv.java:329)
    at com.ibm.ws.webservices.tools.resource.ToolEnv.getCustomBindingProviders(ToolEnv.java:324)
    at com.ibm.ws.webservices.wsdl.toJava.Emitter.initCustomBindingRegistry(Emitter.java:972)
    at com.ibm.ws.webservices.wsdl.toJava.Emitter.setup(Emitter.java:959)
    at com.ibm.ws.webservices.wsdl.Parser.parse(Parser.java:326)
    at com.ibm.ws.webservices.wsdl.Parser.run(Parser.java:313)
    at com.ibm.ws.webservices.tools.WSDLQuery.parse(WSDLQuery.java:142)
    at com.ibm.ws.webservices.engine.deployment.wsdd.WSDDGen.getWSDLQuery(WSDDGen.java:214)
    at com.ibm.ws.webservices.engine.deployment.wsdd.WSDDPort.expand(WSDDPort.java:554)
    at com.ibm.ws.webservices.engine.deployment.wsdd.WSDDPort._initTMR(WSDDPort.java:311)
    at com.ibm.ws.webservices.component.WSServerImpl.setupWsddPort(WSServerImpl.java:1264)
    at com.ibm.ws.webservices.component.WSServerImpl.warMetaDataCreated(WSServerImpl.java:2151)
    at com.ibm.ws.webservices.component.WSServerImpl.metaDataCreated(WSServerImpl.java:639)
    at com.ibm.ws.runtime.component.MetaDataMgrImpl.fireMetaDataCreated(MetaDataMgrImpl.java:279)
    at com.ibm.ws.runtime.component.MetaDataMgrImpl.fireMetaDataCreated(MetaDataMgrImpl.java:262)
    at com.ibm.ws.webcontainer.metadata.WebMetaDataFactory.createMetaData(WebMetaDataFactory.java:244)
    at com.ibm.ws.runtime.component.MetaDataMgrImpl.createMetaDataFromFactories(MetaDataMgrImpl.java:228)
    at com.ibm.ws.runtime.component.MetaDataMgrImpl.createMetaData(MetaDataMgrImpl.java:411)
    at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:631)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:979)

1 个答案:

答案 0 :(得分:0)

服务器级加载器和“父最后”应用程序类加载器之间似乎存在交叉链接。服务器级(实际上,更可能是Java级)加载器加载DocumentBuilderFactory API类,然后该类转到线程上下文类加载器以查找其实现。线程上下文类加载器是最后一个父级应用程序加载器,它不会立即委派给其父级,因此它在此处找到实现,并进而链接到应用程序的API类副本。原始API类(来自Java)和“新” API类(来自应用程序)无法相互转换,因为它们来自不同的类加载器,并且操作失败。

就实际解决而言:

1)您有99.9%的机会不需要携带自己的JAXP版本,该版本已经很长时间包含在JDK中了(看来您正在打包Xerces,该版本包含在其中) IBM Java)。删除它将消除该异常。同样,您可以通过切换到“父级”类加载器委派来解决此问题-如果您不需要自己重写服务器API,则可以大大降低发生此类问题的风险。

2)也就是说,您不必删除它,因为服务器通常允许应用程序携带自己的解析器。该异常堆栈意味着某些WebSphere代码在创建XML对象时可能无法正确地保护其线程上下文,您可能需要打开支持通知单并让IBM验证此处是否存在实际的错误。