tags:

views:

1426

answers:

2

Hey all

I've followed the spring http proxying tutorial as closely as possibly, but I still can't get it to work at runtime (my configuration is largely identical, so unless I've missed a typo there is no need to post it).

The Client starts up fine, as does the server (and I've verified that the object on the server is instantiated), but I get a nullpointer exception as soon as I try to access the proxied object's functions (as well as the fact that the method on the server object is never accessed). This leads me to believe that I haven't accessed the proxy correctly.

So, my questions are:

  1. Are there any common error sources not mentioned in the Spring documentation?
  2. Is there any other way than access from the client to test that the proxy is correctly set up on the server?

Stacktrace from client:

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

When I try to open the proxy address in a web browser or from a separate app using Gregory Mostizky's code below, the client side gives me a 505 while the server prints the following stack trace:

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)

I'm still at a loss as to what the problem can be :/

+1  A: 

According to the trace you posted there is some problem with service URL you are using on the client side. I would try to open a manual connection to the specified URL to try to debug the problem.

Something like:

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

EDIT:

505 on client and EOF on server means that you are getting the connection from client to server. It fails because we send garbage so that is expected and is actually ok.

Are you sure you used the same URL in the test and the spring configuration? Can you post the relevant part of your client context.xml? In particular this line from original exception does look strange:

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

Gregory Mostizky
I tried this, got a 505 for my troubles (I added the stack trace above). Does this say anything about where the error lies?
mikek
Updated the answer, no solution yet though
Gregory Mostizky
Ah, yes. This is where I hand in my coding gloves, I believe.
mikek
A: 

Are you sure the URL is correct? The stack trace is missing one slash after the http:

Could not access HTTP invoker remote service
  at [http:/127.0.0.1:8080/<servlet-context>/<servlet-name>/Server]
Arjan