[Hessian-interest] Hessian 3.1.6 protocol 2.0 does not work when remote exceptions are thrown

Miquel.Herrera at nominet.org.uk Miquel.Herrera at nominet.org.uk
Wed Jul 2 06:46:38 CDT 2008


Hello,

We have been using hessian 3.0.20 and protocol 1.0 for some time now with 
no big issues. However I am trying to move to hessian 3.1.6 and protocol 
2.0 and I can not get it to work.

Normal calls work fine and a lot faster, but when an exception happens in 
the remote side, I get deserialization errors as shown below. 

I tried to directly serialise and deserialise an Exception object and it 
worked fine, therefore the problem is not in the serialization code but 
the data which is transmitted back to the client when an exception arises 
which I think it would be a fault map.


web.xml declares the remoting servlet like this:

        <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>



and remoting-servlet.xml contains:

        <!-- Mapping servlet URL to different remoting handlers -->
        <bean 
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
                <property name="urlMap">
                        <map>
                                <entry key="/hessianProxyService">
                                        <ref bean="hessianProxyService"/>
                                </entry>
                                <!-- Other mappings here -->
                        </map>
                </property>
        </bean>
 
        <!-- Exposing service with Hessian -->
        <bean id="hessianProxyService" 
 class="org.springframework.remoting.caucho.HessianServiceExporter">
                <property name="service" ref="proxyService"/>
                <property name="serviceInterface" 
 value="uk.nominet.proxyservice.InternalProxyServiceIF"/>
        </bean>
 
 
        In the client side, Hessian proxy bean is configured as follows.
        <beans>
 
                <bean id="proxyClient" 
                class="uk.nominet.proxyservice.client.TestProxyClient">
                        <property name="proxyService" 
ref="hessianProxyService"/>
                </bean>
 
                <bean id="hessianProxyService" 
 class="org.springframework.remoting.caucho.HessianProxyFactoryBean">
                        <!-- This URL binds to the service, it must be 
changed as an ant substitution -->
                        <property name="serviceUrl" value="
http://localhost:8080/proxyservice/remoting/hessianProxyService"/> 
                        <property name="serviceInterface" 
value="uk.nominet.proxyservice.InternalProxyServiceIF"/>
                        <property name="proxyFactory" ref="proxyFactory"/>
                </bean>
 
                <bean id="proxyFactory" 
class="com.caucho.hessian.client.HessianProxyFactory">
                        <property name="hessian2Request" value="true" />
                        <property name="hessian2Reply" value="true" />
                        <property name="debug" value="false" />
                </bean>
 
        </beans>

For testing purposes I just define one method in InternalProxyServiceIF 
which is forced to throw an exception:

        public String testHessian2(String str) throws Exception{
                System.out.println("You passed: " + str);
                throw new Exception("Testing");
                //              return str;
        }
 

Calls work for normal cases, when the exception is not thrown and the 
string is returned, but when an exception is thrown I always get the 
following problem:


org.springframework.remoting.RemoteAccessException: Cannot access Hessian 
remote service at [http://
localhost:8080/proxyservice/remoting/hessianProxyService]; nested 
exception is com.caucho.hessian.io
.HessianFieldException: java.lang.StackTraceElement.lineNumber: expected 
integer at end of file
at 
org.springframework.remoting.caucho.HessianClientInterceptor.convertHessianAccessException(Hessi
anClientInterceptor.java:254)
at 
org.springframework.remoting.caucho.HessianClientInterceptor.invoke(HessianClientInterceptor.jav
a:225)
at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.
java:171)
at 
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy1.testHessian2(Unknown Source)
at 
uk.nominet.proxyservice.client.TestProxyClient.main(TestProxyClient.java:42)
Caused by: com.caucho.hessian.io.HessianFieldException: 
java.lang.StackTraceElement.lineNumber: expe
cted integer at end of file
at 
com.caucho.hessian.io.JavaDeserializer.logDeserializeError(JavaDeserializer.java:590)
at 
com.caucho.hessian.io.JavaDeserializer$IntFieldDeserializer.deserialize(JavaDeserializer.java:48
3)
at 
com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:233)
at 
com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:157)
at 
com.caucho.hessian.io.Hessian2Input.readObjectInstance(Hessian2Input.java:2048)
at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1689)
at 
com.caucho.hessian.io.ArrayDeserializer.readList(ArrayDeserializer.java:95)
at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1700)
at 
com.caucho.hessian.io.JavaDeserializer$ObjectFieldDeserializer.deserialize(JavaDeserializer.java
:387)
at 
com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:233)
at 
com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:157)
at 
com.caucho.hessian.io.SerializerFactory.readObject(SerializerFactory.java:376)
at 
com.caucho.hessian.io.Hessian2Input.readObjectInstance(Hessian2Input.java:2051)
at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1977)
at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1969)
at com.caucho.hessian.io.Hessian2Input.readFault(Hessian2Input.java:1626)
at 
com.caucho.hessian.io.Hessian2Input.prepareFault(Hessian2Input.java:425)
at com.caucho.hessian.io.Hessian2Input.startReply(Hessian2Input.java:414)
at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:218)
at $Proxy0.testHessian2(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at 
org.springframework.remoting.caucho.HessianClientInterceptor.invoke(HessianClientInterceptor.jav
a:219)
... 4 more
Caused by: com.caucho.hessian.io.HessianProtocolException: expected 
integer at end of file
at com.caucho.hessian.io.Hessian2Input.error(Hessian2Input.java:2705)
at com.caucho.hessian.io.Hessian2Input.expect(Hessian2Input.java:2668)
at com.caucho.hessian.io.Hessian2Input.readInt(Hessian2Input.java:845)
at 
com.caucho.hessian.io.JavaDeserializer$IntFieldDeserializer.deserialize(JavaDeserializer.java:47
9)
        ... 27 more
 


I tried to set debug to true in the factory to see what is being returned,

        <bean id="proxyFactory" 
class="com.caucho.hessian.client.HessianProxyFactory">
                <property name="hessian2Request" value="true" />
                <property name="hessian2Reply" value="true" />
                <property name="debug" value="true" />
        </bean>
 
A different exception is thrown when debuging. the output in this case is 
shown below.
 
        reply 2.0
        fault map (#0)
        "code" => "ServiceException"
"message" => "Testing"
"detail" => /* defun java.lang.Exception [detailMessage, cause, 
stackTrace] */
object java.lang.Exception (#0)
detailMessage: "Testing"
cause: ref(#0)
stackTrace: list [java.lang.StackTraceElement(#1)
0: 0.0
1: binary(14)
2: 
3: 
4: 
5: 4
6: "declaringClass"
7: "methodName"
8: "fileName"
9: "lineNumber"
10: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at 
com.caucho.hessian.io.HessianDebugState$ObjectState.shift(HessianDebugState.java:1188)
at 
com.caucho.hessian.io.HessianDebugState$State.nextObject(HessianDebugState.java:277)
at 
com.caucho.hessian.io.HessianDebugState$ObjectState.next(HessianDebugState.java:1214)
at com.caucho.hessian.io.HessianDebugState.next(HessianDebugState.java:93)
at 
com.caucho.hessian.io.HessianDebugInputStream.read(HessianDebugInputStream.java:106)
at java.io.InputStream.read(InputStream.java:163)
at com.caucho.hessian.io.Hessian2Input.readBuffer(Hessian2Input.java:2644)
at com.caucho.hessian.io.Hessian2Input.read(Hessian2Input.java:2624)
at com.caucho.hessian.io.Hessian2Input.startReply(Hessian2Input.java:386)
at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:218)
at $Proxy0.testHessian2(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at 
org.springframework.remoting.caucho.HessianClientInterceptor.invoke(HessianClientInterceptor.jav
a:219)
at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.
java:171)
at 
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy1.testHessian2(Unknown Source)
        at 
uk.nominet.proxyservice.client.TestProxyClient.main(TestProxyClient.java:42)
 
 
Can somebody help on this?

Kind regards
Miquel




More information about the hessian-interest mailing list