Announcement Announcement Module
Collapse
No announcement yet.
Page not displayed Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    What is your deployment context? The URI you probably want is:

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

    Comment


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

      Comment


      • #4
        anyone care to reply ?

        Comment


        • #5
          Originally posted by christopher1234 View Post
          anyone care to reply ?
          Deployment context = what is the path to your deployed web application?

          Comment


          • #6
            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

            Comment


            • #7
              Please post the full error message and stack trace.

              Comment


              • #8
                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>

                Comment


                • #9
                  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?

                  Comment


                  • #10
                    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.

                    Comment


                    • #11
                      "com.abc" != "com.database"

                      Try using the Spring IDE (or better yet the SpringSource Tool Suite ), it will catch these errors for you.

                      Comment


                      • #12
                        iwein. Thanks for pointing that problem out. Unfortunately same thing is happening. So i did a little research and came to know that under eclipse build folder i cannot see my insertQuantityOnHandController and couple of other classes. Eclipse should automatically create class files once compile as javabean classes or when restarting tomcat server. This is the problem i am having at work and will try to figure out on Monday.

                        Secondly when i try to run in JBUilder all the necessary classes are created. I have some other questions also and hope to keep this thread open or may be open a new thread for a new question. Sorry to bother you guys but this is my first time using springframework. Starting is always hard but once you get the concept clear then everything is easy for you.

                        i was wondering i am using JBuilder at home and eclipse at work. Can i install spring ide in my jbuilder and in eclipse? Can you give me some url

                        Thanks alot bro.

                        Comment


                        • #13
                          I've never worked with JBuilder, but most ide's have decent plugins for Spring. Spring IDE is an eclipse plugin though, so you'll have to work with Eclipse.

                          Check out http://springide.org/project/wiki/SpringideInstall. Good luck.

                          Comment

                          Working...
                          X