HTTP状态500 - servlet appServlet的Servlet.init()在spring MVC

时间:2017-05-12 08:53:47

标签: java spring oracle tomcat servlets

stackoverflow中有这么多错误,但我无法解决我的问题。以下是我的简单配置:

来自我的TOMCAT服务器的

context.xml ,我已经配置了一个数据源来访问我的oracle 11g服务器

<?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 以显示我的bean配置

    <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>

我不知道它是否有用但你的控制器动作

@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消息摘录

  

例外   javax.servlet.ServletException:servlet appServlet的Servlet.init()抛出异常     org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)     org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79     ...

     

根本原因   org.springframework.beans.factory.UnsatisfiedDependencyException:使用名称&#39; homeController创建bean时出错:通过字段'aricleDAO&#39;表达的不满意的依赖性;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名称为&#39; ArticleDAO&#39;:无法为查找方法元数据内省bean类[com.projet.testjdbc.ArticleDAOImpl]时出错:找不到类这取决于;嵌套异常是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)     ...

     

根本原因   org.springframework.beans.factory.BeanCreationException:创建名称为&#39; ArticleDAO&#39;:无法为查找方法元数据内省bean类[com.projet.testjdbc.ArticleDAOImpl]时出错:找不到它依赖的类上;嵌套异常是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)     ...

     

根本原因   java.lang.NoClassDefFoundError:org / springframework / jdbc / core / RowMapper     java.lang.Class.getDeclaredMethods0(本机方法)     java.lang.Class.privateGetDeclaredMethods(未知来源)     java.lang.Class.getDeclaredMethods(未知来源)     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)     ...

     

根本原因   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(本机方法)       java.lang.Class.privateGetDeclaredMethods(未知来源)       java.lang.Class.getDeclaredMethods(未知来源)     org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613)     org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524)       ...

  

0 个答案:

没有答案