1

I'm trying to deploy a WebSphere Liberty Application via Docker. I'm also using Apache Struts for the UI. When deploying on my local machine I have no problems, but when put on seemingly any other machine, it throws an error saying the struts2 filter cannot be loaded. Classes do not seem to be missing.

Why would this container work on one machine and not another?

Stack Trace:

[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
rickrizzo
  • 422
  • 4
  • 12
  • Possible duplicate of [SEVERE: Exception starting filter struts2 java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.FilterDispatcher](https://stackoverflow.com/questions/5256939/severe-exception-starting-filter-struts2-java-lang-classnotfoundexception-org) – Matt Clark Jul 27 '17 at 20:56

2 Answers2

1

Caused by: javax.xml.parsers.ParserConfigurationException: AElfred parser is non-validating

The struts2 requires to have a validating parser. Since this parser is non-validating it should be removed from the classpath.

The affected parser could be found in saxon.jar.

Roman C
  • 49,761
  • 33
  • 66
  • 176
  • That did the trick! Updated the JAR with a more recent version and my problem was solved. Thank you so much! – rickrizzo Jul 28 '17 at 15:19
  • Update: This did work, but I also found that as I updated the JAR to a newer version I also had to add some other jars. Specifically, saxon-dom-8.jar and jaxp-api-1.4.2.jar. Before adding these I got errors regarding an Illegal Argument Exception. YMMV on the versions, but you need those jars to handle dom components – rickrizzo Jul 28 '17 at 18:55
  • Update: My initial thoughts were wrong. Updating the parser worked briefly, but later broke. I answered the question with my findings. – rickrizzo Aug 09 '17 at 20:24
0

Thanks to Roman I was able to diagnose this problem more correctly as a saxon XML parser issue. I tried just replacing my JAR and this actually worked for a few tests but later broke.

This forum post ultimately solved the problem: http://grokbase.com/t/tomcat/users/031xc9jye7/i-cant-use-saxon-xml-parser-in-my-web-app-please-help

My web server (WebSphere Liberty) was trying to use Saxon as the XML parser, however Saxon is non-validating and thus this was failing, particularly in Docker where I was trying this.

To fix this I had to remove the file javax.xml.parsers.SAXParserFactory from the JAR and then the server ran correctly.

rickrizzo
  • 422
  • 4
  • 12