Announcement Announcement Module
Collapse
No announcement yet.
Using HttpInvoker gives HTTP Status 404 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using HttpInvoker gives HTTP Status 404

    When I try accessing the web application on server using httpinvoker I keep getting "HTTP Status 404". Here are my configuration files,

    web.xml
    --------
    <?xml version="1.0" encoding="UTF-8"?>

    <!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>

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/orderContext.xml /WEB-INF/remoting-servlet.xml</param-value>

    </context-param>

    <servlet>
    <servlet-name>context</servlet-name>
    <servlet-class>org.springframework.web.context.ContextLoade rServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet>
    <servlet-name>remoting</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
    <load-on-startup>3</load-on-startup>
    </servlet>


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

    </web-app>


    --------------------------
    ---------------------------

    remoting-servlet.xml
    ----------

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

    <!--
    - DispatcherServlet application context for OrderService http-invoker web tier.
    -->
    <beans>


    <!-- URL Mapping to forward to controller... -->
    <bean id="urlMapping"
    class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
    <property name="mappings">
    <props>
    <prop key="/orderService">
    /orderService
    </prop>
    </props>
    </property>
    </bean>



    <bean name="/orderService"
    class="org.springframework.remoting.httpinvoker.Ht tpInvokerServiceExporter">
    <property name="service" ref="springHttpServerOrderService" />
    <property name="serviceInterface"
    value="com.packetmotion.service.IClientAPI" />
    </bean>

    </beans>

    -------------------
    -------------------

    orderContext.xml
    -----------

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">

    <!-- Application context definition -->
    <beans>


    <bean id="orderService"
    class="com.packetmotion.service.OrderServiceImpl">
    <property name="dao" ref="orderDAO" />
    </bean>

    <bean id="orderDAO" class="com.packetmotion.dao.jdbc.JdbcOrderDAO">
    <property name="jdbcTemplate" ref="orderJdbcTemplate" />
    </bean>

    <bean id="orderJdbcTemplate"
    class="org.springframework.jdbc.core.JdbcTemplate" >
    <property name="dataSource" ref="myDataSource" />
    </bean>


    <bean id="transactionManager"
    class="org.springframework.jdbc.datasource.DataSou rceTransactionManager">
    <property name="dataSource" ref="myDataSource" />
    </bean>

    <bean id="myDataSource"
    class="org.springframework.jdbc.datasource.DriverM anagerDataSource"
    destroy-method="close">
    <property name="driverClassName" value="${driverClassName}" />
    <property name="url" value="${url}" />
    <property name="username" value="${username}" />
    <property name="password" value="${password}" />
    </bean>


    <bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="locations">
    <list>
    <value>WEB-INF/order.properties</value>
    </list>
    </property>
    <!-- override system properties with those in order.prpoerties -->
    <property name="systemPropertiesModeName"
    value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
    <property name="ignoreResourceNotFound" value="true" />
    </bean>


    <bean id="appCtxHolder" class="com.packetmotion.spring.AppCtxHolder"/>

    <bean id="springHttpServerOrderService" class="com.packetmotion.service.ClientAPIImpl"/>

    </beans>

    ----------------------------
    ---------------------------

    SpringHttpClientService.xml (on Client side)
    ------------------

    <?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="ordeServiceHttpInvokerProxy" class="org.springframework.remoting.httpinvoker.Ht tpInvokerProxyFactoryBean">
    <property name="serviceUrl" value="http://localhost:8080/remoting/orderService"/>
    <property name="serviceInterface" value="com.packetmotion.service.IClientAPI"/>
    </bean>

    <bean id="myOrderServiceClient" class="com.packetmotion.main.OrderClient">
    <property name="orderService" ref="ordeServiceHttpInvokerProxy"/>
    </bean>

    </beans>




    -----------------------------
    -----------------------------
    On Server Side:

    public class AppCtxHolder implements ApplicationContextAware {

    private static ApplicationContext ctx;

    public AppCtxHolder() {}

    public void setApplicationContext(ApplicationContext applicationContext) {
    ctx = applicationContext;
    }

    public static ApplicationContext getApplicationContext() {
    return ctx;
    }
    }

    --------
    private static ApplicationContext appCtx = null;

    private ApplicationContext getAppContext()
    {
    if(this.appCtx == null){
    appCtx = AppCtxHolder.getApplicationContext();
    }

    return appCtx;

    }

    ---------------------------------
    ---------------------------------
    On Client Side:

    ListableBeanFactory beanFactory = new FileSystemXmlApplicationContext(CLIENT_CONTEXT_CON FIG_LOCATION);

    //OrderClient client = new OrderClient();
    OrderClient client = (OrderClient)beanFactory.getBean("myOrderServiceCl ient");


    I am using Tomcat 5.5 and I don't see any error message in the log file. When I type "http://localhost:8080/remoting/orderService" I get,

    HTTP Status 404

    This has been bugging me for past 2 days, any help will be very much appreciated.

  • #2
    Hi,

    I looked through your configuration files and compared to mine (which work, of course) and there are some differences.

    i) I don't include remote-servlet.xml on my context path, as the dispatcher servlet looks for this by default. But you are not using the default name so you may have to.

    ii) I'm not using an explict urlMapping bean but using the default mappings. It looks like the defaults would be fine but dosen't explain why your explict is not working.

    that's the only differences I could see. Have you turned debug logging on on both server and client side? This usually gives me enough information to solve configuration problems of this sort.

    Jonny

    Comment


    • #3
      It looks like your mapping may be set for matching "http://localhost:8080/remoting/remoting/orderService" (the first 'remoting' being the servlet context root and the second specified in the "url-mapping").

      Comment


      • #4
        Bingo !!! Mark gets full mark here for getting it right

        Thanks everyone who tried to help me out here. Evidentally, a small mistake was giving me big headaches.

        Comment


        • #5
          Actually, Mark if possible could you give little explanation about the "servlet-context" and "url mapping" you talked about. I am still not very clear where are those two "remoting" are coming from?

          I understand that the second remoting is from the <servlet-mapping> in the web.xml, but where is the first "remoting" in the URL from - does it has to be for every httpinvoker application?

          Comment


          • #6
            The first 'remoting' is the actual webapp root (when you deploy the remoting WAR file) meaning that when you go to http://localhost:8080/remoting, you are at the root. Any servlet-mapping is based upon the part of the URL that follows that.

            This link explains more details about the servlet-mapping itself.

            Comment

            Working...
            X