Announcement Announcement Module
Collapse
No announcement yet.
HttpInvokerServiceExporter + RemoteConnectFailureException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HttpInvokerServiceExporter + RemoteConnectFailureException

    I am having problem using HttpInvokerServiceExporter. Please take a look at the code and suggest what do I do.
    I have used RmiServiceExporter and RmiProxyFactoryBean which worked fine. But, when I switched the code to HttpInvokerServiceExporter, it started giving errors. Please suggest any code changes.

    <?xml version="1.0"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    <bean id="helloWorldService" class="com.HelloWorldImpl">
    </bean>

    <!--
    <bean id="helloWorldServiceExporter"
    class="org.springframework.remoting.rmi.RmiService Exporter"> <property
    name="serviceName" value="HelloWorldN" /> <property name="service"
    ref="helloWorldService" /> <property name="serviceInterface"
    value="com.HelloWorld" /> <property name="registryPort" value="9000"
    /> <property name="servicePort" value="9001" /> </bean> <bean
    id="helloWorldproxyService"
    class="org.springframework.remoting.rmi.RmiProxyFa ctoryBean">
    <property name="serviceUrl" value="rmi://localhost:9000/HelloWorldN"
    /> <property name="serviceInterface" value="com.HelloWorld" /> </bean>
    -->

    <bean name="HelloWorldN"
    class="org.springframework.remoting.httpinvoker.Ht tpInvokerServiceExporter">
    <property name="service" ref="helloWorldService" />
    <property name="serviceInterface" value="com.HelloWorld" />
    </bean>




    <bean id="helloWorldproxyService"
    class="org.springframework.remoting.httpinvoker.Ht tpInvokerProxyFactoryBean">
    <property name="serviceUrl" value="http://localhost:8080/HelloWorldN" />
    <property name="serviceInterface" value="com.HelloWorld" />
    </bean>

    <bean id="helloWorldHandler" class="com.RMIClient">
    <property name="helloWorld" ref="helloWorldproxyService" />

    </bean>

    </beans>


    Java Code:
    ~~~~~~~~~~~

    System.out.println("Wait..");

    ClassPathXmlApplicationContext factory = new ClassPathXmlApplicationContext("applicationContext .xml");

    System.out.println("factory created");

    RMIClient bean1 = (RMIClient) factory.getBean("helloWorldHandler");

    HelloWorld s = bean1.getHelloWorld();

    System.out.println(s.getHelloWorld());


    Exception:
    ~~~~~~~~~

    org.springframework.remoting.RemoteConnectFailureE xception: Could not connect to HTTP invoker remote service at [http://localhost:8080/HelloWorldN]; nested exception is java.net.ConnectException: Connection refused: connect

  • #2
    Use [ code][/code ] tags whne posting code !!!!

    You will need an app server to deploy your app, the HttpInvoker stuff needs a webserver it doesn't work from the command line.

    Comment


    • #3
      A quick and lightweight way to do this is to use an embedded Jetty server. It only requires that you drop in a few small JAR files into your classpath, and add a few lines of code.

      I wrote about it here.

      Comment

      Working...
      X