gpt4 book ai didi

jquery - 使用 Jquery 和 Rest (Apache CXF) 的 Tomcat 中的套接字写入错误

转载 作者:行者123 更新时间:2023-11-28 22:01:55 28 4
gpt4 key购买 nike

我正在开发一个应用程序,其中我有一个带有用户名和密码的登录页面。在我提供凭据后,我调用了一个在 tomcat 中运行的 restful web 服务和 apache CXF。我在 apache 建立响应时收到套接字写入错误。我得到错误仅针对此调用,而其他其余端点在成功响应时工作正常。

代码片段

<html><head>
<meta charset="UTF-8">
<title>Kovil Registration System</title>
</head>
<body>
<div class="pen-title">
<h1>Kovil Reservation System</h1>
</div>
<div class="module form-module">

<div class="form">
<h2>Admin Login</h2>
</div>
<div class="form">
<h2>Admin Login</h2>
<form>
<input name="username" type="text" placeholder="Username">
<input type="password" placeholder="Password">
<button>Login</button>
</form>
</div>
<div class="cta">
<a>Forgot your password?</a>
</div>
</div>
</body>
</html>

$(document).ready(function() {

$('.form-module button').click(function(event) {
alert("inside submit");
var kovilRequestDTO={
"username" : $("input[name=username]").val(),
"password" : $("input[type='password']").val()
};
var data=JSON.stringify(kovilRequestDTO);
$.ajax({
type: "POST",
url: "http://localhost:8091/KovilRestServices/kovilRestService/validateAdmin",
data: data,
timeout: 60000,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(response) {
alert("success");
window.location.href = "${pageContext.request.contextPath}/resources/jsp/success.jsp";
}
});

});
});

Java 后端

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd">

<import resource="classpath:META-INF/cxf/cxf.xml" />
<jaxrs:server id="base" address="/kovilRestService">
<jaxrs:providers>
<ref bean="jsonProvider"/>
</jaxrs:providers>
<jaxrs:extensionMappings>
<entry key="json" value="application/json"/>
</jaxrs:extensionMappings>
<jaxrs:serviceBeans>
<ref bean="kovilRestService" />
</jaxrs:serviceBeans>
</jaxrs:server>
<bean id="kovilRestService" class="com.kovil.rest.service.KovilRestServiceImpl" />

<bean id="jsonProvider" class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>

    public Response validateAdmin(KovilRequestDTO kovilRequestDTO){
KovilBusinessService kovilBusinessService=loadBusinessBean();
String username=kovilRequestDTO.getUsername();
String password=kovilRequestDTO.getPassword();
KovilResponseObject kovilResponseObject=new KovilResponseObject();
boolean validationResult=kovilBusinessService.validateAdmin(username, password);
kovilResponseObject.setSuccessMessage("success");
return Response.ok(kovilResponseObject).build();
}

我附上了我在点击按钮时可以看到的屏幕截图,我在控制台中看到了“导航到”消息,其中形成了新的 URL。还提供了代码片段和错误日志 Login Screen Redirection inthe chrome console

日志

Jan 24, 2016 1:02:05 AM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
WARNING: Interceptor for {http://service.rest.kovil.com/}KovilRestServiceImpl has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not send Message.
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:113)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:336)
at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:83)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:241)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:248)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:222)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:153)
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:171)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:286)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:206)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:262)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.catalina.connector.ClientAbortException: java.net.SocketException: Software caused connection abort: socket write error
at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:367)
at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:331)
at org.apache.catalina.connector.Response.flushBuffer(Response.java:610)
at org.apache.catalina.connector.ResponseFacade.flushBuffer(ResponseFacade.java:306)
at org.apache.cxf.transport.http.AbstractHTTPDestination$WrappedOutputStream.close(AbstractHTTPDestination.java:750)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.AbstractHTTPDestination$BackChannelConduit.close(AbstractHTTPDestination.java:679)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
... 35 more
Caused by: java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:215)
at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480)
at org.apache.coyote.http11.InternalOutputBuffer.flush(InternalOutputBuffer.java:119)
at org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:801)
at org.apache.coyote.Response.action(Response.java:172)
at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:363)
... 42 more

最佳答案

问题现已解决。我从我的 JSP 中删除了表单标签。这是一个反复试验,但它确实解决了我的问题,我得到了成功的回应。

关于jquery - 使用 Jquery 和 Rest (Apache CXF) 的 Tomcat 中的套接字写入错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34970647/

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