问题
I have a problem related to HttpServletRequest. Somehow it can not be not passed to the called filter with Forward.
When I try to access the fields on request and the session of the request I get null pointer exception.
Here is the code: As you can see I am printing the content of the session just before forwarding the request. And all the fields that I put in it is there. I see it in logs.
HttpServletRequest reqServ = (HttpServletRequest)request;
Enumeration sessionKeys = reqServ.getSession().getAttributeNames();
while (sessionKeys.hasMoreElements())
{
String key = (String)sessionKeys.nextElement();
System.out.println(key + ": " + reqServ.getSession().getValue(key) + "<br>");
}
request.getRequestDispatcher("/jsp/XXXXX.jsp").forward(request, response);
request in this forward is fully filled and not empty. But the filter which takes affect when /jsp/XXXXX.do is getting a totally empty request object and session containes only a LOCALE param.
Cause of that I can not get the params that I need to use and when I try it gives me a null pointer exception.
Here is struts-config.xml for XXXXX.jsp
<action name="XXXXXFormBean" path="/XXXXX" scope="request" type="com.AAAAAA.service.actions.XXXXXAction"
input="/jsp/XXXXX.jsp">
<forward name="oneself" path="/jsp/XXXXX.jsp"></forward>
<forward name="XXXXX" path="/jsp/XXXXX.jsp"></forward>
</action>
I have searched for such an issue on internet and got nothing.
I am using JBoss EAP 6.4
Struts 1.3.8
Java 1.7
What can I do to solve this issue?
Thank you.
Here is the full error message with trace I got.
14:25:57,414 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/BBBBBBB].[action]] (http-localhost/127.0.0.1:8080-2) JBWEB000236: Servlet.service() for servlet action threw exception: java.lang.NullPointerException
at com.AAAAAA.service.actions.XXXXX.execute(XXXXX.java:75) [classes:]
at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58) [struts-core-1.3.8.jar:1.3.8]
at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67) [struts-core-1.3.8.jar:1.3.8]
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51) [struts-core-1.3.8.jar:1.3.8]
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) [commons-chain-1.1.jar:1.1]
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304) [commons-chain-1.1.jar:1.1]
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) [commons-chain-1.1.jar:1.1]
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283) [struts-core-1.3.8.jar:1.3.8]
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) [struts-core-1.3.8.jar:1.3.8]
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462) [struts-core-1.3.8.jar:1.3.8]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-2.jar:1.0.2.Final-redhat-2]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-2.jar:1.0.2.Final-redhat-2]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
at com.AAAAAA.service.filter.RequestEncodingFilter.doFilter(RequestEncodingFilter.java:41) [classes:]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:150) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:854) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_80]
回答1:
This project was written like 13 years ago and at that time that thought that changing the JSESSIONID manally is a good thing to do in WebSphere and it does not create an issues with that. But with JBoss EAP 6.4 it is creating an issue. I have changed the JSSESIONID code to not changing it and all worked out.
来源:https://stackoverflow.com/questions/56835084/forwarded-request-is-not-passed-and-an-empty-one-is-being-processed-jboss-eap-6