Results 1 to 5 of 5

Thread: expected URL given a configuration..

  1. #1

    Default expected URL given a configuration..

    Given the applicationContext:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd" >
    <beans>
    	<!--  Data Source  -->
    	<bean id="dataSource"
    		class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    		<property name="driverClassName"
    			value="org.postgresql.Driver">
    		</property>
    		<property name="url" value="jdbc:postgresql://127.0.0.1/distdata"></property>
    		<property name="username" value="root"></property>
    		<property name="password" value="celicious"></property>
    	</bean>
    	
    	<!-- iBATIS sqlMapClient -->
    	<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
    		<property name="configLocation" value="sqlMapConfig.xml"></property>
    		<property name="dataSource" ref="dataSource"></property>
      		<property name="lobHandler" ref="defaultLobHandler"></property> 
    	</bean>
    	
    	
    	<!-- LobHandler for JDBC drivers -->
    	<bean id="defaultLobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true">
    	</bean>
    	
    	<!-- A transaction manager for a single JDBC connection -->
    	<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    		<property name="dataSource"><ref local="dataSource"/></property>
    	<!-- 	<property name="sessionFactory"><ref local="sessionFactory"/></property> -->
    	</bean>
    	
    	
    	<bean id="sqlMapClientProvinceDao" class="dist.dao.ibatis.SqlMapClientProvinceDao">
    		<property name="dataSource" ref="dataSource"></property>
    		<property name="sqlMapClient" ref="sqlMapClient"></property>
    	</bean>
    
    	<bean id="sqlMapClientPlaceDao" class="dist.dao.ibatis.SqlMapClientPlaceDao">
    		<property name="dataSource" ref="dataSource"></property>
    		<property name="sqlMapClient" ref="sqlMapClient"></property>
    	</bean>
    
    	<bean id="sqlMapClientDistributorDao" class="dist.dao.ibatis.SqlMapClientDistributorDao">
    		<property name="dataSource" ref="dataSource"></property>
    		<property name="sqlMapClient" ref="sqlMapClient"></property>
    	</bean>
    
    	<bean id="sqlMapClientUomDao" class="dist.dao.ibatis.SqlMapClientUomDao">
    		<property name="dataSource" ref="dataSource"></property>
    		<property name="sqlMapClient" ref="sqlMapClient"></property>
    	</bean>
    
    	<bean id="sqlMapClientProductDao" class="dist.dao.ibatis.SqlMapClientProductDao">
    		<property name="dataSource" ref="dataSource"></property>
    		<property name="sqlMapClient" ref="sqlMapClient"></property>
    	</bean>
    
    	<bean id="sqlMapClientProductUomDao" class="dist.dao.ibatis.SqlMapClientProductUomDao">
    		<property name="dataSource" ref="dataSource"></property>
    		<property name="sqlMapClient" ref="sqlMapClient"></property>
    	</bean>
    
    </beans>

    the dsrapp-servlet.xml:

    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="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="mappings">
                <props>
                    <prop key="/viewUom">viewUomController</prop>
                </props>
            </property>
        </bean>
    
    <!--  
    	<bean 
    		id="handlerMapping" 
    		name="handlerMapping"
    		class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping" >
    		<property name="urlMap" >
    			<map>
    				<entry key="/viewUom" value-ref="viewUom"></entry>
    			</map>
    		</property>
    	</bean>
      	-->
       	<bean 
    		id="viewResolver" 
    		name="viewResolver"
    		class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
    		<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
    		<property name="prefix" value="/WEB-INF/jsp/"></property>
    		<property name="suffix" value=".jsp"></property>
    	</bean> 	
    
    
    
    	<bean 
    		id="viewUomController"
    		name="viewUomController"
    		class="dist.web.ViewUomController"  >
    		<property name="uomDao" ref="sqlMapClientUomDao"></property>
    	</bean>
    
    </beans>

    and the web.xml:
    Code:
    <?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>
    
    	<display-name>dsrapp</display-name>
    	<description>Daily Sales Report Monitoring Application</description>
    
    	<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>dsrapp</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<init-param>
    			<param-name>detectAllHandlerAdapters</param-name>
    			<param-value>false</param-value>
    		</init-param>
    		<init-param>
    			<param-name>detectAllHandlerExceptionResolvers</param-name>
    			<param-value>false</param-value>
    		</init-param>
    		<init-param>
    			<param-name>detectAllHandlerMappings</param-name>
    			<param-value>false</param-value>
    		</init-param>
    		<init-param>
    			<param-name>detectAllViewResolvers</param-name>
    			<param-value>false</param-value>
    		</init-param>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    	<servlet-mapping>
    		<servlet-name>dsrapp</servlet-name>
    		<url-pattern>/dsrapp/*</url-pattern>
    	</servlet-mapping>
    	<welcome-file-list>
    		<welcome-file>test.html</welcome-file>
    	</welcome-file-list>
    the webapp is properly deployed in Tomcat 6... Tomcat is running (http://localhost:8080 returns the tomcat page)...

    but as far as the deployed webapp, I'm not sure which proper URL to use in order to get the controller / pages to work. I've tried the following:
    http://localhost:8080/dsrapp/viewuom
    http://localhost:8080/dsrapp/dsrapp/viewuom

    and both addresses return a status 404.

  2. #2
    Join Date
    Mar 2006
    Location
    Bangalore, India
    Posts
    242

    Default

    Hi,

    what is the context of the web application that you have deployed on the tomcat?

    if you have deployed the web application as a war and the war name is sample.war then you can use the following url.

    Code:
    http://localhost:8080/sample/dsrapp/viewuom
    Sami

  3. #3

    Default

    i set the war file name as dsrapp.war... that was why i also tried the url http://localhost:8080/dsrapp/dsrapp/viewuom... and it didn't work...

    in addition to this... doesn't the <servlet-name> </servlet-name> tags (both in <servlet> and <servlet-mapping>) indicate the context being used? In the web.xml as shown above I used "dsrapp" and I'm not sure if this is actually referring to the context, or is the filename of the war file made as default context?
    Last edited by wowiesy; Jul 30th, 2007 at 11:25 AM.

  4. #4
    Join Date
    Mar 2006
    Location
    Bangalore, India
    Posts
    242

    Default

    Hi,
    <servlet>
    <servlet-name>dsrapp</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
    <init-param>
    <param-name>detectAllHandlerAdapters</param-name>
    <param-value>false</param-value>
    </init-param>
    <init-param>
    <param-name>detectAllHandlerExceptionResolvers</param-name>
    <param-value>false</param-value>
    </init-param>
    <init-param>
    <param-name>detectAllHandlerMappings</param-name>
    <param-value>false</param-value>
    </init-param>
    <init-param>
    <param-name>detectAllViewResolvers</param-name>
    <param-value>false</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>
    Can you comment all of the init-param's
    your servlet config should look like this.
    Code:
    <servlet>
    		<servlet-name>dsrapp</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    Sami

  5. #5
    Join Date
    Oct 2006
    Posts
    228

    Default

    Quote Originally Posted by wowiesy View Post
    i set the war file name as dsrapp.war... that was why i also tried the url http://localhost:8080/dsrapp/dsrapp/viewuom... and it didn't work...
    I'm pretty sure that URLs are case sensitive so try [urlhttp://localhost:8080/dsrapp/dsrapp/viewUom[/url]


    The mapping in web.xml is relative to the web application root.

    i.e. in tomcat if your war file is sample.war then the servlet mapping is for everything in the URL after locahost:8080/sample/.

    By default, the mapping in SimpleUrlHandlerMapping is relative to the servlet mapping in web.xml

    i.e. everything after localhost:8080/sample/servletmapping/.


    Chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •