Announcement Announcement Module
Collapse
No announcement yet.
HttpInvoker problems accessing a method Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HttpInvoker problems accessing a method

    Hi folks

    I am losing my mind with this problem. I am sure it must be something simple but can't figure it out. Any help is greatly appreciated.


    Here is the scoop.

    I am trying to write a test service and a client for remoting using HttpInvoker. When I try to execute the client program I get the following error:

    ==========Exception====================
    Exception in thread "main" java.lang.NoSuchMethodError: org.springframework.aop.support.AopUtils.isToStrin gMethod(Ljava/lang/reflect/MethodZ
    at org.springframework.remoting.httpinvoker.HttpInvok erClientInterceptor.invoke(HttpInvokerClientInterc eptor.java:113)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :140)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:153)
    at $Proxy0.aRemoteMethod(Unknown Source)
    at clientTest.TestClient.main(TestClient.java:33)


    ========server web.xml=====================

    <servlet>
    <servlet-name>springhttp</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>springhttp</servlet-name>
    <url-pattern>/springhttp/*</url-pattern>
    </servlet-mapping>
    =============================
    ===========Server applcontext.xml
    <bean id="myFirstServiceImpl" class="test.MyFirstServiceImpl"/>
    <bean name="/MyFirstService"
    class="org.springframework.remoting.httpinvoker.Ht tpInvokerServiceExporter">
    <property name="service" ref="myFirstServiceImpl"/>
    <property name="serviceInterface" value="test.MyFirstService"/>
    </bean>
    ============
    =============springhttp-servlet.xml in WEB-INF ==========
    <bean name="MyFirstService"
    class="org.springframework.remoting.httpinvoker.Ht tpInvokerServiceExporter">
    <property name="service" ref="myFirstServiceImpl"/>
    <property name="serviceInterface" value="MyFirstService"/>
    </bean>
    ================
    ===========Client App context
    <bean id="myFirstServiceRemote"
    class="org.springframework.remoting.httpinvoker.Ht tpInvokerProxyFactoryBean">
    <property name="serviceUrl"
    value="http://localhost:8080/springcode/springhttp/MyFirstService"/>
    <property name="serviceInterface" value="clientTest.MyFirstService"/>
    </bean>
    <bean id="myOrderServiceClient" class="clientTest.TestClient">
    <property name="myFirstService" ref="myFirstServiceRemote"/>
    </bean>
    =====================
    ==============Test Client
    public class TestClient {
    static private ApplicationContext ctx = null;
    MyFirstService myFirstService;
    static {
    // Application context is thread safe and can be save in an
    // instance. See chapter 12 Spring reference man.
    if (ctx == null) {
    ctx = new ClassPathXmlApplicationContext("applicationContext .xml");
    }
    }
    public void setMyFirstService(MyFirstService myFirstService) {
    this.myFirstService = myFirstService;
    }
    public static void main(String[] args) {
    TestClient test = new TestClient();
    test.myFirstService = (MyFirstService) ctx
    .getBean("myFirstServiceRemote");
    String result = test.myFirstService.aRemoteMethod("good", "bad");
    System.out.println(result);
    }

    }

  • #2
    You're getting a java.lang.NoSuchMethodError. This generally means that you are running the program with a different version of the class that which you compiled against. You've probably got multiple versions of spring on your classpath somewhere.

    Comment


    • #3
      Another exception HTTP response: status code = 404

      I deleted all my existing libraries and put new ones. I am getting this exception now.
      Exception in thread "main" org.springframework.remoting.RemoteAccessException : Cannot access HTTP invoker remote service at [http://localhost:8080/springcode/spr...FirstService]; nested exception is java.io.IOException: Did not receive successful HTTP response: status code = 404, status message = [Servlet springhttp is not available]
      java.io.IOException: Did not receive successful HTTP response: status code = 404, status message = [Servlet springhttp is not available]
      at org.springframework.remoting.httpinvoker.SimpleHtt pInvokerRequestExecutor.validateResponse(SimpleHtt pInvokerRequestExecutor.java:135)
      at org.springframework.remoting.httpinvoker.SimpleHtt pInvokerRequestExecutor.doExecuteRequest(SimpleHtt pInvokerRequestExecutor.java:61)
      at org.springframework.remoting.httpinvoker.AbstractH ttpInvokerRequestExecutor.executeRequest(AbstractH ttpInvokerRequestExecutor.java:69)
      at org.springframework.remoting.httpinvoker.HttpInvok erClientInterceptor.executeRequest(HttpInvokerClie ntInterceptor.java:146)
      at org.springframework.remoting.httpinvoker.HttpInvok erClientInterceptor.invoke(HttpInvokerClientInterc eptor.java:120)
      at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :170)
      at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:176)
      at $Proxy0.aRemoteMethod(Unknown Source)
      at clientTest.TestClient.main(TestClient.java:23)

      Comment


      • #4
        I think this most recent error results from the call to "localhost:8080/springcode.." whereas the url-pattern is set for "/springhttp/*" - unless of course you changed that mapping.

        As for the previous errors, it looks like you are using 2 different interfaces on the client and server? Can you post those interfaces?

        Comment


        • #5
          HTTP Error 404

          mark I am past the error "Method not found" I had incompatible libraries.
          Now I have HTTP Error 404 as posted.

          My application is deployed under the context springcode and the servlet mapping is /springhttp/* so my url looks like
          http://localhost:8080/springcode/spr...MyFirstService.

          =========web.xml===============
          <web-app version="2.4"
          xmlns="http://java.sun.com/xml/ns/j2ee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
          http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
          <context-param>
          <param-name>contextConfigLocation</param-name>
          <param-value>/WEB-INF/classes/applicationContext.xml,/WEB-INF/springhttp-servlet.xml</param-value>

          </context-param>

          <servlet>
          <servlet-name>springhttp</servlet-name>
          <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
          <load-on-startup>1</load-on-startup>
          </servlet>
          <servlet-mapping>
          <servlet-name>springhttp</servlet-name>
          <url-pattern>/springhttp/*</url-pattern>
          </servlet-mapping>
          </web-app>

          All other code is posted in the original post.
          Last edited by yogisri; Oct 11th, 2006, 02:17 PM.

          Comment


          • #6
            One thing I notice, you define your http invoker service exporter in two places, one with the name /MyFirstService, the other with MyFirstService. I'm sure that's not correct.

            I define mine within the servlet configuration file (springhttp-servlet.xml in your case). I'm not sure the servlet with pick them up from the other application context file, but I'm not certain on that without reading the docs (it's been a long time since I configured this). The service definition within the springhttp-servlet.xml is missing the leading '/' which maybe causing the url problems.

            Jonny

            Comment


            • #7
              servlet file not getting picked up.

              I am sure that my springhttp-servlet.xml file is not getting picked up from web.xml. The reason I know this is because even if I put some junk in that file I get no errors.

              Here is my web.xml

              ==============web.xml==============
              <?xml version="1.0" encoding="UTF-8"?>
              <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
              http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
              <context-param>
              <param-name>contextConfigLocation</param-name>
              <param-value>
              classpath:applicationContext.xml
              classpath:springhttp-servlet.xml
              </param-value>
              </context-param>
              <listener>
              <listener-class>
              org.springframework.web.context.ContextLoaderListe ner
              </listener-class>
              </listener>
              <servlet>
              <servlet-name>springhttp</servlet-name>
              <servlet-class>
              org.springframework.web.servlet.DispatcherServlet
              </servlet-class>
              <load-on-startup>1</load-on-startup>
              </servlet>
              <servlet-mapping>
              <servlet-name>springhttp</servlet-name>
              <url-pattern>/springhttp/*</url-pattern>
              </servlet-mapping>
              </web-app>
              =================================

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

              <!--
              - DispatcherServlet application context for OrderService http-invoker web tier.
              -->
              <beans>


              <!-- URL Mapping to forward to controller... -->
              <bean id="remoteMapping"
              class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
              <property name="mappings">
              <props>
              <prop key="/MyFirstService">/MyFirstService</prop>
              </props>
              </property>
              </bean>
              <bean name="/MyFirstService"
              class="org.springframework.remoting.httpinvoker.Ht tpInvokerServiceExporter">
              <property name="service" ref="myFirstServiceImpl" />
              <property name="serviceInterface" value="test.MyFirstService" />
              </bean>
              </beans>
              ================================================== ==

              Comment


              • #8
                You should not specify the 'springhttp-servlet.xml' file in the "contextConfigLocation" param. It will be automatically loaded into an ApplicationContext by the DispatcherServlet on startup. The DispatcherServlet looks for the file: "WEB-INF/[servlet-name]-servlet.xml".

                Comment


                • #9
                  Removed the springhttp-servlet.xml from web.xml

                  Mark and Jonny

                  Thank you for hanging in with me. I am still getting HTTP 404 exception.

                  Here is my new web.xml

                  <?xml version="1.0" encoding="UTF-8"?>
                  <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                  http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
                  <context-param>
                  <param-name>contextConfigLocation</param-name>
                  <param-value>
                  classpath:applicationContext.xml
                  </param-value>
                  </context-param>
                  <listener>
                  <listener-class>
                  org.springframework.web.context.ContextLoaderListe ner
                  </listener-class>
                  </listener>
                  <servlet>
                  <servlet-name>springhttp</servlet-name>
                  <servlet-class>
                  org.springframework.web.servlet.DispatcherServlet
                  </servlet-class>
                  <load-on-startup>1</load-on-startup>
                  </servlet>
                  <servlet-mapping>
                  <servlet-name>springhttp</servlet-name>
                  <url-pattern>/springhttp/*</url-pattern>
                  </servlet-mapping>
                  </web-app>

                  Comment


                  • #10
                    It works...

                    I was using Sping 1.2 jars. I downloaded Spring 2.0 jars and it works.

                    Thank you so much for your time.

                    Really appreciated.

                    yogi

                    Comment

                    Working...
                    X