Hi,
I was trying the example given in the book :Spring In Action Chapter 8 on Remoting.
I want to send data remotely from my CitationService to my Client. But I am getting the following exceptions:
Code:Exception in thread "main" org.springframework.remoting.RemoteConnectFailureException: Cannot connect to Burlap remote service at [http://localhost:8080/citation/citation.service]; nested exception is java.net.ConnectException: Connection refused: connect at org.springframework.remoting.caucho.BurlapClientInterceptor.convertBurlapAccessException(BurlapClientInterceptor.java:178) at org.springframework.remoting.caucho.BurlapClientInterceptor.invoke(BurlapClientInterceptor.java:153) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy1.getCitationForVehicle(Unknown Source) at com.tickettodrive.rmi.RmiClient.main(RmiClient.java:16) Caused by: java.net.ConnectException: Connection refused: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at java.net.Socket.connect(Socket.java:519) at java.net.Socket.connect(Socket.java:469) at sun.net.NetworkClient.doConnect(NetworkClient.java:157) at sun.net.www.http.HttpClient.openServer(HttpClient.java:394) at sun.net.www.http.HttpClient.openServer(HttpClient.java:529) at sun.net.www.http.HttpClient.<init>(HttpClient.java:233) at sun.net.www.http.HttpClient.New(HttpClient.java:306) at sun.net.www.http.HttpClient.New(HttpClient.java:323) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:788) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:729) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:654) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:832) at com.caucho.burlap.client.BurlapProxy.invoke(BurlapProxy.java:131) at $Proxy0.getCitationForVehicle(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.remoting.caucho.BurlapClientInterceptor.invoke(BurlapClientInterceptor.java:147) ... 4 more
I am using hessian-3.1.3.jar with Spring 2.5.6
My desktop firewall is turned off.
I am using eclipse 3.4.1 with Tomcat 5.5
I have used the following configurations:
To Define a service:
1) CitationServiceImpl.java
My Service side XML ttd-burlap-service.xml:Code:public class CitationServiceImpl implements CitationService { // private static final Logger LOGGER = Logger // .getLogger(CitationServiceImpl.class); public CitationServiceImpl() {} public Citation[] getCitationForVehicle(String state, String plateNumber) { Citation[] citations = new Citation[2]; // TODO - implement real citation lookup. For now, return dummy values citations[0] = new Citation(); citations[0].setDate(new Date(103, 2, 3)); // yeah, I know it's // deprecated. citations[0].setViolationCode("PKG123"); citations[0].setDescription("Parked blocking a fire hydrant"); citations[1] = new Citation(); citations[1].setDate(new Date(105, 6, 9)); // yeah, I know it's // deprecated. citations[1].setViolationCode("SPD110"); citations[1].setDescription("Driving 98MPH in a school zone"); return citations; } }
Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="citationService" class="com.tickettodrive.CitationServiceImpl" /> <!-- An RMI service exporter, as discussed in section 8.2.2 and shown on page 315. --> <bean class="org.springframework.remoting.caucho.BurlapServiceExporter"> <property name="service" ref="citationService"/> <property name="serviceInterface" value="com.tickettodrive.CitationService"/> </bean> </beans>
My Client Class:
My ttd-burlap-client.xmlCode:public class BurlapClient { public static void main(String[] args) { ApplicationContext ctx = new ClassPathXmlApplicationContext( "classpath:com/tickettodrive/burlap/ttd-burlap-client.xml"); CitationService cs = (CitationService) ctx.getBean("citationService"); Citation[] citations = cs.getCitationForVehicle("TX", "J55DNY"); for (int i = 0; i < citations.length; i++) { Citation citation = citations[i]; System.out.println(i + ". " + citation.getViolationCode() + " - " + citation.getDescription()); } } }
<?xml version="1.0" encoding="UTF-8"?>
My web.xml looks like:Code:<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <!-- <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">--> <!-- <property name="location" value="ttd.properties" />--> <!-- </bean>--> <!-- BurlapProxyFactoryBean to wire in a Burlap service. From section 8.3.1, page 317. Notice, that I'm using the short-hand value attribute here, while the book shows the long-hand <value> element. I had intended for the book to use the short-hand form, as shown below, but didn't catch this until the book was already typeset and it was too late to change. --> <bean id="citationService" class="org.springframework.remoting.caucho.BurlapProxyFactoryBean"> <property name="serviceUrl" value="http://localhost:8080/citation/citation.service" /> <property name="serviceInterface" value="com.tickettodrive.CitationService" /> </bean> </beans>
And finally my citation-servlet.xml looks like:Code:<?xml version="1.0" encoding="ISO-8859-1"?> <web-app 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 web-app_2_4.xsd" version="2.4"> <servlet> <servlet-name>citation</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>citation</servlet-name> <url-pattern>*.service</url-pattern> </servlet-mapping> </web-app>
Does any one have any Idea why I am getting the error. Am I doing something wrong? Is it something to do with Tomcat?Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="citationService" class="com.tickettodrive.CitationServiceImpl" /> <!-- Exports the citationService bean as a Burlap service. From section 8.3.2, page 322 Notice, that I'm using the short-hand value attribute here, while the book shows the long-hand <value> element. I had intended for the book to use the short-hand form, as shown below, but didn't catch this until the book was already typeset and it was too late to change. --> <bean name="burlapCitationService" class="org.springframework.remoting.caucho.BurlapServiceExporter"> <property name="service" ref="citationService" /> <property name="serviceInterface" value="com.tickettodrive.CitationService" /> </bean> <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <props> <prop key="/citation.service">burlapCitationService</prop> </props> </property> </bean> </beans>
FYI : I was getting similar connection refused exception when i try to use RMI based remoting using spring. I havent been able to figure that out either.


Reply With Quote