Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Page not displayed

  1. #1

    Default Page not displayed

    Hey guys. Well this is my first time working with a spring framework. I am having some problems in (Injecting beans) + i am kinda confused of the concept behind spring mvc framework. Well first of all my problem is this

    Code:
    WARN [org.springframework.web.servlet.PageNotFound] No mapping for [/abc/index.htm] in DispatcherServlet with name 'abc'
    here is my web.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    	
    	
    		
    	<servlet>
    <servlet-name>abc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
      </servlet>
    		
    		
    	<servlet-mapping>
    		<servlet-name>abc</servlet-name>
    		<url-pattern>*.htm</url-pattern>
    	</servlet-mapping>
    	
    	
                    // i am getting a red cross sign besides the tag lib also in jbuilder 2007
                   <taglib>
    		<taglib-uri>/spring</taglib-uri>
    		<taglib-location>/WEB-INF/spring.tld</taglib-location>
    	</taglib>
      
      	<welcome-file-list>
    		<welcome-file>index.jsp</welcome-file>
    	</welcome-file-list>
    	
    </web-app>
    here is my abc-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="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
      <property name="driverClassName">
     	<value>com.mysql.jdbc.Driver</value>
      </property>
     
      <property name="url">
     	<value>jdbc:mysql://localhost/stores</value>
      </property>
     
      <property name="username">
     	<value>jhtp6</value>
      </property>
     
      <property name="password">
     	<value>jhtp6</value>
      </property>
      
     </bean>
     
     <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>
     </bean>
     
      <bean id="quantityOnHandDao" class="com.database.daoimpl.QuantityOnHandDaoImpl">
    		 <property name="jdbcTemplate">
    			 <ref bean="jdbcTemplate" />
    		 </property>
    		     
    		 <property name="dataSource">
    		     <ref bean="dataSource"/>
    		 </property>
    		 
       </bean>	
       
      
      <bean id="quantityOnHandController" class="com.database.controller.QuantityOnHandController"> 
      </bean>
     
        <bean id="simpleUrlMapping"
    	class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    	<property name="mappings">
    	<props>
    	<prop key="/quantityOnHandForm.htm">quantityOnHandController</prop>
    	</props>
    	</property>
    	</bean>
        
    	    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
            <property name="prefix" value="/WEB-INF/jsp/"/>
            <property name="suffix" value=".jsp"/>
        </bean>
        
    </beans>
    I have one more question but i will leave it for later on. Thanks

  2. #2

    Default

    What is your deployment context? The URI you probably want is:

    Code:
    /{servlet context}/
    to get the default jsp page.

  3. #3

    Default

    thanks for the reply. When you said deployment context you meant application-context.xml? or something else. I dont have any application-context.xml

  4. #4

    Default

    anyone care to reply ?

  5. #5
    Join Date
    Sep 2004
    Location
    Manchester, NH
    Posts
    1,236

    Default

    Quote Originally Posted by christopher1234 View Post
    anyone care to reply ?
    Deployment context = what is the path to your deployed web application?
    Peter Mularien | Blog
    Author, Spring Security 3 (Book) - Packt Publishing, Available in print and eBook form
    SCJP 5, Oracle DBA
    Any postings are my own opinion, and should not be attributed to my employer or clients.


  6. #6

    Default

    ok thanks for the reply. Actually that was not the problem. The problem was in my abc-servlet.xml(spelling mistake). But now i am getting another error. :

    Code:
    ERROR [org.springframework.web.servlet.DispatcherServlet] Context initialization failed
    java.lang.ClassNotFoundException: cannot find the class

    I can see my controller class under com.database.controller.QuantityOnHandController but everytime i try to run my application i get this error under tomcat. The solution provided in this thread is also not working for me.

    http://forum.springframework.org/showthread.php?t=40265

    Thank you

  7. #7
    Join Date
    Sep 2004
    Location
    Manchester, NH
    Posts
    1,236

    Default

    Please post the full error message and stack trace.
    Peter Mularien | Blog
    Author, Spring Security 3 (Book) - Packt Publishing, Available in print and eBook form
    SCJP 5, Oracle DBA
    Any postings are my own opinion, and should not be attributed to my employer or clients.


  8. #8

    Default

    Here is my stack trace.

    Code:
    ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
    org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.database.daoimpl.InsertQuantityOnHandDaoImpl] for bean with name 'insertQuantityOnHandDao' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: com.database.daoimpl.InsertQuantityOnHandDaoImpl
    Caused by: 
    java.lang.ClassNotFoundException: com.database.daoimpl.InsertQuantityOnHandDaoImpl
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1362)
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1208)
    	at org.springframework.util.ClassUtils.forName(ClassUtils.java:229)
    	at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:327)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1073)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:283)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
    	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:245)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:188)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
    	at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
    	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    	at org.apache.catalina.core.StandardService.start(StandardService.java:448)
    	at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
    	at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
    	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
    ERROR [catalina.core.ContainerBase.[Catalina].[localhost].[/DatabaseMassUpdate]] Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.database.daoimpl.InsertQuantityOnHandDaoImpl] for bean with name 'insertQuantityOnHandDao' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: com.database.daoimpl.InsertQuantityOnHandDaoImpl
    Caused by: 
    java.lang.ClassNotFoundException: com.database.daoimpl.InsertQuantityOnHandDaoImpl
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1362)
    abc-servlet.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.0.xsd">
    
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
      <property name="driverClassName">
     	<value>com.mysql.jdbc.Driver</value>
      </property>
     
      <property name="url">
     	<value>jdbc:mysql://localhost/stores</value>
      </property>
     
      <property name="username">
     	<value>jhtp6</value>
      </property>
     
      <property name="password">
     	<value>jhtp6</value>
      </property>
      
     </bean>
     
     <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>
     </bean>
     
     
        <bean name="simpleUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    		<property name="mappings">
    	<props>
    	<prop key="/insertQuantityOnHandForm">insertQuantityOnHandController</prop>
    	</props>
    	</property>
    	</bean>
        
         <bean id="insertQuantityOnHandController" class="com.database.controller.InsertQuantityOnHandController" >
         <property name="insertQuantityOnHandDao"><ref bean ="insertQuantityOnHandDao"/></property> 
         <property name="commandName"><value>insertQuantityOnHand</value></property>
         <property name="commandClass"><value>com.database.model.InsertQuantityOnHand</value></property>
         <property name="formView"><value>insertQuantityOnHandForm</value></property>
         </bean>
         
    	    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
            <property name="prefix" value="/WEB-INF/jsp/"/>
            <property name="suffix" value=".jsp"/>
        </bean>
        
    
    </beans>
    web.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    	
    	<display-name>abc</display-name>
    	
    	<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>abc</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<load-on-startup>2</load-on-startup>
      </servlet>
    
    	<servlet-mapping>
    		<servlet-name>abc</servlet-name>
    		<url-pattern>*.htm</url-pattern>
    	</servlet-mapping>
    	
    	<taglib>
    		<taglib-uri>/spring</taglib-uri>
    		<taglib-location>/WEB-INF/spring.tld</taglib-location>
    	</taglib>
      
      	<welcome-file-list>
    		<welcome-file>index.jsp</welcome-file>
    	</welcome-file-list>
    	
    </web-app>
    applicationContext.xml
    Code:
        <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.0.xsd">
      
      <bean id="insertQuantityOnHandDao" class="com.database.daoimpl.InsertQuantityOnHandDaoImpl" >
      <property name="dataSource"><ref bean="dataSource"/></property>
      </bean>
      
      </beans>

  9. #9
    Join Date
    Sep 2004
    Location
    Manchester, NH
    Posts
    1,236

    Default

    Just to hazard a guess, is it possible that you have the name of the DAO class wrong? "com.database.daoimpl.InsertQuantityOnHandDaoI mpl" is what you have in the configuration file - is that the correct fully-qualified class name?
    Peter Mularien | Blog
    Author, Spring Security 3 (Book) - Packt Publishing, Available in print and eBook form
    SCJP 5, Oracle DBA
    Any postings are my own opinion, and should not be attributed to my employer or clients.


  10. #10

    Default

    Code:
    package com.abc.daoimpl;
    
    
    import java.sql.Timestamp;
    import java.sql.Types;
    import java.sql.Date;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.HashMap;
    import java.util.Map;
    
    import javax.sql.DataSource;
    
    
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import org.springframework.dao.DataAccessException;
    import org.springframework.jdbc.core.JdbcTemplate;
    import org.springframework.jdbc.core.SqlParameter;
    import org.springframework.jdbc.object.SqlUpdate;
    
    import com.abc.dao.InsertQuantityOnHandDao;
    import com.abc.model.InsertQuantityOnHand;
    
    public class InsertQuantityOnHandDaoImpl implements InsertQuantityOnHandDao{
    .
    .
    .
    Thanks for the reply. I dont think there is anything wrong with the name.

Posting Permissions

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