• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Why NestedServletException?

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am new to Spring and have been trying to run a simple SpringMVC program and am getting the following error ..Can someone help me with this error?


08-Jul-2010 01:21:42 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;E:\Program Files\MySQL\MySQL Server 5.1\bin
08-Jul-2010 01:21:42 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:SpringApp' did not find a matching property.
08-Jul-2010 01:21:42 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
08-Jul-2010 01:21:42 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 551 ms
08-Jul-2010 01:21:42 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
08-Jul-2010 01:21:42 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.26
08-Jul-2010 01:21:43 org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(E:\Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\SpringApp\WEB-INF\lib\j2ee.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
08-Jul-2010 01:21:43 org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(E:\Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\SpringApp\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
08-Jul-2010 01:21:43 org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet springapp as unavailable
08-Jul-2010 01:21:43 org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /SpringApp threw load() exception
java.lang.ClassNotFoundException: org.springframework.web.util.NestedServletException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1116)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4187)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4496)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
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:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
08-Jul-2010 01:21:43 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
08-Jul-2010 01:21:43 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
08-Jul-2010 01:21:43 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/20 config=null
08-Jul-2010 01:21:43 org.apache.catalina.startup.Catalina start
INFO: Server startup in 485 ms
08-Jul-2010 01:22:07 org.apache.catalina.core.StandardWrapperValve invoke
INFO: Servlet springapp is currently unavailable


Code as follows:

web.xml

<?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>springapp</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>springapp</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>




springapp-servlet.xml

<?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.5.xsd">

<!-- the application context definition for the springapp DispatcherServlet -->

<bean name="/hello.htm" class="com.HelloController"/>
</beans>


HelloController.javal

package com;

import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.IOException;

public class HelloController implements Controller {
protected final Log logger = LogFactory.getLog(getClass());

public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

logger.info("Returning hello view");
System.out.println("Inside controller");
return new ModelAndView("hello.jsp");
}
}



I have all the jars in place.

Thanks in advance,
Jane.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you put the Spring jars in your WEB-INF/lib directory ?
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

INFO: validateJarFile(E:\Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\SpringApp\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class...


Looks like you have a servlet-api.jar & j2ee.jar inside the web application? Then remove them in the first place use the ones in the application server.
 
Jane Toma
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Christophe,

I have added all the jars in the lib folder.. the project is compiling in eclipse with no errors.

Jars as follows

commons-logging.jar
dom4j-1.6.1.jar
jstl.jar
spring-webmvc.jar
spring.jar
standard.jar

Also i have added the jars in the Project's Build Path.

Thanks,
Jane

 
Jane Toma
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vijitha,

I had added the servlet-api.jar and j2ee.jar.. but i have removed them now.
But then i have errors while compiling in eclipse.. how do you map to these jars present in the server.

Thanks,
Jane.
 
Vijitha Kumara
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jane Toma wrote:I had added the servlet-api.jar and j2ee.jar.. but i have removed them now. But then i have errors while compiling in eclipse.. how do you map to these jars present in the server.


You should add them as part of a library to the eclipse (by pointing the jars from the application server lib directory) that way same jars are used in both compiling and running. However you should not include them in your final application which is being deployed (essentially not including them inside WEB-INF/lib).
 
Jane Toma
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vijitha,

I have removed the jars from WEB-INF/lib and have created a library to point to jars in the web app.
But still the error persist..

Thanks,
Jane
 
Vijitha Kumara
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, Now tell us how you have deployed the application and the directory structure of the application inside the application server you are running the application?
 
Jane Toma
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ok, Now tell us how you have deployed the application and the directory structure of the application inside the application server you are running the application?



Answer to the first question.... i have the project(SpringApp) in the Eclipse Workspace, I do a right click and run on the server..and it gets automatically deployed on the server.


Answer to the second question...Physically i cannot view the SpringApp project inside the webapps..I have attached the directory structure of the project from the IDE.

piwo.jpg
[Thumbnail for piwo.jpg]
Directory Structure
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

i have the project(SpringApp) in the Eclipse Workspace


How are you launching the web application ? From Eclipse ? Which plugin are you using ? You might have to configure it to deploy the lib directory as well.
 
I knew I would regret that burrito. But this tiny ad has never caused regrets:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic