PDA

View Full Version : Problems getting HttpInvoker to work


shadrak
Sep 22nd, 2004, 06:11 AM
I've been reading about the new HttpInvoker and thought I'd give it a try. I ran the example in jpetstore and decided to implement my own. To demonstrate the concept to others I've pared things down to the absolute minimum and I just cannot get it to work.

Tomcat shows the request coming in but the client reports :-


Exception in thread "main" org.springframework.remoting.RemoteAccessException : Cannot access HTTP invoker remote service at [http://192.168.254.205:8080/camserv/request]; nested exception is java.io.FileNotFoundException: http://192.168.254.205:8080/camserv/request


My application is very simple :-


package webservice;
public interface IRequestServer {
public String ping( );
}

package webservice;
public class RequestServer implements IRequestServer {
public String ping( ) {
return "pong";
}
}

public class PingClient {
public static void main( String[] args ) throws Exception {
ApplicationContext ctx = new FileSystemXmlApplicationContext(
"RequestClient.xml" );
IRequestServer req = (IRequestServer) ctx.getBean( "ping" );
System.out.println( "Ping: " + req.ping( ) );
}
}

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

<beans>
<bean id="requestService" class="webservice.RequestServer"/>
<bean
name="/request"
class="org.springframework.remoting.httpinvoker.HttpInvok erServiceExporter"
>
<property name="service"><ref bean="requestService"/></property>
<property name="serviceInterface">
<value>webservice.IRequestServer</value>
</property>
</bean>
</beans>

<beans>
<bean
id="ping"
class="org.springframework.remoting.httpinvoker.HttpInvok erProxyFactoryBean"
>
<property name="serviceUrl">
<value>http://192.168.254.205:8080/camserv/request</value>
</property>
<property name="serviceInterface">
<value>webservice.IRequestServer</value>
</property>
</bean>
</beans>


I'm sure it's something simple but I can't for the life of me spot what it is. Any ideas?

steven.warren
Sep 22nd, 2004, 12:50 PM
It looks pretty good from what you've posted. I would make sure that your config file is being read into the camserv servlet dispatcher. I couldn't tell from looking at your posting.

I think it needs to be in a file called camserv-config.xml, since you don't explicitly load the context.

Regards
Steve

shadrak
Sep 22nd, 2004, 01:23 PM
I confused myself. In the sample application the application is rooted at jpetstore, the servlet at remoting and the service at something else. By calling my application the same name as the servlet I forgot to add the extra component in the pathname. When I did this it worked!

hitdemo
Nov 29th, 2004, 09:30 AM
yes,need add

<servlet>
<servlet-name>remoting</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>4</load-on-startup>
</servlet>

and

<servlet-mapping>
<servlet-name>remoting</servlet-name>
<url-pattern>/remoting/*</url-pattern>
</servlet-mapping>

in web.xml,i was confused by this wholely night.