I am having problems w/ConnectExceptions when testing an HttpInvoker process using embedded Jetty. I have a client Swing app and a Spring Config file, which is attempting to access and define a remote bean by way of HttpInvokerProxyFactoryBean. On the other end(The data access service), I
have another Spring Config file which exposes the remote beans by way of HttpInvokerServiceExporter.
I took the following approach to setting up the Jetty, web and Spring config files, separating Jetty from Spring:
http://jroller.com/page/sjivan?entry...ty_in_a_spring
I suspect the problem is either in the Jetty.xml or web.xml files.
The Jetty.xml is here:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="Server"
class="org.mortbay.jetty.Server" init-method="start" destroy-method="stop">
<property name="connectors">
<list>
<bean id="Connector" class="org.mortbay.jetty.nio.SelectChannelConnector">
<property name="port" value="8080"/>
</bean>
</list>
</property>
<property name="handler">
<bean id="handlers"
class="org.mortbay.jetty.handler.HandlerCollection">
<property name="handlers">
<list>
<bean id="contexts"
class="org.mortbay.jetty.handler.ContextHandlerCollection">
<property name="handlers">
<list>
<bean class="org.mortbay.jetty.webapp.WebAppContext">
<property name="contextPath" value="/"/>
<!--<property name="war" value="../web">-->
<property name="resourceBase" value="web">
</property>
</bean>
</list>
</property>
</bean>
</list>
</property>
</bean>
</property>
</bean>
</beans>
The web.xml file is here:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Backcheck Remoting</display-name>
<description>Backcheck Remoting Services</description>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:SpringConfig.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>remoting</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>remoting</servlet-name>
<url-pattern>/remoting/*</url-pattern>
</servlet-mapping>
</web-app>
The client Spring Config is here:
Code:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean id="httpGroupDao" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
<property name="serviceUrl" value="http://localhost:8080/remoting/httpGroupDao"/>
<property name="serviceInterface" value="com.xrite.ind.backcheck.dao.group.GroupDao"/>
<property name="httpInvokerRequestExecutor">
<bean class="org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor"/>
</property>
</bean>
</beans>
The code to access the remote bean from the Swing Client is:
Code:
private static BeanFactory beanFactory;
beanFactory = new ClassPathXmlApplicationContext("SpringClientConfig.xml");
return (GroupDao) beanFactory.getBean("httpGroupDao");
The Data Access Layer/Server Spring Config file is:
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"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/backcheck"/>
<property name="username" value="root"/>
<property name="password" value="goteam"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
<list>
<value>Color.hbm.xml</value>
<value>ReflectanceData.hbm.xml</value>
<value>Group.hbm.xml</value>
<value>Standard.hbm.xml</value>
<value>Sample.hbm.xml</value>
<value>Lab.hbm.xml</value>
<value>Tag.hbm.xml</value>
<value>TagCategory.hbm.xml</value>
<value>Tolerance.hbm.xml</value>
<value>ViewSet.hbm.xml</value>
<value>ViewSetItem.hbm.xml</value>
<value>FilterState.hbm.xml</value>
<value>User.hbm.xml</value>
<value>FilterSort.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="current_session_context_class">thread</prop>
<prop key="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</prop>
</props>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="groupDao"
class="com.xrite.ind.backcheck.dao.group.GroupDAOImpl">
<property name="sessionFactory" ref="backcheckSessionFactory"/>
</bean>
<bean name="/httpGroupDao" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
<property name="service" ref="groupDao"/>
<property name="serviceInterface" value="com.xrite.ind.backcheck.dao.group.GroupDao"/>
</bean>
</beans>