带有Jquery和Rest的Tomcat中的套接字写入错误(Apache CXF)

时间:2016-01-24 00:13:30

标签: jquery apache tomcat websocket cxf

我正在开发一个应用程序,其中我有一个用户名和密码的登录页面。在我提供凭据后,我调用了一个在tomcat中使用apache CXF运行的restful webservice。我在响应它构建时在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>
&#13;
&#13;
&#13;

&#13;
&#13;
$(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";
				  } 
			});

	});
});
&#13;
&#13;
&#13;

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();
}

我正在附上记录的屏幕截图,点击我看到的按钮,我可以看到&#34;导航到&#34;控制台中形成新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

1 个答案:

答案 0 :(得分:0)

此问题现已解决。我从我的JSP中删除了表单标签。这是一次试验和错误但是它确实解决了我的问题并且我得到了成功的响应。