spring mvc - Could not open Hibernate Session for transaction / Cannot open connection -


in application, have module designed search database users , display information in table inside jsp. setup spring security inside application. able make connection database login page, though reason none of dao's crud operations (in case, search) working.

thanks, , please let me know if can provide more information.

here of stack trace.

    org.springframework.web.util.nestedservletexception: request processing failed; nested exception org.springframework.transaction.cannotcreatetransactionexception: not open hibernate session transaction; nested exception org.hibernate.exception.genericjdbcexception: cannot open connection         org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:656)         org.springframework.web.servlet.frameworkservlet.dopost(frameworkservlet.java:560)         javax.servlet.http.httpservlet.service(httpservlet.java:637)         javax.servlet.http.httpservlet.service(httpservlet.java:717)  ...  org.springframework.transaction.cannotcreatetransactionexception: not open hibernate session transaction; nested exception org.hibernate.exception.genericjdbcexception: cannot open connection     org.springframework.orm.hibernate3.hibernatetransactionmanager.dobegin(hibernatetransactionmanager.java:596)     org.springframework.transaction.support.abstractplatformtransactionmanager.gettransaction(abstractplatformtransactionmanager.java:371)     org.springframework.transaction.interceptor.transactionaspectsupport.createtransactionifnecessary(transactionaspectsupport.java:335)     org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:105)     org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172)     org.springframework.aop.interceptor.exposeinvocationinterceptor.invoke(exposeinvocationinterceptor.java:89)     org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172)     org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:202)     $proxy8.searchentity(unknown source)     arlua.controller.searchusercontroller.mysearchmethod(searchusercontroller.java:35)     sun.reflect.nativemethodaccessorimpl.invoke0(native method)     sun.reflect.nativemethodaccessorimpl.invoke(unknown source)     sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source  ...      org.hibernate.exception.genericjdbcexception: cannot open connection         org.hibernate.exception.sqlstateconverter.handlednonspecificexception(sqlstateconverter.java:140)         org.hibernate.exception.sqlstateconverter.convert(sqlstateconverter.java:128)         org.hibernate.exception.jdbcexceptionhelper.convert(jdbcexceptionhelper.java:66)         org.hibernate.exception.jdbcexceptionhelper.convert(jdbcexceptionhelper.java:52)         org.hibernate.jdbc.connectionmanager.openconnection(connectionmanager.java:449)         org.hibernate.jdbc.connectionmanager.getconnection(connectionmanager.java:167)         org.hibernate.jdbc.borrowedconnectionproxy.invoke(borrowedconnectionproxy.java:74)         $proxy14.gettransactionisolation(unknown source)  ...      java.sql.sqlexception: invalid arguments in call         oracle.jdbc.driver.databaseerror.throwsqlexception(databaseerror.java:112)         oracle.jdbc.driver.databaseerror.throwsqlexception(databaseerror.java:146)         oracle.jdbc.driver.databaseerror.throwsqlexception(databaseerror.java:208)         oracle.jdbc.driver.t4cconnection.logon(t4cconnection.java:236)         oracle.jdbc.driver.physicalconnection.<init>(physicalconnection.java:414)         oracle.jdbc.driver.t4cconnection.<init>(t4cconnection.java:165)         oracle.jdbc.driver.t4cdriverextension.getconnection(t4cdriverextension.java:35)         oracle.jdbc.driver.oracledriver.connect(oracledriver.java:801)         java.sql.drivermanager.getconnection(unknown source)         java.sql.drivermanager.getconnection(unknown source)         org.springframework.jdbc.datasource.drivermanagerdatasource.getconnectionfromdrivermanager(drivermanagerdatasource.java:173)         org.springframework.jdbc.datasource.drivermanagerdatasource.getconnectionfromdriver(drivermanagerdatasource.java:164)         org.springframework.jdbc.datasource.abstractdriverbaseddatasource.getconnectionfromdriver(abstractdriverbaseddatasource.java:149)         org.springframework.jdbc.datasource.abstractdriverbaseddatasource.getconnection(abstractdriverbaseddatasource.java:119)         org.springframework.orm.hibernate3.localdatasourceconnectionprovider.getconnection(localdatasourceconnectionprovider.java:81)         org.hibernate.jdbc.connectionmanager.openconnection(connectionmanager.java:446)         org.hibernate.jdbc.connectionmanager.getconnection(connectionmanager.java:167)         org.hibernate.jdbc.borrowedconnectionproxy.invoke(borrowedconnectionproxy.java:74)         $proxy14.gettransactionisolation(unknown source)         org.springframework.jdbc.datasource.datasourceutils.prepareconnectionfortransaction(datasourceutils.java:190)         org.springframework.orm.hibernate3.hibernatetransactionmanager.dobegin(hibernatetransactionmanager.java:508)         org.springframework.transaction.support.abstractplatformtransactionmanager.gettransaction(abstractplatformtransactionmanager.java:371)         org.springframework.transaction.interceptor.transactionaspectsupport.createtransactionifnecessary(transactionaspectsupport.java:335)         org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:105)         org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172)         org.springframework.aop.interceptor.exposeinvocationinterceptor.invoke(exposeinvocationinterceptor.java:89)         org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172)         org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:202)         $proxy8.searchentity(unknown source)         arlua.controller.searchusercontroller.mysearchmethod(searchusercontroller.java:35)         sun.reflect.nativemethodaccessorimpl.invoke0(native method)         sun.reflect.nativemethodaccessorimpl.invoke(unknown source)         sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source)         java.lang.reflect.method.invoke(unknown source)         org.springframework.web.bind.annotation.support.handlermethodinvoker.invokehandlermethod(handlermethodinvoker.java:176)         org.springframework.web.servlet.mvc.annotation.annotationmethodhandleradapter.invokehandlermethod(annotationmethodhandleradapter.java:426)         org.springframework.web.servlet.mvc.annotation.annotationmethodhandleradapter.handle(annotationmethodhandleradapter.java:414)         org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:790)         org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:719)         org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:644)         org.springframework.web.servlet.frameworkservlet.dopost(frameworkservlet.java:560)         javax.servlet.http.httpservlet.service(httpservlet.java:637)         javax.servlet.http.httpservlet.service(httpservlet.java:717)         org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:368)         org.springframework.security.web.access.intercept.filtersecurityinterceptor.invoke(filtersecurityinterceptor.java:109)         org.springframework.security.web.access.intercept.filtersecurityinterceptor.dofilter(filtersecurityinterceptor.java:83)         org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:380)         org.springframework.security.web.access.exceptiontranslationfilter.dofilter(exceptiontranslationfilter.java:97)         org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:380)         org.springframework.security.web.session.sessionmanagementfilter.dofilter(sessionmanagementfilter.java:100)         org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:380)         org.springframework.security.web.authentication.anonymousauthenticationfilter.dofilter(anonymousauthenticationfilter.java:78)         org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:380)         org.springframework.security.web.servletapi.securitycontextholderawarerequestfilter.dofilter(securitycontextholderawarerequestfilter.java:54)         org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:380)         org.springframework.security.web.savedrequest.requestcacheawarefilter.dofilter(requestcacheawarefilter.java:35)         org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:380)         org.springframework.security.web.authentication.www.basicauthenticationfilter.dofilter(basicauthenticationfilter.java:177)         org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:380)         org.springframework.security.web.authentication.ui.defaultloginpagegeneratingfilter.dofilter(defaultloginpagegeneratingfilter.java:91)         org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:380)         org.springframework.security.web.authentication.abstractauthenticationprocessingfilter.dofilter(abstractauthenticationprocessingfilter.java:187)         org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:380)         org.springframework.security.web.authentication.logout.logoutfilter.dofilter(logoutfilter.java:105)         org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:380)         org.springframework.security.web.context.securitycontextpersistencefilter.dofilter(securitycontextpersistencefilter.java:79)         org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:380)         org.springframework.security.web.filterchainproxy.dofilter(filterchainproxy.java:169)         org.springframework.web.filter.delegatingfilterproxy.invokedelegate(delegatingfilterproxy.java:237)         org.springframework.web.filter.delegatingfilterproxy.dofilter(delegatingfilterproxy.java:167) 

searchusercontroller class

package arlua.controller;  import java.util.list;  import arlua.dao.tableentityfetchdao; import arlua.exception.improperusersearchexception; import arlua.exception.searchstringtooshortexception; import arlua.helper.buildusertables; import arlua.service.searchcriteria;  import org.springframework.beans.factory.annotation.autowired; import org.springframework.beans.factory.annotation.qualifier; import org.springframework.stereotype.controller; import org.springframework.web.bind.annotation.modelattribute; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod; import org.springframework.web.bind.annotation.sessionattributes; import org.springframework.web.servlet.modelandview;  @controller @sessionattributes public class searchusercontroller {      private @autowired @qualifier("userinfodaoimpl") tableentityfetchdao userinfodao;      list<?> searchlist;     string error;      @requestmapping(value = "/search_user", method = requestmethod.post)     public string mysearchmethod(@modelattribute("search_criteria") searchcriteria search){          error = "";         try{             if(search.getinput() != null)                 searchlist = userinfodao.searchentity(search.getinput());         }         catch(searchstringtooshortexception e1){             error = "search criteria short. more specific.";         }         catch(improperusersearchexception e2){             error = "specify either id or first , last name.";         }          return "redirect:search_user";     }      @requestmapping("/search_user")     public modelandview mysuccessmethod(){         modelandview model = new modelandview("search_user");          if(searchlist != null){             if(searchlist.size() == 0)                 error = "search returned no results.";             else                 model.addobject("searchtable", buildusertables.buildsearch(searchlist));         }          return model;     }  } 

userinfodaoimpl class

package arlua.dao.impl;  import arlua.dao.tableentityfetchdao; import arlua.exception.improperusersearchexception; import arlua.exception.searchstringtooshortexception; import arlua.tables.userinfotable;  import java.util.arraylist; import java.util.list;  import org.hibernate.session; import org.hibernate.sessionfactory; import org.springframework.beans.factory.annotation.autowired;  public class userinfodaoimpl implements tableentityfetchdao{      @autowired     private sessionfactory sessionfactory;      public void setsessionfactory(sessionfactory sessionfactory){         this.sessionfactory = sessionfactory;     }      public void saveentity(object userinfo) {         this.sessionfactory.getcurrentsession().save((userinfotable)userinfo);     }      public userinfotable getentity(object user_id) {         return (userinfotable)this.sessionfactory.getcurrentsession().             get(userinfotable.class, (string)user_id);     }      public void updateentity(object userinfo) {         this.sessionfactory.getcurrentsession().update((userinfotable)userinfo);     }      public void deleteentity(object userinfo) {         this.sessionfactory.getcurrentsession().delete((userinfotable)userinfo);     }      public list<?> getallentities() {         return this.sessionfactory.getcurrentsession().createquery             ("from userinfotable").list();     }      public list<?> searchentity(string search) throws searchstringtooshortexception, improperusersearchexception{         //this search supports input of user's seid or first , last name.         if(search.length() < 3){             throw new searchstringtooshortexception();         }          session s = this.sessionfactory.getcurrentsession();         list<?> searchlist = new arraylist();          //searches similar users matching seids.         if(search.matches("^[a-za-z0-9]*[0-9]+[a-za-z0-9]*$")){             searchlist = s.createquery                 //("from userinfotable").list();                 ("from userinfotable upper(user_id) upper('%" + search + "%')").list();          }         //searches similar users matching first , last name.         //if search contains more 2 arguments, exception thrown.         else if(search.length() >= 3){             string[] searchparts = search.split(" ");             if(searchparts.length != 2)                 throw new improperusersearchexception();             searchlist = s.createquery                 ("from userinfotable upper(first_name) upper('%" + searchparts[0] + "%') " +                         "and upper(last_name) upper('%" + searchparts[1] + "%')").list();         }         else{             throw new improperusersearchexception();         }          return searchlist;     } } 

application-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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemalocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">      <context:annotation-config />      <bean id="serverdatasource"         class="org.springframework.jdbc.datasource.drivermanagerdatasource">         <property name="driverclassname">             <value>oracle.jdbc.driver.oracledriver</value>         </property>         <property name="url">             <value>url</value>         </property>     </bean>      <bean id="datasource" class="org.springframework.jdbc.datasource.usercredentialsdatasourceadapter">         <property name="targetdatasource" ref="serverdatasource"/>         <property name="username"><value>unknown</value></property>         <property name="password"><value>unknown</value></property>     </bean>      <!--     <bean id="propertyplaceholderconfigurer"         class="org.springframework.beans.factory.config.propertyplaceholderconfigurer">         <property name="systempropertiesmodename" value="system_properties_mode_override" />         <property name="ignoreunresolvableplaceholders" value="true"/>     </bean>     -->      <bean id="mysessionfactory"         class="org.springframework.orm.hibernate3.localsessionfactorybean">         <property name="mappinglocations">             <list>                 <value>web-inf/mapping/user_info.hbm.xml</value>                 <value>web-inf/mapping/login.hbm.xml</value>                 <value>web-inf/mapping/linked_accounts.hbm.xml</value>                 <value>web-inf/mapping/application_instance.hbm.xml</value>             </list>         </property>         <property name="hibernateproperties">             <props>                 <prop key="hibernate.dialect">org.hibernate.dialect.oracledialect</prop>                 <prop key="hibernate.hbm2ddl.auto">update</prop>             </props>         </property>         <property name="datasource" ref="serverdatasource"/>     </bean>      <bean id = "userinfodaoimpl" class="arlua.dao.impl.userinfodaoimpl">         <property name="sessionfactory" ref="mysessionfactory"/>     </bean>      <bean id = "logindaoimpl" class="arlua.dao.impl.logindaoimpl">         <property name="sessionfactory" ref="mysessionfactory"/>     </bean>      <bean id = "linkedaccountsdaoimpl" class="arlua.dao.impl.linkedaccountsdaoimpl">         <property name="sessionfactory" ref="mysessionfactory"/>     </bean>      <bean id = "applicationinstancedaoimpl" class="arlua.dao.impl.applicationinstancedaoimpl">         <property name="sessionfactory" ref="mysessionfactory"/>     </bean>      <bean id = "roledaoimpl" class="arlua.dao.impl.roledaoimpl">         <property name="sessionfactory" ref="mysessionfactory"/>     </bean>      <bean id = "applicationapprovaldaoimpl" class="arlua.dao.impl.applicationapprovaldaoimpl">         <property name="sessionfactory" ref="mysessionfactory"/>     </bean>      <bean id = "userdaoimpl" class="arlua.dao.impl.userdaoimpl"/>      <!--  *************  transaction management using aop **************** -->      <bean id="mytransactionmanager"         class="org.springframework.orm.hibernate3.hibernatetransactionmanager">         <property name="sessionfactory" ref="mysessionfactory"/>         </bean>      <aop:config>         <aop:pointcut id="allmethods" expression="execution(* arlua.dao.tableentityfetchdao.*(..))"/>         <aop:advisor advice-ref="txadvice" pointcut-ref="allmethods"/>     </aop:config>      <tx:advice id="txadvice" transaction-manager="mytransactionmanager">         <tx:attributes>             <tx:method name="saveentity"                 propagation = "requires_new"                 isolation = "read_committed"                 rollback-for = "exception"/>             <tx:method name="updateentity"                 propagation = "requires_new"                 isolation = "read_committed"                 rollback-for = "exception"/>             <tx:method name="getentity"                 propagation = "requires_new"                 isolation = "read_committed"                 rollback-for = "exception"/>             <tx:method name="getallentities"                 propagation = "requires_new"                 isolation = "read_committed"                 rollback-for = "exception"/>             <tx:method name="searchentity"                 propagation = "requires_new"                 isolation = "read_committed"                 rollback-for = "exception"/>         </tx:attributes>     </tx:advice>  </beans> 

java.sql.sqlexception: invalid arguments in call means problem while connect database url/auth issues: looking stacktrace not getting connection via usercredentialsdatasourceadapter (your id="datasource") using drivermanagerdatasource (id="serverdatasource"): in few word trying connect without using user/password.

in sessionfactory bean creating wire:
<property name="datasource" ref="datasource"/>
instead of:
<property name="datasource" ref="serverdatasource"/>


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -