我有一个我在Java SE上运行的类,它每秒都会通过一个线程调用。一切正常。
然而,当我将其转换为WebService并每秒通过AJAX调用它时,我遇到了SOAP服务器错误。但是,如果我每隔6秒调用一次,一切都很好。
我以前调用的方法无法执行工作。它实际上成功地读取和解析XML,但是当转换为WebService时,XML解析崩溃。
更频繁地调用WebService会导致错误的原因是什么?
以下是服务器端抛出的异常:
[Fatal Error] :1:7: A pseudo attribute name is expected.
Sep 25, 2014 3:22:46 PM com.sun.xml.internal.ws.server.sei.TieHandler createResponse
SEVERE: null
java.lang.NullPointerException
at Targets.XML.TESXMLStringToArrays(XML.java:209)
at Navires.Vessel.allVessels(Vessel.java:137)
at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.Trampoline.invoke(Unknown Source)
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.xml.internal.ws.api.server.MethodUtil.invoke(Unknown Source)
at com.sun.xml.internal.ws.api.server.InstanceResolver$1.invoke(Unknown Source)
at com.sun.xml.internal.ws.server.InvokerTube$2.invoke(Unknown Source)
at com.sun.xml.internal.ws.server.sei.SEIInvokerTube.processRequest(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Unknown Source)
at com.sun.xml.internal.ws.server.WSEndpointImpl$2.process(Unknown Source)
at com.sun.xml.internal.ws.transport.http.HttpAdapter$HttpToolkit.handle(Unknown Source)
at com.sun.xml.internal.ws.transport.http.HttpAdapter.handle(Unknown Source)
at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handleExchange(Unknown Source)
at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handle(Unknown Source)
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
at sun.net.httpserver.AuthFilter.doFilter(Unknown Source)
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(Unknown Source)
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
at sun.net.httpserver.ServerImpl$Exchange.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
以下是客户端抛出的异常:
Sep 25, 2014 3:22:39 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [/Map] threw exception [An exception occurred processing JSP page /targets.jsp at line 17
14:
15: Vessel M = V.getVesselPort() ;
16:
17: List<Vessel_Type> vessel =M.allVessels ();
18:
19: int j =0 ;
20: k="{"+'"'+"vessels"+'"'+":[" ;
Stacktrace:] with root cause
com.sun.xml.internal.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: java.lang.NullPointerException Please see the server log to find more detail regarding exact cause of the failure.
at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(Unknown Source)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(Unknown Source)
at com.sun.xml.internal.ws.client.sei.StubHandler.readResponse(Unknown Source)
at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(Unknown Source)
at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source)
at com.sun.proxy.$Proxy35.allVessels(Unknown Source)
at org.apache.jsp.targets_jsp._jspService(targets_jsp.java:90)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:335)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:534)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1081)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
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)
当一个客户端调用Web服务时,它经常发生。但是,当2个客户端调用Web服务时,它立即在服务器端和客户端崩溃。执行Ajax调用时抛出这些异常。
编辑:添加了详细信息。
问题来自应用程序架构。
以下是它的工作原理:
1)服务器将打开与另一台服务器的套接字连接,并获得XML数据紧密连接。
2)服务器将XML数据格式化为Array,并通过webservice
提供3)客户端调用Web服务来获取Array数据。
因此,如果我尝试在不到6秒的时间内调用Web服务,我会收到之前发布的错误。
当我检查登录时1)我可以看到错误是因为连接已关闭所以2)将自动导致错误。
我可以通过多次调用来触发错误(通过eclipse多次点击来运行调用webservice的java方法),或者通过使用多个客户端通过具有ajax的JSP页面调用webservice,或者简单地通过调用ajax调用
在1)我可以使用许多客户端打开连接并快速获取数据,无任何问题。
因此,如果我将webmethod声明为同步,我将得到的错误可以解决,但不会出现任何错误,但是因为多次调用将挂起直到处理,所以它非常慢。
我无法理解的原因是为什么在SE中我可以每秒调用2次并获得数据甚至更好我可以在各种机器上同时执行此操作而不会出现任何日志错误,并且数据在webservice中同时是100清理( EE)它失败了......我应该重新配置我的网络服务吗?审查架构?
答案 0 :(得分:0)
问题来自:
public class cnx {
static Socket socket ;
现在通过从类属性中删除套接字并将其作为局部变量放在类中来解决它。
但是在服务器端(我拉数据)我可以看到很多连接被启动,同时只连接了一个客户端,这是由于多次调用(每秒一次,待处理的数据需要2秒)。
如果你有更好的选择,请分享。