我正在尝试通过Docker部署WebSphere Liberty Application。我也在使用Apache Struts作为UI。在我的本地机器上部署时我没有问题,但是当看似任何其他机器时,它会抛出错误,说无法加载struts2过滤器。似乎没有丢失类。
为什么这个容器可以在一台机器上工作而不能在另一台机器上工作?
堆栈追踪:
[ERROR ] SRVE0321E: The [struts2] filter did not load during start up.
Filter [struts2]: could not be initialized
[ERROR ] SRVE0315E: An exception occurred: java.lang.Throwable: javax.servlet.ServletException: Filter [struts2]: could not be initialized
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:5027)
at [internal classes]
Caused by: javax.servlet.ServletException: Filter [struts2]: could not be initialized
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.init(FilterInstanceWrapper.java:163)
... 1 more
Caused by: Unable to create SAX parser - Class: com.icl.saxon.aelfred.SAXParserFactoryImpl
File: SAXParserFactoryImpl.java
Method: newSAXParser
Line: 34 - com/icl/saxon/aelfred/SAXParserFactoryImpl.java:34:-1
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:835)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:131)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:100)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:130)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452)
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:201)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.init(FilterInstanceWrapper.java:149)
... 1 more
Caused by: Unable to create SAX parser - Class: com.icl.saxon.aelfred.SAXParserFactoryImpl
File: SAXParserFactoryImpl.java
Method: newSAXParser
Line: 34 - com/icl/saxon/aelfred/SAXParserFactoryImpl.java:34:-1
at com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:111)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:830)
... 9 more
Caused by: javax.xml.parsers.ParserConfigurationException: AElfred parser is non-validating
at com.icl.saxon.aelfred.SAXParserFactoryImpl.newSAXParser(SAXParserFactoryImpl.java:34)
at com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:109)
... 10 more
答案 0 :(得分:1)
引起:javax.xml.parsers.ParserConfigurationException:AElfred解析器无法验证
struts2需要有一个验证解析器。由于此解析器是非验证的,因此应将其从类路径中删除。
可以在saxon.jar
中找到受影响的解析器。
答案 1 :(得分:0)
感谢Roman,我能够更正确地诊断出这个问题,因为它是一个撒克逊XML解析器问题。我试着替换我的JAR,这实际上适用于一些测试,但后来破了。
此论坛帖最终解决了问题:http://grokbase.com/t/tomcat/users/031xc9jye7/i-cant-use-saxon-xml-parser-in-my-web-app-please-help
我的Web服务器(WebSphere Liberty)试图使用Saxon作为XML解析器,但是Saxon是非验证的,因此失败了,特别是在我尝试这个的Docker中。
要解决此问题,我必须从JAR中删除文件javax.xml.parsers.SAXParserFactory
,然后服务器才能正常运行。