Announcement Announcement Module
Collapse
No announcement yet.
HttpInvoker doesn't load beans from root context Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HttpInvoker doesn't load beans from root context

    I have exposed few services throgh HttpInvoker and defined dispatcher servlet as

    <servlet>
    <servlet-name>springRemoting</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
    <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/config/core/remote/springRemoting-servlet.xml</param-value>
    </init-param>
    </servlet>


    When i try to call a exposed service (which has dependencies on other bean that defined in root beans application context file) it doesn't recognize those refrence beans from global context location. why?

    On other hand instead of defining springRemoting-servlet.xml in this dispatcher if i add the same springRemoting-servlet.xml in root beans application context it works fine !

    Root global context
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/config/core/remote/springRemoting-servlet.xml, abc.xml,wewe.xml</param-value>
    </context-param>




  • #2
    Posting the exact error that you got along with the actual config XML and the code which doesn't work, helps.

    Following setup, which is similar to what you mentioned, works fine:
    Web.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/applicationContext.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>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/config/remoting-servlet.xml</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>remoting</servlet-name>
            <url-pattern>/remoting/*</url-pattern>
        </servlet-mapping>
    </web-app>
    /WEB-INF/applicationContext.xml defined as context param in above web.xml:
    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.5.xsd">
        
        <bean id="myServiceImpl" class="forums.MyServiceImpl"/>
    </beans>
    Finally the /WEB-INF/config/remoting-servlet.xml whose location is set as servlet init-param in the above web.xml:
    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.5.xsd">
        
        <bean name="/MyService" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
            <property name="service" ref="myServiceImpl"/>
            <property name="serviceInterface" value="forums.MyService"/>
        </bean>
    </beans>

    Comment

    Working...
    X