java


HTTP Status 500 - Servlet.init() for servlet appServlet threw exception in spring MVC


There is so many of this error in stackoverflow but I could not resolver my issue from is. Below is my simple configurations :
context.xml from my TOMCAT server where I have configured a datasource for accessing my oracle 11g server
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<!--Oracle DataSource-->
<Resource
name="jdbc/MonDataSource"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:#localhost:1521:orcl"
username="system"
password="Azerty123"
connectionProperties="SetBigStringTryClob=true"
accessToUnderlyingConnectionAllowed="true"
maxTotal="60"
maxIdle="20"
maxWaitMillis="10000"
/>
</Context>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
servlet-context.xml to show my bean configuration
<beans:bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<beans:property name="jndiName" value="java:comp/env/jdbc/MonDataSource"/>
</beans:bean>
<beans:bean id="ArticleDAO" class="com.projet.testjdbc.ArticleDAOImpl">
<beans:constructor-arg>
<beans:ref bean="dataSource" />
</beans:constructor-arg>
</beans:bean>
</beans:beans>
I don't know if it'll be usefull but you have below my controller action
#Controller
public class HomeController {
#Autowired
private ArticleDAO aricleDAO;
#RequestMapping(value="/liste")
public ModelAndView home() throws IOException{
List<Article> listArticles = aricleDAO.list();
ModelAndView model = new ModelAndView("home");
model.addObject("articleListe", listArticles);
return model;
}
}
EXCEPTIONS MESSAGES EXCERPT
exception
javax.servlet.ServletException: Servlet.init() for servlet appServlet threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79
...
root cause
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'homeController': Unsatisfied dependency expressed through field 'aricleDAO'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ArticleDAO': Failed to introspect bean class [com.projet.testjdbc.ArticleDAOImpl] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/core/RowMapper
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588)
org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
...
root cause
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ArticleDAO': Failed to introspect bean class [com.projet.testjdbc.ArticleDAOImpl] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/core/RowMapper
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:269)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1118)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1091)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
...
root cause
java.lang.NoClassDefFoundError: org/springframework/jdbc/core/RowMapper
java.lang.Class.getDeclaredMethods0(Native Method)
java.lang.Class.privateGetDeclaredMethods(Unknown Source)
java.lang.Class.getDeclaredMethods(Unknown Source)
org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613)
org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524)
org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:510)
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:247)
...
root cause
java.lang.ClassNotFoundException: org.springframework.jdbc.core.RowMapper
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
java.lang.Class.getDeclaredMethods0(Native Method)
java.lang.Class.privateGetDeclaredMethods(Unknown Source)
java.lang.Class.getDeclaredMethods(Unknown Source)
org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613)
org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524)
...
root cause java.lang.ClassNotFoundException: org.springframework.jdbc.core.RowMapper
Looks like you miss a dependency. Add this to maven (if you use it)
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>2.0.6</version>
</dependency>
If not add the .jar to classpath

Related Links

How can I reference to an element on an ArrayList of objects. to invoke some method on that object
Make a dynamically re-sized, BufferedImage, scroll, that renders actively
Manual Object serialisation
Java NoSuchElementException on nextInt
Java: Get Float and String value from a String
Android wear in app purchases
How check action bar is visible?
Adding functions to Thread class in Java
How to configure StatisticsCsvLayout in log4j2
Mockito verify that method is called with correct argument using regex
Algorithm sometimes works
NoClassDefFoundError at Runtime on class inside .AAR in Android Studio
In Java, why does String == String evaluate to true inside a method (as opposed to using .equals())? [duplicate]
How to open file in META-INF independent of environment
How getLineNumber() method in StackTraceElement class find actual line number of java source file
500 - servlet.init() for servlet jersey rest service threw exception

Categories

HOME
twitter
amazon-ec2
zeromq
magnific-popup
urbancode
hashmap
grep
sqlite-net-extensions
jxls
networkx
basic
cloudkit
floating-action-button
numeral.js
google-cloud-spanner
jplayer
task
quartz-scheduler
vaadin7
uitypeeditor
libtiff
foselasticabundle
google-static-maps
physics-engine
abi
wijmo
blazemeter
dxf
p-value
tinymce-4
phonegap
typed.js
openoffice.org
android-nestedscrollview
scaffold
multilingual
occlusion
splice
streamreader
gulp-sourcemaps
texmaker
estimote
midl
outlook-api
unixodbc
netcdf4
gpx
paxos
jlink
powercli
pg-dump
imanage
spring-cache
lync-client-sdk
vmware-tools
savon
login-control
mathematica-frontend
impresspages
plottable.js
flash-cs5
qcustomplot
bgp
design-by-contract
photobucket
separator
spim
endeca-workbench
iis-arr
coveralls
tarjans-algorithm
wyam
rgeo
dukescript
method-parameters
iiviewdeckcontroller
oberon
csquery
operator-precedence
gwidgets
clicktag
google-style-guide
phalanger
websocket4net
preferences
code-access-security
document-classification
cloud-connect
mcts
spring-io
listings
ruby-datamapper
bulkloader
comaddin
interface-orientation
lcs
cassini-dev
gil
chrono
windows-phone-7.1.1
rfc1123
imac
photoshop-cs4
gacutil
django-notification

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App