gpt4 book ai didi

java - Spring HTTP 调用程序返回空代理,需要调试帮助

转载 作者:太空宇宙 更新时间:2023-11-04 08:59:29 25 4
gpt4 key购买 nike

我关注了the spring http proxying tutorial尽可能接近,但我仍然无法让它在运行时工作(我的配置基本相同,所以除非我错过了拼写错误,否则不需要发布它)。

客户端启动正常,服务器也启动得很好(并且我已经验证了服务器上的对象已实例化),但是当我尝试访问代理对象的函数时(以及从未访问服务器对象上的方法),我立即收到空指针异常。这让我相信我没有正确访问代理。

所以,我的问题是:

  1. 是否有 Spring 文档中未提及的常见错误源?
  2. 除了客户端访问之外,还有其他方法可以测试服务器上的代理是否正确设置吗?

来自客户端的堆栈跟踪:

2009-07-28 16:29:57,270    ERROR  ig.ApplicationLifecycleAdvisor | Could not access HTTP invoker remote service at [http:/127.0.0.1:8080/<servlet-context>/<servlet-name>/Server]; nested exception is java.lang.NullPointerException
org.springframework.remoting.RemoteAccessException: Could not access HTTP invoker remote service at [http:/127.0.0.1:8080/<servlet-context>/<servlet-name>/Server]; nested exception is java.lang.NullPointerException
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.convertHttpInvokerAccessException(HttpInvokerClientInterceptor.java:211)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:144)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy0.logon(Unknown Source)
at se.<companyname>.client.connection.HttpServerConnection.logon(HttpServerConnection.java:55)
at se.<companyname>.client.command.logon.LoginDialog$LoginOkCommand.doExecuteCommand(LoginDialog.java:134)
at org.springframework.richclient.command.ActionCommand.execute(ActionCommand.java:219)
at org.springframework.richclient.command.ActionCommand$1.actionPerformed(ActionCommand.java:132)
at org.springframework.richclient.command.SwingActionAdapter.actionPerformed(SwingActionAdapter.java:71)
at javax.swing.SwingUtilities.notifyAction(Unknown Source)
at javax.swing.JComponent.processKeyBinding(Unknown Source)
at javax.swing.JComponent.processKeyBindings(Unknown Source)
at javax.swing.JComponent.processKeyEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.Dialog$1.run(Unknown Source)
at java.awt.Dialog$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Dialog.show(Unknown Source)
at java.awt.Component.show(Unknown Source)
at java.awt.Component.setVisible(Unknown Source)
at java.awt.Window.setVisible(Unknown Source)
at java.awt.Dialog.setVisible(Unknown Source)
at org.springframework.richclient.dialog.ApplicationDialog.showDialog(ApplicationDialog.java:405)
at se.<companyname>.client.jide.docking.JideLifecycleAdvisor.onPreWindowOpen(JideLifecycleAdvisor.java:47)
at org.springframework.richclient.application.support.AbstractApplicationWindow.showPage(AbstractApplicationWindow.java:187)
at org.springframework.richclient.application.support.AbstractApplicationWindow.showPage(AbstractApplicationWindow.java:158)
at se.<companyname>.client.jide.docking.JideApplicationWindow.showPage(JideApplicationWindow.java:131)
at org.springframework.richclient.application.Application.openWindow(Application.java:172)
at org.springframework.richclient.application.Application.start(Application.java:254)
at org.springframework.richclient.application.ApplicationLauncher$1.run(ApplicationLauncher.java:308)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at sun.net.www.ParseUtil.toURI(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
at org.springframework.remoting.httpinvoker.SimpleHttpInvokerRequestExecutor.writeRequestBody(SimpleHttpInvokerRequestExecutor.java:129)
at org.springframework.remoting.httpinvoker.SimpleHttpInvokerRequestExecutor.doExecuteRequest(SimpleHttpInvokerRequestExecutor.java:64)
at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.executeRequest(AbstractHttpInvokerRequestExecutor.java:136)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:191)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:173)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:141)
... 54 more

当我尝试使用下面的 Gregory Mostizky 代码在 Web 浏览器中或从单独的应用程序中打开代理地址时,客户端向我提供 505,同时服务器打印以下堆栈跟踪:

2009-07-29 10:52:49,023 ERROR ([serverExporter]) [http-127.0.0.1-8080-1] Servlet.service() for servlet serverExporter threw exception
java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2279)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2748)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:780)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
at org.springframework.core.ConfigurableObjectInputStream.<init>(ConfigurableObjectInputStream.java:47)
at org.springframework.remoting.rmi.CodebaseAwareObjectInputStream.<init>(CodebaseAwareObjectInputStream.java:81)
at org.springframework.remoting.rmi.RemoteInvocationSerializingExporter.createObjectInputStream(RemoteInvocationSerializingExporter.java:105)
at org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter.readRemoteInvocation(HttpInvokerServiceExporter.java:115)
at org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter.readRemoteInvocation(HttpInvokerServiceExporter.java:96)
at org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter.handleRequest(HttpInvokerServiceExporter.java:73)
at org.springframework.web.context.support.HttpRequestHandlerServlet.service(HttpRequestHandlerServlet.java:65)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Thread.java:619)

我仍然不知道问题出在哪里:/

最佳答案

根据您发布的跟踪,您在客户端使用的服务 URL 存在一些问题。我会尝试打开到指定 URL 的手动连接来尝试调试问题。

类似于:

    URL url = new URL("your_service_url");
int i = url.openConnection().getInputStream().read();

编辑:

客户端上的 505 和服务器上的 EOF 意味着您正在获取从客户端到服务器的连接。它失败了,因为我们发送了垃圾,所以这是预期的并且实际上是可以的。

您确定在测试和 Spring 配置中使用了相同的 URL 吗?您可以发布您的客户端 context.xml 的相关部分吗?特别是原始异常中的这一行看起来确实很奇怪:

[http:/127.0.0.1:8080/<servlet-context>/<servlet-name>/Server]

关于java - Spring HTTP 调用程序返回空代理,需要调试帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1194545/

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