gpt4 book ai didi

java - AJAX Servlet 调用非法状态异常

转载 作者:行者123 更新时间:2023-12-01 11:38:36 25 4
gpt4 key购买 nike

我使用 ajax 调用 servlet,并将其部署到 websphere 时出现以下异常。然而它正在我的本地机器上运行。据我了解 document原因是因为我试图访问 response.getWriter()response.getOutputStream() 方法,但事实并非如此,因为我只有 getWriter我的代码中的 方法。

我已经在 stackoverflow 上搜索过之前的问题,但没有帮助。

因此,任何帮助将不胜感激

我的 Servlet 代码

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub

String[] userStates = request.getParameterValues("user");
String r_object_id = request.getParameter("queueId");

boolean isUpdateSuccessfull =false;
response.setContentType("text/html; charset=UTF-8");
response.setCharacterEncoding("UTF-8");

PrintWriter out = response.getWriter();

//ArrayList
//string[0] -> skill_id
//string[1] -> r_object_id
//string[2] -> original_value

ArrayList<String[]> updateList = new ArrayList<String[]>();

for (int i = 0; i < userStates.length; i++) {

String[] update = userStates[i].split("_");
updateList.add(update);
}

try{
DefineSkillSet dss = new DefineSkillSet();
HashMap<String, ArrayList<String>> userSkillMap = new HashMap<String, ArrayList<String>>();

for(String[] status: updateList){

if(status == null && status.length != 2){
// TODO error logging
HlkUtils.printErr(null, "skillSetName()", "status dizisinin boyutu yanlış");
continue;
}
// get array values
String skillId = status[0];
String objectId = status[1];

// check if object ID exists in hash map
if(!userSkillMap.containsKey(objectId)){

ArrayList<String> skillList = new ArrayList<String>();

skillList.add(skillId);

userSkillMap.put(objectId, skillList);
}
else{

userSkillMap.get(objectId).add(skillId);
}
}

isUpdateSuccessfull = dss.Update(userSkillMap, r_object_id);


}
catch(Exception e){
e.printStackTrace();
}

if(isUpdateSuccessfull){
response.getWriter().write("Güncelleme Başarılı");
}
else{
response.getWriter().write("Güncelleme Yapılamadı!");
}
}

我的错误日志

[4/20/15 9:41:27:795 EEST] 00000128 webapp        E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[dispatcherServlet]: java.lang.IllegalStateException: Cannot forward. Response already committed.
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:1148)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:193)
at org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler.handleRequest(DefaultServletHttpRequestHandler.java:120)
at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:49)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
at javax.servlet.http.HttpServlet.__AW_service(HttpServlet.java:668)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1225)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:775)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:457)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at com.emc.xcp.rest.security.filter.BasicAuthFilter.doFilter(BasicAuthFilter.java:51)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter.doFilter(DefaultLoginPageGeneratingFilter.java:91)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at com.emc.xcp.rest.security.filter.CSRFTokenFilter.doFilter(CSRFTokenFilter.java:23)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.__AW_doFilter(LogoutFilter.java:105)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.__AW_doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
at com.emc.xcp.rest.security.filter.RepositoryInfoFilter.doFilter(RepositoryInfoFilter.java:33)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
at com.emc.xcp.ui.LocaleFilter.doFilter(LocaleFilter.java:26)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at com.emc.xcp.ui.web.filter.CustomCharEncodingFilter.doFilterInternal(CustomCharEncodingFilter.java:47)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:928)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1025)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3761)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:975)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:459)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:526)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:312)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:87)
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:1815)

[4/20/15 9:41:27:811 EEST] 00000128 srt W com.ibm.ws.webcontainer.srt.SRTServletResponse setStatus WARNING: Cannot set status. Response already committed.

[4/20/15 9:41:27:811 EEST] 00000128 srt W com.ibm.ws.webcontainer.srt.SRTServletResponse addHeader SRVE8094W: WARNING: Cannot set header. Response already committed.

编辑

事实证明我在 servlet 映射方面遇到了问题。错误日志显示

Error while adding servlet mapping for path-->/UpdateSkillSet, wrapper-->ServletWrapper[com.hlk.katip.skillset.UpdateSkillSet:[/UpdateSkillSet]], application-->Katip_BPM.

在我的本地计算机上,我的网址是 - http://localhost:8080/KatipSkillSetWeb/skillset.jsp

我的 servlet 映射是

 <servlet>        
<servlet-name>UpdateSkillSet</servlet-name>
<servlet-class>com.hlk.katip.web.skillset.UpdateSkillSet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>UpdateSkillSet</servlet-name>
<url-pattern>/UpdateSkillSet</url-pattern>
</servlet-mapping>

现在我在服务器上的网址是 - http://gtdctmdapp01:9084/Katip_BPM/skillset/skillset.jsp

我的 servlet 映射又是

<servlet>        
<servlet-name>UpdateSkillSet</servlet-name>
<servlet-class>com.hlk.katip.web.skillset.UpdateSkillSet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>UpdateSkillSet</servlet-name>
<url-pattern>/UpdateSkillSet</url-pattern>
</servlet-mapping>

所以可能在服务器上我的 url-pattern 应该是/skillset/UpdateSkillSet

最佳答案

er.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[dispatcherServlet]: java.lang.IllegalStateException: Cannot forward. Response already committed.

这个错误是显而易见的。您已将输出写入响应流,并且某处的过滤器正在尝试将请求转发到另一个资源。

我在堆栈跟踪中看到的自定义类的第一个实例如下

com.emc.xcp.rest.security.filter.BasicAuthFilter.doFilter(BasicAuthFilter.java:5‌​1)

如果这不是您的类,您可以使用一个使用该过滤器类的框架,您应该从这里开始调试。

关于java - AJAX Servlet 调用非法状态异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29741783/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com