java - Spring MVC Hibernate Specified JDBC Driver oracle.jdbc.pool.OracleDataSource could not be loaded error -
i trying integrate hibernate spring. until dont introduce hibernate code & libraries, works fine. here code,
welcome-servlet.xml
<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" 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.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd" xmlns:mvc="http://www.springframework.org/schema/mvc"> <context:annotation-config /> <context:component-scan base-package="java4s" /> <mvc:annotation-driven /> <bean id="employeeservice" class="java4s.service.employeeserviceimpl" /> <bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="prefix" value="/jsp/" /> <property name="suffix" value=".jsp" /> </bean> <bean id="sessionfactory" class="org.springframework.orm.hibernate4.localsessionfactorybean"> <property name="datasource" ref="datasource" /> <property name="configlocation"> <value>classpath:hibernate.cfg.xml</value> </property> <property name="hibernateproperties"> <props> <prop key="hibernate.dialect">${jdbc.dialect}</prop> <prop key="hibernate.show_sql">true</prop> </props> </property> </bean> <bean id="datasource" class="org.springframework.jdbc.datasource.drivermanagerdatasource" p:driverclassname="oracle.jdbc.pool.oracledatasource" p:url="jdbc:oracle:thin:@localhost:1521:ims" p:username="username" p:password="password" /> </beans>
controller.java
public boolean validatelogin(string username, string password) { // todo auto-generated method stub configuration configuration = new configuration(); configuration.configure(); serviceregistry serviceregistry = new serviceregistrybuilder().applysettings(configuration.getproperties()).buildserviceregistry(); sessionfactory sessionfactory = configuration.buildsessionfactory(serviceregistry); session session = sessionfactory.opensession(); session.begintransaction(); query query = session.createquery("select count(*) employeeinfo username = ? , password = ?"); query.setstring(1, username); query.setstring(2, password); return query.list().size() > 0; }
libraries
antlr-2.7.7 aopalliance-1.0 classmate-1.0.0 commons-logging-1.2 dom4j-1.6.1 hibernate-commons-annotations-4.0.5.final hibernate-core-4.3.10.final hibernate-jpa-2.1-api-1.0.0.final hibernate-validator-5.1.3.final jandex-1.1.0.final javassist-3.18.1-ga javax.servlet-api-3.1.0 javax.servlet.jsp-api-2.3.1 jboss-logging-3.1.3.ga jboss-logging-annotations-1.2.0.beta1 jboss-transaction-api_1.2_spec-1.0.0.final jstl-1.2 ojdbc6 spring-aop-4.1.7.release spring-beans-4.1.7.release spring-context-4.1.7.release spring-core-4.1.7.release spring-expression-4.1.7.release spring-jdbc-4.1.7.release spring-orm-4.1.7.release spring-tx-4.1.7.release spring-web-4.1.7.release spring-webmvc-4.1.7.release validation-api-1.1.0.final xml-apis-1.0.b2
error
org.springframework.web.util.nestedservletexception: request processing failed; nested exception org.hibernate.service.spi.serviceexception: specified jdbc driver oracle.jdbc.pool.oracledatasource not loaded org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:979) org.springframework.web.servlet.frameworkservlet.dopost(frameworkservlet.java:869) javax.servlet.http.httpservlet.service(httpservlet.java:647) org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:843) javax.servlet.http.httpservlet.service(httpservlet.java:728) root cause org.hibernate.service.spi.serviceexception: specified jdbc driver oracle.jdbc.pool.oracledatasource not loaded org.hibernate.engine.jdbc.connections.internal.drivermanagerconnectionproviderimpl.loaddriverifpossible(drivermanagerconnectionproviderimpl.java:205) org.hibernate.engine.jdbc.connections.internal.drivermanagerconnectionproviderimpl.buildcreator(drivermanagerconnectionproviderimpl.java:156) org.hibernate.engine.jdbc.connections.internal.drivermanagerconnectionproviderimpl.configure(drivermanagerconnectionproviderimpl.java:95) org.hibernate.boot.registry.internal.standardserviceregistryimpl.configureservice(standardserviceregistryimpl.java:111) org.hibernate.service.internal.abstractserviceregistryimpl.initializeservice(abstractserviceregistryimpl.java:234) org.hibernate.service.internal.abstractserviceregistryimpl.getservice(abstractserviceregistryimpl.java:206) org.hibernate.engine.jdbc.internal.jdbcservicesimpl.buildjdbcconnectionaccess(jdbcservicesimpl.java:260) org.hibernate.engine.jdbc.internal.jdbcservicesimpl.configure(jdbcservicesimpl.java:94) org.hibernate.boot.registry.internal.standardserviceregistryimpl.configureservice(standardserviceregistryimpl.java:111) org.hibernate.service.internal.abstractserviceregistryimpl.initializeservice(abstractserviceregistryimpl.java:234) org.hibernate.service.internal.abstractserviceregistryimpl.getservice(abstractserviceregistryimpl.java:206) org.hibernate.cfg.configuration.buildtyperegistrations(configuration.java:1887) org.hibernate.cfg.configuration.buildsessionfactory(configuration.java:1845) java4s.service.employeeserviceimpl.validatelogin(employeeserviceimpl.java:58) java4s.controller.loginsuccesscontroller.loginvalidateform(loginsuccesscontroller.java:61) sun.reflect.nativemethodaccessorimpl.invoke0(native method) sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) java.lang.reflect.method.invoke(method.java:606) org.springframework.web.method.support.invocablehandlermethod.doinvoke(invocablehandlermethod.java:221) org.springframework.web.method.support.invocablehandlermethod.invokeforrequest(invocablehandlermethod.java:137) org.springframework.web.servlet.mvc.method.annotation.servletinvocablehandlermethod.invokeandhandle(servletinvocablehandlermethod.java:110) org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.invokehandlemethod(requestmappinghandleradapter.java:776) org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.handleinternal(requestmappinghandleradapter.java:705) org.springframework.web.servlet.mvc.method.abstracthandlermethodadapter.handle(abstracthandlermethodadapter.java:85) org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:959) org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:893) org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:967) org.springframework.web.servlet.frameworkservlet.dopost(frameworkservlet.java:869) javax.servlet.http.httpservlet.service(httpservlet.java:647) org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:843) javax.servlet.http.httpservlet.service(httpservlet.java:728) root cause java.lang.classcastexception: oracle.jdbc.pool.oracledatasource cannot cast java.sql.driver org.hibernate.engine.jdbc.connections.internal.drivermanagerconnectionproviderimpl.loaddriverifpossible(drivermanagerconnectionproviderimpl.java:202) org.hibernate.engine.jdbc.connections.internal.drivermanagerconnectionproviderimpl.buildcreator(drivermanagerconnectionproviderimpl.java:156) org.hibernate.engine.jdbc.connections.internal.drivermanagerconnectionproviderimpl.configure(drivermanagerconnectionproviderimpl.java:95) org.hibernate.boot.registry.internal.standardserviceregistryimpl.configureservice(standardserviceregistryimpl.java:111) org.hibernate.service.internal.abstractserviceregistryimpl.initializeservice(abstractserviceregistryimpl.java:234) org.hibernate.service.internal.abstractserviceregistryimpl.getservice(abstractserviceregistryimpl.java:206) org.hibernate.engine.jdbc.internal.jdbcservicesimpl.buildjdbcconnectionaccess(jdbcservicesimpl.java:260) org.hibernate.engine.jdbc.internal.jdbcservicesimpl.configure(jdbcservicesimpl.java:94) org.hibernate.boot.registry.internal.standardserviceregistryimpl.configureservice(standardserviceregistryimpl.java:111) org.hibernate.service.internal.abstractserviceregistryimpl.initializeservice(abstractserviceregistryimpl.java:234) org.hibernate.service.internal.abstractserviceregistryimpl.getservice(abstractserviceregistryimpl.java:206) org.hibernate.cfg.configuration.buildtyperegistrations(configuration.java:1887) org.hibernate.cfg.configuration.buildsessionfactory(configuration.java:1845) java4s.service.employeeserviceimpl.validatelogin(employeeserviceimpl.java:58) java4s.controller.loginsuccesscontroller.loginvalidateform(loginsuccesscontroller.java:61) sun.reflect.nativemethodaccessorimpl.invoke0(native method) sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) java.lang.reflect.method.invoke(method.java:606) org.springframework.web.method.support.invocablehandlermethod.doinvoke(invocablehandlermethod.java:221) org.springframework.web.method.support.invocablehandlermethod.invokeforrequest(invocablehandlermethod.java:137) org.springframework.web.servlet.mvc.method.annotation.servletinvocablehandlermethod.invokeandhandle(servletinvocablehandlermethod.java:110) org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.invokehandlemethod(requestmappinghandleradapter.java:776) org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.handleinternal(requestmappinghandleradapter.java:705) org.springframework.web.servlet.mvc.method.abstracthandlermethodadapter.handle(abstracthandlermethodadapter.java:85) org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:959) org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:893) org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:967) org.springframework.web.servlet.frameworkservlet.dopost(frameworkservlet.java:869) javax.servlet.http.httpservlet.service(httpservlet.java:647) org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:843) javax.servlet.http.httpservlet.service(httpservlet.java:728)
it seems problem getting line.
sessionfactory sessionfactory = configuration.buildsessionfactory(serviceregistry);
how can solve problem?
edit
error
http status 500 - request processing failed; nested exception org.hibernate.service.spi.serviceexception: specified jdbc driver oracle.jdbc.pool.oracledatasource not loaded type exception report message request processing failed; nested exception org.hibernate.service.spi.serviceexception: specified jdbc driver oracle.jdbc.pool.oracledatasource not loaded description server encountered internal error prevented fulfilling request. exception org.springframework.web.util.nestedservletexception: request processing failed; nested exception org.hibernate.service.spi.serviceexception: specified jdbc driver oracle.jdbc.pool.oracledatasource not loaded org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:979) org.springframework.web.servlet.frameworkservlet.dopost(frameworkservlet.java:869) javax.servlet.http.httpservlet.service(httpservlet.java:647) org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:843) javax.servlet.http.httpservlet.service(httpservlet.java:728) root cause org.hibernate.service.spi.serviceexception: specified jdbc driver oracle.jdbc.pool.oracledatasource not loaded org.hibernate.engine.jdbc.connections.internal.drivermanagerconnectionproviderimpl.loaddriverifpossible(drivermanagerconnectionproviderimpl.java:205) org.hibernate.engine.jdbc.connections.internal.drivermanagerconnectionproviderimpl.buildcreator(drivermanagerconnectionproviderimpl.java:156) org.hibernate.engine.jdbc.connections.internal.drivermanagerconnectionproviderimpl.configure(drivermanagerconnectionproviderimpl.java:95) org.hibernate.boot.registry.internal.standardserviceregistryimpl.configureservice(standardserviceregistryimpl.java:111) org.hibernate.service.internal.abstractserviceregistryimpl.initializeservice(abstractserviceregistryimpl.java:234) org.hibernate.service.internal.abstractserviceregistryimpl.getservice(abstractserviceregistryimpl.java:206) org.hibernate.engine.jdbc.internal.jdbcservicesimpl.buildjdbcconnectionaccess(jdbcservicesimpl.java:260) org.hibernate.engine.jdbc.internal.jdbcservicesimpl.configure(jdbcservicesimpl.java:94) org.hibernate.boot.registry.internal.standardserviceregistryimpl.configureservice(standardserviceregistryimpl.java:111) org.hibernate.service.internal.abstractserviceregistryimpl.initializeservice(abstractserviceregistryimpl.java:234) org.hibernate.service.internal.abstractserviceregistryimpl.getservice(abstractserviceregistryimpl.java:206) org.hibernate.cfg.configuration.buildtyperegistrations(configuration.java:1887) org.hibernate.cfg.configuration.buildsessionfactory(configuration.java:1845) java4s.service.employeeserviceimpl.validatelogin(employeeserviceimpl.java:58) java4s.controller.loginsuccesscontroller.loginvalidateform(loginsuccesscontroller.java:61) sun.reflect.nativemethodaccessorimpl.invoke0(native method) sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) java.lang.reflect.method.invoke(method.java:606) org.springframework.web.method.support.invocablehandlermethod.doinvoke(invocablehandlermethod.java:221) org.springframework.web.method.support.invocablehandlermethod.invokeforrequest(invocablehandlermethod.java:137) org.springframework.web.servlet.mvc.method.annotation.servletinvocablehandlermethod.invokeandhandle(servletinvocablehandlermethod.java:110) org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.invokehandlemethod(requestmappinghandleradapter.java:776) org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.handleinternal(requestmappinghandleradapter.java:705) org.springframework.web.servlet.mvc.method.abstracthandlermethodadapter.handle(abstracthandlermethodadapter.java:85) org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:959) org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:893) org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:967) org.springframework.web.servlet.frameworkservlet.dopost(frameworkservlet.java:869) javax.servlet.http.httpservlet.service(httpservlet.java:647) org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:843) javax.servlet.http.httpservlet.service(httpservlet.java:728) root cause java.lang.classcastexception: oracle.jdbc.pool.oracledatasource cannot cast java.sql.driver org.hibernate.engine.jdbc.connections.internal.drivermanagerconnectionproviderimpl.loaddriverifpossible(drivermanagerconnectionproviderimpl.java:202) org.hibernate.engine.jdbc.connections.internal.drivermanagerconnectionproviderimpl.buildcreator(drivermanagerconnectionproviderimpl.java:156) org.hibernate.engine.jdbc.connections.internal.drivermanagerconnectionproviderimpl.configure(drivermanagerconnectionproviderimpl.java:95) org.hibernate.boot.registry.internal.standardserviceregistryimpl.configureservice(standardserviceregistryimpl.java:111) org.hibernate.service.internal.abstractserviceregistryimpl.initializeservice(abstractserviceregistryimpl.java:234) org.hibernate.service.internal.abstractserviceregistryimpl.getservice(abstractserviceregistryimpl.java:206) org.hibernate.engine.jdbc.internal.jdbcservicesimpl.buildjdbcconnectionaccess(jdbcservicesimpl.java:260) org.hibernate.engine.jdbc.internal.jdbcservicesimpl.configure(jdbcservicesimpl.java:94) org.hibernate.boot.registry.internal.standardserviceregistryimpl.configureservice(standardserviceregistryimpl.java:111) org.hibernate.service.internal.abstractserviceregistryimpl.initializeservice(abstractserviceregistryimpl.java:234) org.hibernate.service.internal.abstractserviceregistryimpl.getservice(abstractserviceregistryimpl.java:206) org.hibernate.cfg.configuration.buildtyperegistrations(configuration.java:1887) org.hibernate.cfg.configuration.buildsessionfactory(configuration.java:1845) java4s.service.employeeserviceimpl.validatelogin(employeeserviceimpl.java:58) java4s.controller.loginsuccesscontroller.loginvalidateform(loginsuccesscontroller.java:61) sun.reflect.nativemethodaccessorimpl.invoke0(native method) sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) java.lang.reflect.method.invoke(method.java:606) org.springframework.web.method.support.invocablehandlermethod.doinvoke(invocablehandlermethod.java:221) org.springframework.web.method.support.invocablehandlermethod.invokeforrequest(invocablehandlermethod.java:137) org.springframework.web.servlet.mvc.method.annotation.servletinvocablehandlermethod.invokeandhandle(servletinvocablehandlermethod.java:110) org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.invokehandlemethod(requestmappinghandleradapter.java:776) org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.handleinternal(requestmappinghandleradapter.java:705) org.springframework.web.servlet.mvc.method.abstracthandlermethodadapter.handle(abstracthandlermethodadapter.java:85) org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:959) org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:893) org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:967) org.springframework.web.servlet.frameworkservlet.dopost(frameworkservlet.java:869) javax.servlet.http.httpservlet.service(httpservlet.java:647) org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:843) javax.servlet.http.httpservlet.service(httpservlet.java:728) note full stack trace of root cause available in apache tomcat/7.0.41 logs. apache tomcat/7.0.41
the driverclassname shouldn't datasource:
class="org.springframework.jdbc.datasource.drivermanagerdatasource" p:driverclassname="oracle.jdbc.pool.oracledatasource"
it should class name of driver class: oracle.jdbc.oracledriver
class="org.springframework.jdbc.datasource.drivermanagerdatasource" p:driverclassname="oracle.jdbc.oracledriver"
Comments
Post a Comment