spring mvc with rest webservices using hibernate -
i working customer application using spring mvc restful webservice using hibernate. have created application dynamic web project in eclipse because if using maven getting few dependencies error.
as new these technologies don’t know have done mistake in configuring these files
i have configured follows in configuration files.
web.xml
<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="webapp_id" version="3.0"> <display-name>springwithrestcasestudy</display-name> <context-param> <param-name>root-context</param-name> <param-value>\web-inf\spring\appservlet\root- context.xml</paramvalue> </context-param> <servlet> <servlet-name>servlet-context</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>servlet-context</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <listener> <listener-class>org.springframework.web.context.requestcontextlistener</listener-class> </listener>
servlet-context.xml
<?xml version="1.0" encoding="utf-8"?> <beans:beans xmlns="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:task="http://www.springframework.org/schema/task" 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/task http://www.springframework.org/schema/task/spring-task.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"> <!-- dispatcherservlet context: defines servlet's request-processing infrastructure --> <!-- enables spring mvc @controller programming model --> <annotation-driven /> <resources location="/resources/" mapping="/resources/**"></resources> <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> <context:component-scan base-package="com.crud.rest.controllers" /> </beans:beans>
root-context.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" xmlns:c="htpp://www.springframework.org/schema/c" xmlns:p="htpp://www.springframework.org/schema/p" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> <!-- root context: defines shared resources visible other web components --> <bean id="datasource" class="org.springframework.jdbc.datasource.drivermanagerdatasource"> <property name="driverclassname" value="oracle.jdbc.driver.oracledriver"> </property> <property name="url" value="jdbc:oracle:thin:@172.16.156.152:1521:orcl"> </property> <property name="username" value="scott"></property> <property name="password" value="tiger"></property> </bean> <bean id="sessionfactory" class="org.springframework.orm.hibernate4.localsessionfactorybean"> <property name="datasource" ref="datasource"></property> <property name="hibernateproperties"> <props> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.dialect">org.hibernate.dialect.oracle10gdialect</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> </props> </property> <property name="annotatedclasses"> <list> <value>com.crud.rest.beans.mycustomer</value> </list> </property> </bean> <bean id="transactionmanager" class="org.springframework.orm.hibernate4.hibernatetransactionmanager"> <property name="sessionfactory" ref="sessionfactory"></property> </bean> <bean id="customerdao" class="com.crud.rest.dao.customerdaoimpl"> <property name="sessionfactory" ref="sessionfactory"></property> </bean> <bean id="customerservice" class="com.crud.rest.dao.customerserviceimpl"> <property name="customerdao" ref="customerdao"></property> </bean> </beans>
i getting error follows.
sep 12, 2017 12:52:55 pm org.apache.tomcat.util.digester.setpropertiesrule begin warning: [setpropertiesrule]{server/service/engine/host/context} setting property 'source' 'org.eclipse.jst.jee.server:shoppingdemo' did not find matching property. sep 12, 2017 12:52:55 pm org.apache.tomcat.util.digester.setpropertiesrule begin warning: [setpropertiesrule]{server/service/engine/host/context} setting property 'source' 'org.eclipse.jst.jee.server:springwithrestcasestudy' did not find matching property. sep 12, 2017 12:52:55 pm org.apache.catalina.startup.versionloggerlistener log info: server version: apache tomcat/8.0.37 sep 12, 2017 12:52:55 pm org.apache.catalina.startup.versionloggerlistener log info: server built: sep 1 2016 10:01:52 utc sep 12, 2017 12:52:55 pm org.apache.catalina.startup.versionloggerlistener log info: server number: 8.0.37.0 sep 12, 2017 12:52:55 pm org.apache.catalina.startup.versionloggerlistener log info: os name: windows 7 sep 12, 2017 12:52:55 pm org.apache.catalina.startup.versionloggerlistener log info: os version: 6.1 sep 12, 2017 12:52:55 pm org.apache.catalina.startup.versionloggerlistener log info: architecture: amd64 sep 12, 2017 12:52:55 pm org.apache.catalina.startup.versionloggerlistener log info: java home: c:\program files\java\jre1.8.0_66 sep 12, 2017 12:52:55 pm org.apache.catalina.startup.versionloggerlistener log info: jvm version: 1.8.0_66-b18 sep 12, 2017 12:52:55 pm org.apache.catalina.startup.versionloggerlistener log info: jvm vendor: oracle corporation sep 12, 2017 12:52:55 pm org.apache.catalina.startup.versionloggerlistener log info: catalina_base: d:\narmatha workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp2 sep 12, 2017 12:52:55 pm org.apache.catalina.startup.versionloggerlistener log info: catalina_home: d:\apache-tomcat-8.0.37 sep 12, 2017 12:52:55 pm org.apache.catalina.startup.versionloggerlistener log info: command line argument: -dcatalina.base=d:\narmatha workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp2 sep 12, 2017 12:52:55 pm org.apache.catalina.startup.versionloggerlistener log info: command line argument: -dcatalina.home=d:\apache-tomcat-8.0.37 sep 12, 2017 12:52:55 pm org.apache.catalina.startup.versionloggerlistener log info: command line argument: -dwtp.deploy=d:\narmatha workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps sep 12, 2017 12:52:55 pm org.apache.catalina.startup.versionloggerlistener log info: command line argument: -djava.endorsed.dirs=d:\apache-tomcat-8.0.37\endorsed sep 12, 2017 12:52:55 pm org.apache.catalina.startup.versionloggerlistener log info: command line argument: -dfile.encoding=cp1252 sep 12, 2017 12:52:55 pm org.apache.catalina.core.aprlifecyclelistener lifecycleevent info: apr based apache tomcat native library allows optimal performance in production environments not found on java.library.path: c:\program files\java\jre1.8.0_66\bin;c:\windows\sun\java\bin;c:\windows\system32;c:\windows;c:/program files/java/jre1.8.0_66/bin/server;c:/program files/java/jre1.8.0_66/bin;c:/program files/java/jre1.8.0_66/lib/amd64;c:\programdata\oracle\java\javapath;c:\windows\system32;c:\windows;c:\windows\system32\wbem;c:\windows\system32\windowspowershell\v1.0\;c:\progra~2\ca\sc\cam\bin;c:\windows\system32\windowspowershell\v1.0\;c:\oraclexe\app\oracle\product\10.2.0\server\bin;c:\tcl\bin;c:\windows\syswow64\;c:\windows\syswow64\wbem;c:\windows\system32\windowspowershell\v1.0\;d:\eclipse-jee-luna-sr2-win32-x86_64\eclipse;;. sep 12, 2017 12:52:55 pm org.apache.coyote.abstractprotocol init info: initializing protocolhandler ["http-nio-8080"] sep 12, 2017 12:52:55 pm org.apache.tomcat.util.net.nioselectorpool getsharedselector info: using shared selector servlet write/read sep 12, 2017 12:52:55 pm org.apache.coyote.abstractprotocol init info: initializing protocolhandler ["ajp-nio-8009"] sep 12, 2017 12:52:55 pm org.apache.tomcat.util.net.nioselectorpool getsharedselector info: using shared selector servlet write/read sep 12, 2017 12:52:55 pm org.apache.catalina.startup.catalina load info: initialization processed in 1524 ms sep 12, 2017 12:52:55 pm org.apache.catalina.core.standardservice startinternal info: starting service catalina sep 12, 2017 12:52:55 pm org.apache.catalina.core.standardengine startinternal info: starting servlet engine: apache tomcat/8.0.37 sep 12, 2017 12:53:00 pm org.apache.jasper.servlet.tldscanner scanjars info: @ least 1 jar scanned tlds yet contained no tlds. enable debug logging logger complete list of jars scanned no tlds found in them. skipping unneeded jars during scanning can improve startup time , jsp compilation time. sep 12, 2017 12:53:00 pm org.apache.catalina.core.applicationcontext log info: marking servlet dispatcher unavailable sep 12, 2017 12:53:00 pm org.apache.catalina.core.standardcontext loadonstartup severe: servlet [dispatcher] in web application [/shoppingdemo] threw load() exception java.lang.classnotfoundexception: org.springframework.web.servlet.disptacherservlet @ org.apache.catalina.loader.webappclassloaderbase.loadclass(webappclassloaderb ase.java:1333) @ org.apache.catalina.loader.webappclassloaderbase.loadclass(webappclassloaderb ase.java:1167) @ org.apache.catalina.core.defaultinstancemanager.loadclass(defaultinstancemana ger.java:518) @ org.apache.catalina.core.defaultinstancemanager.loadclassmaybeprivileged(defa ultinstancemanager.java:499) @ org.apache.catalina.core.defaultinstancemanager.newinstance(defaultinstancema nager.java:118) @ org.apache.catalina.core.standardwrapper.loadservlet(standardwrapper.java:109 1) @ org.apache.catalina.core.standardwrapper.load(standardwrapper.java:1027) @ org.apache.catalina.core.standardcontext.loadonstartup(standardcontext.java:5 038) @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5 348) @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:145) @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:140 7) @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:139 7) @ java.util.concurrent.futuretask.run(unknown source) @ java.util.concurrent.threadpoolexecutor.runworker(unknown source) @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) @ java.lang.thread.run(unknown source) sep 12, 2017 12:53:00 pm org.apache.catalina.core.standardcontext listenerstart severe: error configuring application listener of class org.springframework.web.context.contextloaderlistener java.lang.classnotfoundexception: org.springframework.web.context.contextloaderlistener @ org.apache.catalina.loader.webappclassloaderbase.loadclass(webappclassloaderb ase.java:1333) @ org.apache.catalina.loader.webappclassloaderbase.loadclass(webappclassloaderb ase.java:1167) @ org.apache.catalina.core.defaultinstancemanager.loadclass(defaultinstancemanager.java:518) @ org.apache.catalina.core.defaultinstancemanager.loadclassmaybeprivileged(defaultinstancemanager.java:499) @ org.apache.catalina.core.defaultinstancemanager.newinstance(defaultinstancema nager.java:118) @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:4 775) @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5 314) @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:145) @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1407) @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:130 9) @ java.util.concurrent.futuretask.run(unknown source) @ java.util.concurrent.threadpoolexecutor.runworker(unknown source) @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) @ java.lang.thread.run(unknown source) sep 12, 2017 12:53:00 pm org.apache.catalina.core.standardcontext listenerstart severe: error configuring application listener of class org.springframework.web.context.requestcontextlistener java.lang.classnotfoundexception: org.springframework.web.context.requestcontextlistener @ org.apache.catalina.loader.webappclassloaderbase.loadclass(webappclassloaderb ase.java:1333) @ org.apache.catalina.loader.webappclassloaderbase.loadclass(webappclassloaderb ase.java:1167) @ org.apache.catalina.core.defaultinstancemanager.loadclass(defaultinstancemana ger.java:518) @ org.apache.catalina.core.defaultinstancemanager.loadclassmaybeprivileged(defa ultinstancemanager.java:499) @ org.apache.catalina.core.defaultinstancemanager.newinstance(defaultinstancema nager.java:118) @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:4 775) @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5 314) @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:145) @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1407) @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1397) @ java.util.concurrent.futuretask.run(unknown source) @ java.util.concurrent.threadpoolexecutor.runworker(unknown source) @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) @ java.lang.thread.run(unknown source) sep 12, 2017 12:53:00 pm org.apache.catalina.core.standardcontext listenerstart severe: skipped installing application listeners due previous error(s) sep 12, 2017 12:53:00 pm org.apache.catalina.core.standardcontext startinternal severe: 1 or more listeners failed start. full details found in appropriate container log file sep 12, 2017 12:53:00 pm org.apache.catalina.core.standardcontext startinternal severe: context [/springwithrestcasestudy] startup failed due previous errors sep 12, 2017 12:53:01 pm org.apache.coyote.abstractprotocol start info: starting protocolhandler ["http-nio-8080"] sep 12, 2017 12:53:01 pm org.apache.coyote.abstractprotocol start info: starting protocolhandler ["ajp-nio-8009"] sep 12, 2017 12:53:01 pm org.apache.catalina.startup.catalina start info: server startup in 5154 ms
kindly me solve issue.
and more helpful if can provide details of how configure these 3 files.
might solution.
the solution problem simple. double click on tomcat server. open server configuration. under server options check ‘publish module contents separate xml files’ checkbox. restart server. time page come without issues.
Comments
Post a Comment