Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying out Spring 3 MVC, Getting a page error
    primarykey
    data
    text
    <p>Trying to configure spring 3 MVC, here is what I did so far:</p> <p>I added all the spring 3.0 libraries to my netbeans project.</p> <p>My web.xml is:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt; &lt;servlet&gt; &lt;servlet-name&gt;WebApplication1&lt;/servlet-name&gt; &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt; &lt;load-on-startup&gt;2&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;WebApplication1&lt;/servlet-name&gt; &lt;url-pattern&gt;/&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;/web-app&gt; </code></pre> <p>Next I created a WebAppliation1-servlet.xml, also in my /web-inf folder:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!-- - DispatcherServlet application context for PetClinic's web tier. --&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:oxm="http://www.springframework.org/schema/oxm" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd"&gt; &lt;!-- - The controllers are autodetected POJOs labeled with the @Controller annotation. --&gt; &lt;context:component-scan base-package="org.springframework.Hi"/&gt; &lt;!-- - The form-based controllers within this application provide @RequestMapping - annotations at the type level for path mapping URLs and @RequestMapping - at the method level for request type mappings (e.g., GET and POST). - In contrast, ClinicController - which is not form-based - provides - @RequestMapping only at the method level for path mapping URLs. - - DefaultAnnotationHandlerMapping is driven by these annotations and is - enabled by default with Java 5+. --&gt; &lt;!-- - This bean resolves specific types of exceptions to corresponding logical - view names for error views. The default behaviour of DispatcherServlet - is to propagate all exceptions to the servlet container: this will happen - here with all other types of exceptions. --&gt; &lt;bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"&gt; &lt;property name="exceptionMappings"&gt; &lt;props&gt; &lt;prop key="org.springframework.web.servlet.PageNotFound"&gt;pageNotFound&lt;/prop&gt; &lt;prop key="org.springframework.dao.DataAccessException"&gt;dataAccessFailure&lt;/prop&gt; &lt;prop key="org.springframework.transaction.TransactionException"&gt;dataAccessFailure&lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;/bean&gt; &lt;!-- - The BeanNameViewResolver is used to pick up the visits view name (below). - It has the order property set to 2, which means that this will - be the first view resolver to be used after the delegating content - negotiating view resolver. --&gt; &lt;bean class="org.springframework.web.servlet.view.BeanNameViewResolver" p:order="1"/&gt; &lt;!-- - This bean configures the 'prefix' and 'suffix' properties of - InternalResourceViewResolver, which resolves logical view names - returned by Controllers. For example, a logical view name of "vets" - will be mapped to "/WEB-INF/jsp/vets.jsp". --&gt; &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" p:order="2"/&gt; &lt;/beans&gt; </code></pre> <p>I then created a simple welcome.jsp in the folder /WEB-INF/jsp/welcome.jsp</p> <p>I then created a package:</p> <p>org.springframework.Hi</p> <p>And I created a TestController.java file:</p> <p>package org.springframework.Hi;</p> <pre><code>/* * To change this template, choose Tools | Templates * and open the template in the editor. */ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; @Controller public class TestController { @RequestMapping("/") public String welcomeHandler(){ return "welcome"; } } </code></pre> <p>I wanted this to work w/o any file extensions, so I don't have to end my urls with xxx.htm etc.</p> <p>So when I run the netbeans project I get the error:</p> <blockquote> <pre><code>type Status report message Servlet WebApplication1 is not available description The requested resource (Servlet WebApplication1 is not </code></pre> <p>available) is not available.</p> </blockquote> <p>What exactly am I missing here?</p> <p><b>Tomcat logs</b></p> <p>Thanks for the feedback</p> <p><strong>My tomcat logs show this:</strong></p> <pre><code>SEVERE: Servlet /WebApplication1 threw load() exception java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316) at org.springframework.web.servlet.DispatcherServlet.&lt;clinit&gt;(DispatcherServlet.java:207) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload