Announcement Announcement Module
Collapse
No announcement yet.
Injecting a bean into HttpInvokerServiceExporter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Injecting a bean into HttpInvokerServiceExporter

    I am trying to inject a bean into an extension of the HttpInvokerServiceExporter. I've tried to do this is a standard spring config file like this:

    Code:
    <bean id="myHttpInvokerServiceExporter" class="com.blah.common.remoting.MyHTTPInvokerServiceExporter">
    <property name="myBean">    
    <ref bean="myBean"/>
    </property>
    </bean>
    But this gets interpreted as if I were trying to define a service to expose through the DispatcherServlet like this example from Chapter 17 of the docs:

    Code:
    <bean name="/AccountService" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
        <property name="service" ref="accountService"/>
        <property name="serviceInterface" value="example.AccountService"/>
    </bean>
    But this is not what I'm trying to do. Our services are exposed and working fine. I just want to add a bean to the HttpInvokerServiceExporter itself so I can store some temporary data about remote connections and make them accessible to other parts of the application.

    Here is the exception I'm getting on startup:

    Caught exception in main program org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'myHttpInvokerServiceExporter' defined in class path resource [config/commonConfig.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'service' is required
    I've Googled and searched through this forum, but can't find out how I should be doing this. Thanks in advance,

    Matt Taylor
    Last edited by rhyolight; Sep 14th, 2009, 08:56 AM. Reason: fixing first code snippet

  • #2
    The answer is to set up a parent bean definition that injects the bean I want:

    Code:
    <bean id="parentServiceExporter" abstract="true"
    		class="com.blah.common.remoting.MyHTTPInvokerServiceExporter">
    		<property name="myBean" ref="myBean"/>
    	</bean>
    
    	<bean name="/SomeService" parent="parentServiceExporter">
    		<property name="service" ref="someService" />
    		<property name="serviceInterface"
    			value="com.blah.services.SomeService" />
    	</bean>

    Comment

    Working...
    X