java - HTTP Status 500 - Servlet.init() for servlet appServlet threw exception (spring4 hibernate4) -
i finished this tutorial (spring4 , hibernate4) , got msg:
javax.servlet.servletexception: servlet.init() servlet appservlet threw exception org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:502) org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:79) org.apache.catalina.valves.abstractaccesslogvalve.invoke(abstractaccesslogvalve.java:617) org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:518) org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1091) org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:668) org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:277) java.util.concurrent.threadpoolexecutor.runworker(unknown source) java.util.concurrent.threadpoolexecutor$worker.run(unknown source) org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61) java.lang.thread.run(unknown source) root cause org.springframework.beans.factory.xml.xmlbeandefinitionstoreexception: line 44 in xml document servletcontext resource [/web-inf/spring/appservlet/servlet-context.xml] invalid; nested exception org.xml.sax.saxparseexception; linenumber: 44; columnnumber: 26; cvc-complex-type.2.4.c: matching wildcard strict, no declaration can found element 'tx:annotation-driven'. org.springframework.beans.factory.xml.xmlbeandefinitionreader.doloadbeandefinitions(xmlbeandefinitionreader.java:398) org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinitionreader.java:335) org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinitionreader.java:303) org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:180) org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:216) org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:187) org.springframework.web.context.support.xmlwebapplicationcontext.loadbeandefinitions(xmlwebapplicationcontext.java:125) org.springframework.web.context.support.xmlwebapplicationcontext.loadbeandefinitions(xmlwebapplicationcontext.java:94) org.springframework.context.support.abstractrefreshableapplicationcontext.refreshbeanfactory(abstractrefreshableapplicationcontext.java:129) org.springframework.context.support.abstractapplicationcontext.obtainfreshbeanfactory(abstractapplicationcontext.java:540) org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:454) org.springframework.web.servlet.frameworkservlet.configureandrefreshwebapplicationcontext(frameworkservlet.java:658) org.springframework.web.servlet.frameworkservlet.createwebapplicationcontext(frameworkservlet.java:624) org.springframework.web.servlet.frameworkservlet.createwebapplicationcontext(frameworkservlet.java:672) org.springframework.web.servlet.frameworkservlet.initwebapplicationcontext(frameworkservlet.java:543) org.springframework.web.servlet.frameworkservlet.initservletbean(frameworkservlet.java:484) org.springframework.web.servlet.httpservletbean.init(httpservletbean.java:136) javax.servlet.genericservlet.init(genericservlet.java:158) org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:502) org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:79) org.apache.catalina.valves.abstractaccesslogvalve.invoke(abstractaccesslogvalve.java:617) org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:518) org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1091) org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:668) org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:277) java.util.concurrent.threadpoolexecutor.runworker(unknown source) java.util.concurrent.threadpoolexecutor$worker.run(unknown source) org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61) java.lang.thread.run(unknown source) , ...
web.xml
<?xml version="1.0" encoding="utf-8"?>
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- definition of root spring container shared servlets , filters --> <context-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/spring/root-context.xml</param-value> </context-param> <!-- creates spring container shared servlets , 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
<?xml version="1.0" encoding="utf-8"?> <beans:beans xmlns="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xsi:schemalocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd 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/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd"> <!-- dispatcherservlet context: defines servlet's request-processing infrastructure --> <!-- enables spring mvc @controller programming model --> <annotation-driven /> <resources mapping="/resources/**" location="/resources/" /> <context:component-scan base-package="com.terafast.hibernate" /> <!-- handles http requests /resources/** efficiently serving static resources in ${webapproot}/resources directory --> <resources mapping="/resources/**" location="/resources/" /> <!-- resolves views selected rendering @controllers .jsp resources in /web-inf/views directory --> <beans:bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <beans:property name="prefix" value="/web-inf/views/" /> <beans:property name="suffix" value=".jsp" /> </beans:bean> <beans:bean id="datasource" class="org.apache.commons.dbcp2.basicdatasource" destroy-method="close"> <beans:property name="driverclassname" value="com.mysql.jdbc.driver" /> <beans:property name="url" value="jdbc:mysql://localhost/test" /> <beans:property name="username" value="root" /> <beans:property name="password" value="xxx" /> </beans:bean> <beans:bean id="sessionfactory" class="org.springframework.orm.hibernate4.localsessionfactorybean"> <beans:property name="datasource" ref="datasource" /> <beans:property name="configlocation" value="classpath:hibernate.cfg.xml" /> </beans:bean> <tx:annotation-driven /> <beans:bean id="transactionmanager" class="org.springframework.orm.hibernate4.hibernatetransactionmanager"> <beans:property name="sessionfactory" ref="sessionfactory" /> </beans:bean> <beans:bean id="userdao" class="com.terafast.hibernate.dao.userdaoimpl"> <beans:constructor-arg> <beans:ref bean="sessionfactory" /> </beans:constructor-arg> </beans:bean> <context:component-scan base-package="com.terafast.hibernate" /> </beans:beans>
could explain problem?
you forgot declare xml namespace tx
prefix ?
Comments
Post a Comment