Announcement Announcement Module
Collapse
No announcement yet.
Remote services and Hessian Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Remote services and Hessian

    Hello,

    I try to test remote calls to a service with Hessian and I have the following exception:
    Cannot access Hessian service; nested exception is com.caucho.hessian.io.HessianProtocolException: unknown code:?

    I expose my service with HessianServiceExporter and linking the client to the remote service
    as explain in the reference documentation of Spring ( cf 16.3 ).
    I have no errors or exceptions during the load of the two servlets ( Struts and 'remote servlet' ).

    Can anyone help me to solve this problem?
    Thierry

  • #2
    can you elaborate more? config files, server/client classes...

    Comment


    • #3
      Remote services and Hessian/Burlap

      Hello,

      Thanks a lot for your reponse. Here are more details of my tests...
      I use TCP Monitor and here are the outputs ( with Burlap ). When Burlap
      works, I will try with Hessian...

      Request:

      POST /strutsspring/EnvironnementService HTTP/1.1
      Content-Type: text/xml
      User-Agent: Java/1.4.1
      Host: localhost
      Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
      Connection: keep-alive
      Content-Length: 72

      <burlap:call><method>getEnvironnement</method><int>1</int></burlap:call>

      Response:

      HTTP/1.1 200 OK
      Server: WebSphere Application Server/5.1
      Content-Type: text/html; charset=ISO-8859-1
      Content-Language: fr-FR
      Transfer-Encoding: chunked

      0


      Here is the web.xml for the webapp:

      <?xml version="1.0" encoding="ISO-8859-1"?>

      <!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
      "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

      <web-app>
      <display-name>Struts Application</display-name>

      <servlet>
      <servlet-name>action</servlet-name>
      <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
      <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
      </init-param>
      <init-param>
      <param-name>debug</param-name>
      <param-value>2</param-value>
      </init-param>
      <init-param>
      <param-name>detail</param-name>
      <param-value>2</param-value>
      </init-param>
      <load-on-startup>2</load-on-startup>
      </servlet>

      <servlet>
      <servlet-name>remote</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
      <load-on-startup>1</load-on-startup>
      </servlet>

      <servlet-mapping>
      <servlet-name>action</servlet-name>
      <url-pattern>*.do</url-pattern>
      </servlet-mapping>

      <servlet-mapping>
      <servlet-name>remote</servlet-name>
      <url-pattern>EnvironnementService</url-pattern>
      </servlet-mapping>
      </web-app>

      Here is the application.xml for the Struts application ( client Burlap ):

      <?xml version="1.0" encoding="ISO-8859-1"?>

      <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

      <beans>
      <bean id="serviceEnrionnement" class="org.springframework.remoting.caucho.BurlapP roxyFactoryBean">
      <property name="serviceUrl">
      <value>http://localhost:9081/strutsspring/EnvironnementService</value>
      </property>
      <property name="serviceInterface">
      <value>service.IEnvironnementService</value>
      </property>
      </bean>

      <bean name="/environnement" class="struts.EnvironnementAction"><!-- singleton="false"-->
      <property name="service">
      <ref local="serviceEnrionnement" />
      </property>
      </bean>

      <bean name="/envmanager" class="struts.ManageEnvironnementAction"><!-- singleton="false"-->
      <property name="service">
      <ref local="serviceEnrionnement" />
      </property>
      </bean>
      </beans>

      PS: the port 9081 is to use TCP Monitor, the real port to access is 9080.

      Here is the remote-servlet.xml configuration file ( provider Burlap ):

      <?xml version="1.0" encoding="ISO-8859-1"?>

      <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

      <beans>
      <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
      <property name="driverClassName"><value>org.hsqldb.jdbcDrive r</value></property>
      <property name="url"><value>jdbc:hsqldb:hsql://localhost:9001</value></property>
      <property name="username"><value>sa</value></property>
      <property name="password"><value></value></property>
      </bean>

      <bean id="environnementDao" class="dao.EnvironnementDao">
      <property name="dataSource">
      <ref bean="myDataSource" />
      </property>
      </bean>

      <bean id="codeOrigineDao" class="dao.CodeOrigineDao">
      <property name="dataSource">
      <ref bean="myDataSource" />
      </property>
      </bean>

      <bean id="serviceEnvironnement" class="service.EnvironnementService">
      <property name="environnementDao">
      <ref local="environnementDao" />
      </property>
      <property name="codeOrigineDao">
      <ref local="codeOrigineDao" />
      </property>
      </bean>

      <bean name="/EnvironnementService" class="org.springframework.remoting.caucho.BurlapS erviceExporter">
      <property name="service">
      <ref bean="serviceEnvironnement" />
      </property>
      <property name="serviceInterface">
      <value>service.IEnvironnementService</value>
      </property>
      </bean>
      </beans>

      Thanks for your help,
      Thierry

      Comment


      • #4
        Hessian problem solved

        Hello,

        I just solve my problem.
        The interface of my service has two methods with the same name but not the same signature: One with a parameter and one without parameter. Hessian / Burlap call one instead of the other...
        Thierry

        Comment


        • #5
          You can solve this problem by setting the property overload something on the factory instance on the client side.

          Comment


          • #6
            Hello and thanks for your answer.

            Can you give more details about this option? Can I set it in the following xml configuration code?

            <beans>
            <bean id="serviceEnrionnement" class="org.springframework.remoting.caucho.BurlapP roxyFactoryBean">
            <property name="serviceUrl">
            <value>http://localhost:9081/strutsspring/EnvironnementService</value>
            </property>
            <property name="serviceInterface">
            <value>service.IEnvironnementService</value>
            </property>
            </bean>

            Thanks,
            Thierry

            Comment


            • #7
              BurlapProxyFactory has a method "setOverloadEnabled", which is indirectly exposed in BurlapProxyFactoryBean throught a method of the same name.

              So your XML would become:

              Code:
              <bean id="serviceEnrionnement" class="org.springframework.remoting.caucho.BurlapProxyFactoryBean">
                <property name="serviceUrl">
                  <value>http&#58;//localhost&#58;9081/strutsspring/EnvironnementService</value>
                </property>
                <property name="serviceInterface">
                  <value>service.IEnvironnementService</value>
                </property>
                <property name="overloadEnabled">
                  <value>true</value>
                </property>
              </bean>
              Guillaume

              Comment


              • #8
                Hessian problem solved

                Thanks Guillaume, it works fine either with Hessian and Burlap.
                Thierry

                Comment


                • #9
                  <property name="overloadEnabled">
                  <value>true</value>
                  </property>

                  Ahh very helpful, thanks. I had the same problem.

                  Best,
                  Ben

                  Comment


                  • #10
                    It would seem to me that this option should be enabled by default? I know it ends up mangling the method names, which can make it slightly more difficult for non-Java clients to invoke, but it's not that much more difficult, and these are probably used more with Java clients than anything else.

                    Comment


                    • #11
                      Actually, the non-java client thing is a non-issue, because the server always support both mangled and non-mangled method names, it's the client that default not to mangle method name. However, not mangling method name is the default value of hessian/burlap, Spring just doesn't mess with that if not asked. I guess caucho decided to have non-mangled method names by default for performance reasons.

                      Comment


                      • #12
                        Hessian client connection problem

                        Hello,

                        I have exposed a Hessian service in my web-app and am trying to connect a standalone client to it. I seem to be getting the error:

                        com.caucho.hessian.io.HessianProtocolException:
                        at com.caucho.hessian.client.HessianProxy.invoke(Hess ianProxy.java:176)
                        at $Proxy0.createArrayDesign2Persist(Unknown Source)

                        .....

                        my client config file is:

                        <beans>
                        <!-- Remoting -->
                        <!-- Server Side RMI is on port 1299 ... see IntegrativeMetaAnalysis
                        springapp-servlet.xml -->
                        <!--Client Side Hessian -->
                        <bean id="readFile" class="tools.SimpleClientObject">
                        <property name="arrayDesignManagerInterface">
                        <ref bean="arrayDesignManagerProxy"/>
                        </property>
                        </bean>
                        <bean id="arrayDesignManagerProxy"
                        class="org.springframework.remoting.caucho.Hessian ProxyFactoryBean">
                        <property name="serviceUrl">
                        <value>http://localhost:8080/ArrayDesignService</value>
                        </property>
                        <property name="serviceInterface">
                        <value>bus.ArrayDesignManagerInterface</value>
                        </property>
                        </bean>
                        </beans>

                        my server config file is:

                        <?xml version="1.0" encoding="UTF-8"?>
                        <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

                        <!--
                        - Application context definition for "springapp" DispatcherServlet.
                        -->


                        <beans>
                        <!-- Controller (Action equivalent) -->
                        <bean id="springappController" class="web.SpringappController">
                        <property name="geneManager">
                        <ref bean="geneMan"/>
                        </property>
                        <property name="bioSequenceManager">
                        <ref bean="biosequenceMan"/>
                        </property>
                        <property name="compositeSequenceManager">
                        <ref bean="compositesequenceMan"/>
                        </property>
                        <property name="arrayDesignManager">
                        <ref bean="arraydesignMan"/>
                        </property>
                        </bean>
                        <!-- Validator and Form Controller for the "UserName" page -->
                        <bean id="userNameValidator" class="bus.UserNameValidator"/>
                        <bean id="userNameForm" class="web.UserNameFormController">
                        <property name="sessionForm">
                        <value>true</value>
                        </property>
                        <property name="commandName">
                        <value>userName</value>
                        </property>
                        <property name="commandClass">
                        <value>bus.UserName</value>
                        </property>
                        <property name="validator">
                        <ref bean="userNameValidator"/>
                        </property>
                        <property name="formView">
                        <value>username</value>
                        </property>
                        <property name="successView">
                        <value>hello.htm</value>
                        </property>
                        <property name="geneManager">
                        <ref bean="geneMan"/>
                        </property>
                        <property name="bioSequenceManager">
                        <ref bean="biosequenceMan"/>
                        </property>
                        <property name="compositeSequenceManager">
                        <ref bean="compositesequenceMan"/>
                        </property>
                        <property name="arrayDesignManager">
                        <ref bean="arraydesignMan"/>
                        </property>
                        </bean>
                        <!-- Bean Managers -->
                        <bean id="geneMan" class="bus.GeneManager">
                        <property name="geneManagerDao">
                        <ref bean="geneManDaoHib"/>
                        </property>
                        </bean>
                        <bean id="biosequenceMan" class="bus.BioSequenceManager">
                        <property name="bioSequenceManagerDao">
                        <ref bean="biosequenceManDaoHib"/>
                        </property>
                        </bean>
                        <bean id="compositesequenceMan" class="bus.CompositeSequenceManager">
                        <property name="compositeSequenceManagerDao">
                        <ref bean="compositesequenceManDaoHib"/>
                        </property>
                        </bean>
                        <bean id="arraydesignMan" class="bus.ArrayDesignManager">
                        <property name="arrayDesignManagerDao">
                        <ref bean="arraydesignManDaoHib"/>
                        </property>
                        </bean>
                        <!-- Data Access Objects -->
                        <bean id="geneManDao" class="db.GeneManagerDaoJdbc">
                        <property name="dataSource">
                        <ref bean="dataSource"/>
                        </property>
                        </bean>
                        <bean id="geneManDaoHib" class="db.GeneManagerDaoHibernate">
                        <property name="sessionFactory">
                        <ref bean="mySessionFactory"/>
                        </property>
                        </bean>
                        <bean id="biosequenceManDaoHib" class="db.BioSequenceManagerDaoHibernate">
                        <property name="sessionFactory">
                        <ref bean="mySessionFactory"/>
                        </property>
                        </bean>
                        <bean id="compositesequenceManDaoHib"
                        class="db.CompositeSequenceManagerDaoHibernate">
                        <property name="sessionFactory">
                        <ref bean="mySessionFactory"/>
                        </property>
                        </bean>
                        <bean id="arraydesignManDaoHib" class="db.ArrayDesignManagerDaoHibernate">
                        <property name="sessionFactory">
                        <ref bean="mySessionFactory"/>
                        </property>
                        </bean>
                        <!--
                        <property name="genes">
                        <list>
                        <ref bean="gene1"/>
                        <ref bean="gene2"/>
                        <ref bean="gene3"/>
                        </list>
                        </property>
                        </bean>
                        -->
                        <!--
                        <bean id="gene1" class="bus.Gene">
                        <property name="id"><value>0</value></property>
                        <property name="name"><value>GeneA</value></property>
                        <property name="description"><value>An A Gene.</value></property>
                        </bean>

                        <bean id="gene2" class="bus.Gene">
                        <property name="id"><value>1</value></property>
                        <property name="name"><value>GeneB</value></property>
                        <property name="description"><value>An B Gene.</value></property>
                        </bean>

                        <bean id="gene3" class="bus.Gene">
                        <property name="id"><value>2</value></property>
                        <property name="name"><value>GeneC</value></property>
                        <property name="description"><value>An C Gene.</value></property>
                        </bean>
                        -->
                        <!--Using SessionFactory resource for Hibernate data access-->
                        <bean id="mySessionFactory"
                        class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
                        <property name="mappingResources">
                        <list>
                        <value>Gene.hbm.xml</value>
                        <value>BioSequence.hbm.xml</value>
                        <value>CompositeSequence.hbm.xml</value>
                        <value>ArrayDesign.hbm.xml</value>
                        <value>Reporter.hbm.xml</value>
                        </list>
                        </property>
                        <property name="hibernateProperties">
                        <props>
                        <prop key="hibernate.dialect">
                        net.sf.hibernate.dialect.MySQLDialect</prop>
                        </props>
                        </property>
                        <property name="dataSource">
                        <ref bean="dataSource"/>
                        </property>
                        </bean>
                        <!-- Used by straight jdbc as well as by hibernate's session factory -->
                        <bean id="dataSource"
                        class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
                        <property name="driverClassName">
                        <value>com.mysql.jdbc.Driver</value>
                        </property>
                        <property name="url">
                        <value>jdbc:mysql://localhost:3307/integrativemetaanalysis</value>
                        <!--<value>jdbc:mysql://localhost:3307/ermine</value>-->
                        <!--<value>jdbc:mysql://localhost:3306/ermine</value>-->
                        </property>
                        <property name="username">
                        <value>pavlidis</value>
                        </property>
                        <property name="password">
                        <value>toast</value>
                        </property>
                        </bean>
                        <!--Transaction Management -->
                        <!--
                        <bean id="myTransactionManager"
                        class="org.springframework.orm.hibernate.Hibernate TransactionManager">
                        <property name="sessionFactory">
                        <ref bean="mySessionFactory"/>
                        </property>
                        </bean>
                        <bean id="myGeneServiceTarget" class="bus.GeneManager">
                        <property name="geneManagerDao">
                        <ref bean="geneManDaoHib"/>
                        </property>
                        </bean>
                        <bean id="myGeneService"
                        class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
                        <property name="transactionManager">
                        <ref bean="myTransactionManager"/>
                        </property>
                        <property name="target">
                        <ref bean="myGeneServiceTarget"/>
                        </property>
                        <property name="transactionAttributes">
                        <props>
                        <prop key="increasePrice*">PROPAGATION_REQUIRED</prop>
                        <prop key="someOtherBusinessMethod">PROPAGATION_MANDATOR Y</prop>
                        </props>
                        </property>
                        </bean>-->
                        <!-- message bundle -->
                        <bean id="messageSource"
                        class="org.springframework.context.support.Resourc eBundleMessageSource">
                        <property name="basename">
                        <value>messages</value>
                        </property>
                        </bean>
                        <!-- map urls -->
                        <bean id="urlMapping"
                        class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
                        <property name="mappings">
                        <props>
                        <prop key="/hello.htm">springappController</prop>
                        <prop key="/username.htm">userNameForm</prop>
                        </props>
                        </property>
                        </bean>
                        <!-- Spring's view resolver implementation -->
                        <bean id="viewResolver"
                        class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
                        <property name="viewClass">
                        <value>org.springframework.web.servlet.view.JstlVi ew</value>
                        </property>
                        <property name="prefix">
                        <value>/WEB-INF/jsp/</value>
                        </property>
                        <property name="suffix">
                        <value>.jsp</value>
                        </property>
                        </bean>
                        <!-- Remoting -->
                        <!--Server Side Hessian -->
                        <bean name="/ArrayDesignService"
                        class="org.springframework.remoting.caucho.Hessian ServiceExporter">
                        <property name="service">
                        <ref bean="arraydesignMan"/>
                        </property>
                        <property name="serviceInterface">
                        <value>bus.ArrayDesignManagerInterface</value>
                        </property>
                        </bean>
                        </beans>

                        Any ideas? The only difference between this and the Spring examples I have looked at is the fact that I am using a standalone command line client as opposed to another servlet.

                        Any help would be greatly appreciated.

                        Thanks.

                        Comment

                        Working...
                        X