Announcement Announcement Module
Collapse
No announcement yet.
Hessian-Service is not working proper Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hessian-Service is not working proper

    I have written a simple client to access a spring hessian-service:

    Code:
    import java.net.MalformedURLException;
    
    import com.caucho.hessian.client.HessianProxyFactory;
    
    public class HelloHessian {
    
    	public static void main(String[] args) {
    		try {
    			String url = "http"+"://localhost/remoting/HessianService";
    
    			HessianProxyFactory factory = new HessianProxyFactory();
    			HessianService basic = (HessianService) factory.create(HessianService.class, url);
    
    			System.out.println("hello(): " + basic.getHelloWorld());
    		} catch (MalformedURLException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    	}
    }
    Spring-Exception in Tomcat:
    Code:
    java.io.StreamCorruptedException: invalid stream header
    	at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:763)
    	at java.io.ObjectInputStream.<init>(ObjectInputStream.java:278)
    	at org.springframework.remoting.rmi.CodebaseAwareObjectInputStream.<init>(CodebaseAwareObjectInputStream.java:68)
    	at org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter.createObjectInputStream(HttpInvokerServiceExporter.java:157)
    	at org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter.readRemoteInvocation(HttpInvokerServiceExporter.java:123)
    	at org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter.readRemoteInvocation(HttpInvokerServiceExporter.java:102)
    	at org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter.handleRequest(HttpInvokerServiceExporter.java:81)
    	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:723)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:663)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:394)
    	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:358)
    Client-Exception because of redirection to error-page:
    Code:
    Exception in thread "main" com.caucho.hessian.client.HessianConnectionException: 302: java.net.HttpRetryException: cannot retry due to redirection, in streaming mode
    	at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:197)
    	at $Proxy0.getHelloWorld(Unknown Source)
    	at HelloHessian.main(HelloHessian.java:16)
    Caused by: java.net.HttpRetryException: cannot retry due to redirection, in streaming mode
    	at sun.net.www .protocol.http.HttpURLConnection.followRedirect(HttpURLConnection.java:1653)
    	at sun.net.www .protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1088)
    	at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:367)
    	at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:168)
    	... 2 more
    I get the server-exception also if I call the url from browser.

    If I call the service from another spring-tomcat-client, it works!

    My configuration:
    web.xml
    Code:
    	<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>
    remoting-servlet.xml:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http: .... www .springframework.org/dtd/spring-beans.dtd">
    <beans>
    	<bean id="hessianService" class="my.HessianServiceImpl">
      
    	</bean>
    	<bean name="hessian" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
    		<property name="service" ref="hessianService"/>
    		<property name="serviceInterface" value="my.HessianService"/>
    	</bean>
    	
    	<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    
    		<property name="mappings">
    			<props>
    				<prop key="/HessianService">hessian</prop>
    			</props>
    		</property>
    	</bean>
    </beans>
    my-servlet.xml:
    Code:
    	<bean id="httpInvokerProxy" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
        	<property name="serviceUrl" value="http... ip/remoting/HessianService"/>
    		<property name="serviceInterface" value="my.HessianService"/>
    	</bean>
    ..
    	<bean id="anyController" class="my.AnyClientController">
    ....
    		<property name="hessianService">
    			<ref bean="httpInvokerProxy" />
    		</property>
    	</bean>
    Is the hessian-implementation of spring not standard-conform? Or is there any error in my client (I used example code from hessian.caucho.com/#Client%20Implementation)?

  • #2
    You aren't using Hessian you are using the HttpInvoker. If you want to use hessaion you should also use the correct ServiceExporter.

    Comment


    • #3
      wrong version of hessian

      This was also not working! But now I have found the problem: Im using spring 1.2.7. And I need to use hessian-2.1.12.jar!

      Comment

      Working...
      X