Hi Guys,

I'm currently working on a project which allows a non-spring client to transfer data to and from a Tomcat/Spring Server.

I decided to use Hessian because it sounded quite neat but it creates crazy exceptions which I do not understand.

So first i show some of my code

So i use
Spring 3.0.6
Tomcat 7
Hessian 4.0.7


Client:

Code:
HessianProxyFactory factory = new HessianProxyFactory();
IConnector basic = (IConnector) factory.create(IConnector.class, "http://localhost:8080/HessianTest/remoting/RemoteService");
basic.getData2(new long[]{1,2});
basic.getData(new long[]{1,2});

Server:


web.xml
Code:
<web-app>
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>WEB-INF/beans.xml</param-value>
	</context-param>
	<listener>
		<listener-class>
			org.springframework.web.context.ContextLoaderListener
		</listener-class>
	</listener>
	<servlet>
		<servlet-name>remoting</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet
		</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>remoting</servlet-name>
		<url-pattern>/remoting/*</url-pattern>
	</servlet-mapping>
</web-app>
remoting.xml

Code:
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">


	<bean name="/RemoteService"
		class="org.springframework.remoting.caucho.HessianServiceExporter">
		<property name="service" ref="Connector" />
		<property name="serviceInterface" value="xxx.IConnector" />
	</bean>

</beans>

The code of the Connector is very simple. It just calls a dao with to deal with the data

Code:
int getData(long[] data);
int getData2(long[] data);

So now the Exception I keep getting:

Client:
Code:
Exception in thread "main" com.caucho.hessian.client.HessianRuntimeException: com.caucho.hessian.io.HessianProtocolException: '?' is an unknown code
	at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:221)
	at $Proxy0.getDatasetHeader(Unknown Source)
	at de.rusch.client.Main.main(Main.java:45)
Caused by: com.caucho.hessian.io.HessianProtocolException: '?' is an unknown code
	at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:219)
	... 2 more
Server:

Code:
Feb 15, 2012 5:38:08 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [remoting] in context with path [/HessianTest] threw exception [Hessian skeleton invocation failed; nested exception is java.lang.UnsupportedOperationException: com.caucho.hessian.io.BasicDeserializer@31987298] with root cause
java.lang.UnsupportedOperationException: com.caucho.hessian.io.BasicDeserializer@31987298
	at com.caucho.hessian.io.BasicDeserializer.readList(BasicDeserializer.java:512)
	at com.caucho.hessian.io.HessianInput.readObject(HessianInput.java:1052)
	at com.caucho.hessian.server.HessianSkeleton.invoke(HessianSkeleton.java:300)
	at com.caucho.hessian.server.HessianSkeleton.invoke(HessianSkeleton.java:221)
	at org.springframework.remoting.caucho.HessianExporter.doInvoke(HessianExporter.java:198)
	at org.springframework.remoting.caucho.HessianExporter.invoke(HessianExporter.java:118)
	at org.springframework.remoting.caucho.HessianServiceExporter.handleRequest(HessianServiceExporter.java:66)
	at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:49)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:585)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:680)
The strange thing about this error is that I get it when using getData but not when using getData2.

I tried playing a bit with the HessianFactory in the client and setting Hessian2Reply and Hessian2Request to true with the effect that a long[] was translated into a String[] (There is another method getData(String[] data)) or I got some of the "long expected 0xd java.lang.String".


So from what I see from the BasicDeserializer source the Exception is thrown because readList checks with a switch if the datatype is readable or otherwise throws this exception. And during debugging i saw that Hessian does not see a long[] as datatype but a simple String.

I guess this is a problem with me using Hessian in a wrong way and can be solved very easy :-).

Can u please also help me to make Hessian2 work on my Service.

Best and thx a lot

hajoru

(Sorry for the repost. Accidently postet the same thread into web services and have no idea how to change the folder)