Using HttpInvokerServiceExporter giving 500 error code
<p>I am struggling for last two days to expose a service using HttpInvokerServiceExporter. The error says <code>Did not receive successful HTTP response</code> The complete stack trace is below for details. The code is checked in Git repo. Link is - <a href="https://github.com/prashdeep/spring-remoting.git" rel="nofollow">Github link</a> </p>

<pre><code>org.springframework.remoting.RemoteAccessException: Could not access HTTP invoker remote service at [http://localhost:8080/spring-remoting/AccountService]; nested exception is java.io.IOException: Did not receive successful HTTP response: status code = 500, status message = [Internal Server Error]
org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.convertHttpInvokerAccessException(HttpInvokerClientInterceptor.java:216)
org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:147)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
com.sun.proxy.$Proxy8.add(Unknown Source)
com.remoting.ClientInvoker.getCube(ClientInvoker.java:9)
org.apache.jsp.process_jsp._jspService(process_jsp.java:118)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

java.io.IOException: Did not receive successful HTTP response: status code = 500, status message = [Internal Server Error]
org.springframework.remoting.httpinvoker.SimpleHttpInvokerRequestExecutor.validateResponse(SimpleHttpInvokerRequestExecutor.java:185)
org.springframework.remoting.httpinvoker.SimpleHttpInvokerRequestExecutor.doExecuteRequest(SimpleHttpInvokerRequestExecutor.java:92)
org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.executeRequest(AbstractHttpInvokerRequestExecutor.java:138)
org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:194)
org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:176)
org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:144)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
com.sun.proxy.$Proxy8.add(Unknown Source)
com.remoting.ClientInvoker.getCube(ClientInvoker.java:9)
org.apache.jsp.process_jsp._jspService(process_jsp.java:118)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
</code></pre>

<p>I have followed the documentation properly and have implemented all the steps. Below is the service interface:</p>

<pre><code>package com.remoting;

public interface AccountService {
    public int add(int a, int b);
}
</code></pre>

<p>Then the service implementation </p>

<pre><code>package com.remoting;
public class AccountServiceImpl implements AccountService {
    @Override
    public int add(int a, int b) {
        return a + b;
    }
}
</code></pre>

<p>Then the web.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
    &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1"&gt;
    &lt;display-name&gt;spring-remoting&lt;/display-name&gt;

&lt;!-- The front controller of this Spring Web application, responsible for 
    handling all application requests --&gt;
    &lt;servlet&gt;
        &lt;servlet-name&gt;accountExporter&lt;/servlet-name&gt;
        &lt;servlet-class&gt;org.springframework.web.context.support.HttpRequestHandlerServlet&lt;/servlet-class&gt;
        &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
        &lt;servlet-name&gt;accountExporter&lt;/servlet-name&gt;
        &lt;url-pattern&gt;/AccountService&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
&lt;/web-app&gt;
</code></pre>

<p>Then the application beans. The application beans are placed in <code>applicationContext.xml</code> and is inside the <code>/WEB-INF/classes</code> directory:</p>

<pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd"&gt;

&lt;bean id="accountService" class="com.remoting.AccountServiceImpl"&gt;&lt;/bean&gt;

&lt;bean name="accountExporter"
    class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter"&gt;
    &lt;property name="service" ref="accountService" /&gt;
    &lt;property name="serviceInterface" value="com.remoting.AccountService" /&gt;
&lt;/bean&gt;
&lt;bean id="httpServer"
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean"&gt;
    &lt;property name="serviceUrl" value="http://localhost:8080/spring-remoting/AccountService"&gt;&lt;/property&gt;
    &lt;property name="serviceInterface" value="com.remoting.AccountService"&gt;&lt;/property&gt;
    &lt;/bean&gt;

&lt;/beans&gt;
</code></pre>

<p>Now to invoke the service I have two jsp files and a helper class to load the beans and invoke the function:</p>

<p>index.jsp</p>

<pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
    &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;form action="process.jsp"&gt;
    Enter Number:&lt;input type="text" name="number" /&gt; &lt;input type="submit"
        value="cube" /&gt;
    &lt;/form&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>process.jsp</p>

<pre><code>&lt;jsp:include page="index.jsp"&gt;&lt;/jsp:include&gt;  
&lt;hr/&gt;  
&lt;%@page import="com.remoting.ClientInvoker"%&gt;  

&lt;%  
  int number=Integer.parseInt(request.getParameter("number"));  
  out.print("sum of "+number+" is: "+ClientInvoker.sum(number));  
%&gt;  
</code></pre>

<p>Finally the <code>ClientInvoker</code> class</p>

<pre><code>package com.remoting;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;  

public class ClientInvoker {  
    public static int sum(int number){  
        ApplicationContext context = new      ClassPathXmlApplicationContext("classpath:applicationContext.xml");  
        AccountService service = (AccountService)context.getBean("httpServer");  
        return service.add(4, 4);  
    }  
}
</code></pre>

<p>The applicationContext.xml is placed inside the <code>/WEB-INF/classes</code> directory.</p>

<p>Please let me know where I am going wrong.  </p>