在WebSphere Application Server 7.x的类加载器问题(Classload

2019-09-21 11:47发布

com.ibm.xml.xlxp2.api.stax.XMLOutputFactoryImpl与javax.xml.stream.XMLOutputFactory不兼容

com.ibm.xml.xlxp2.api.stax.XMLOutputFactoryImpl与javax.xml.stream.XMLInputFactory不兼容

删除 “jsr173_1.0_api.jar”, “STAX-API 1.0-2.jar” 有从APP(WEB-INF / lib目录) “XMLOutputFactory” 和 “的XMLInputFactory” 类,以避免与服务器版本的任何冲突。

也改变了战争类加载器以“父最后”,并在WebSphere管理控制台政策“单类加载器的应用程序”。 做了这些改变,优先申请罐子WebInf/lib高于服务器的罐子。

下面是堆栈跟踪。

java.lang.ClassCastException: com.ibm.xml.xlxp2.api.stax.XMLOutputFactoryImpl incompatible with javax.xml.stream.XMLOutputFactory
                                 javax.faces.FacesException: #{tBean.persist}: java.lang.ClassCastException: com.ibm.xml.xlxp2.api.stax.XMLOutputFactoryImpl incompatible with javax.xml.stream.XMLOutputFactory
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1655)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1595)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:131)
    at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
    at com.testtech.myapp.admin.authentication.UrlAuthorization.doFilter(Unknown Source)
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
    at com.testtech.myapp.admin.authentication.UrlAuthentication.doFilter(Unknown Source)
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:114)
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:77)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:895)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:932)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:500)
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
    at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:864)
    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:183)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
    at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)
Caused by: javax.faces.el.EvaluationException: java.lang.ClassCastException: com.ibm.xml.xlxp2.api.stax.XMLOutputFactoryImpl incompatible with javax.xml.stream.XMLOutputFactory
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    ... 42 more
Caused by: java.lang.ClassCastException: com.ibm.xml.xlxp2.api.stax.XMLOutputFactoryImpl incompatible with javax.xml.stream.XMLOutputFactory
    at javax.xml.stream.XMLOutputFactory.newInstance(XMLOutputFactory.java:98)
    at com.thoughtworks.xstream.io.xml.StaxDriver.getOutputFactory(StaxDriver.java:157)
    at com.thoughtworks.xstream.io.xml.StaxDriver.createWriter(StaxDriver.java:109)
    at com.thoughtworks.xstream.XStream.toXML(XStream.java:802)
    at com.thoughtworks.xstream.XStream.toXML(XStream.java:792)
    at com.testtech.UI.z.service.zService.createz(Unknown Source)
    at com.testtech.UI.z.web.zBean.persist(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:600)
    at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
    at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
    ... 43 more

JSF2.1.2
春天3.1.0
Prettyfaces-jsf2-3.3.2
Primefaces 3.2
WebSphere应用服务器7.0.0.9

IBM页面
当故障排除类装入问题,您可能需要重写可见类的父类加载器。 要覆盖这些类与特定于应用程序,设置类装载器模式,家长最后在包含在其类路径的应用程序类的类加载器。 一个应用程序可以覆盖到一个父类加载器可见的类,但这样做可能会导致一个ClassCastException或UnsatisfiedLinkError当有一个混合使用重载类和非重写类。

Answer 1:

您正在使用第三方JSF实现。 作为第一步,我建议您检查您是否已经正确配置它。 这里是信息中心链接, 配置的JavaServer Faces实现 。

基本上,你必须

  • 创建隔离的共享库
  • 把你的JSF库及其依赖于它
  • 与模块关联共享库
  • 设置应用程序类加载政策PARENTLAST


文章来源: Classloader issue in WebSphere Application server 7.x