At my work I have to maintain some web applications written by a previous developer and I recently have to upgrade Struts from the version 2.1.6 to 2.3.32
The update goes mostly well, the only real change I had to make in the application was changing the old
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
to
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
in web.xml, but now the problem is that every drop down list populated by the application just fail with the sames Exception like theses ones:
mars 23, 2017 8:14:03 AM org.apache.catalina.core.ApplicationDispatcher invoke
GRAVE: "Servlet.service()" pour la servlet jsp a lancé une exception
tag 'select', field 'list', name 'QUALITE': The requested list key 'liste_Qualite' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
at org.apache.struts2.components.Component.fieldError(Component.java:263)
at org.apache.struts2.components.Component.findValue(Component.java:356)
at org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:82)
at org.apache.struts2.components.Select.evaluateExtraParams(Select.java:105)
at org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:893)
at org.apache.struts2.components.UIBean.end(UIBean.java:535)
at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
...
mars 23, 2017 8:14:03 AM org.apache.struts2.dispatcher.DefaultDispatcherErrorHandler error
GRAVE: Exception occurred during processing request: tag 'select', field 'list', name 'QUALITE': The requested list key 'liste_Qualite' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
org.apache.jasper.JasperException: tag 'select', field 'list', name 'QUALITE': The requested list key 'liste_Qualite' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:538)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:430)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
...
mars 23, 2017 8:14:03 AM org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: "Servlet.service()" pour la servlet default a généré une exception
java.lang.IllegalStateException
at org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:407)
at org.apache.struts2.dispatcher.DefaultDispatcherErrorHandler.sendErrorResponse(DefaultDispatcherErrorHandler.java:80)
at org.apache.struts2.dispatcher.DefaultDispatcherErrorHandler.handleError(DefaultDispatcherErrorHandler.java:59)
at org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:920)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:587)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
...
The last Exception make me think the problem come from the change of filter in web.xml since the rest of the application have not been modified. But after one day of searching I can't seem to find what to do to make the application work again.
The Map are set initialized and filled in this file:
public class OrdreMissionAction_ext extends ActionSupport {
...
Map<String,String> liste_Qualite = new HashMap<String,String>();
public Map<String,String> getliste_Qualite() {
return liste_Qualite;
}
...
public String init_om() throws NamingException, IOException{
liste_Qualite = new LinkedHashMap<String,String>();
liste_Qualite.put("IAT","Personnel IATSS");
liste_Qualite.put("PSD","Personnel uB Postdoctorant");
liste_Qualite.put("ENS","Personnel uB Ens/Chercheur");
....
return SUCCESS;
}
...
}
Declared in struts.xml that way:
<package name="actions_ext" namespace="/gom_ext" extends="struts-default">
<default-action-ref name="saisir_Om"></default-action-ref>
<action name="saisir_Om" class="beansActions.OrdreMissionAction_ext" method="init_om">
<interceptor-ref name="StackForms"/>
<result name="success">/WEB-INF/gom_ext/saisir_Om.jsp</result>
</action>
...
</package>
And call in the jsp with this sort of line:
<s:select label="Choisissez une qualité" headerKey="" headerValue="Choisissez une qualité" list="liste_Qualite" name="QUALITE" id="QUALITE" tabindex="3" onchange="Collab_ext(this.value)"/>
After looking at a countless number of examples and questions asked here I did not see any errors in theses declarations and I still don't have figured out how to fix it yet. Have you some idea about what goes wrong?
The page is called via it's action http://example.com/gom_ext/saisir_Om so the init_om() function is called and the Map filled.
Before the Exceptions happens, the application start to be sent to the browser and if I remove the selects, the pages seem to work correctly out of that. It seem that's the only problem is just the jsp that don't success to retrieve the differents lists.