title: Error while making datasource in tomcat conf folder and connecting with spring and hibernate
body: <p>We are getting error while connecting spring and hibernate with tomcat datasource 
  please suggest what to do</p>
  
  <p>I had checked many configration files and spring jee jndi resource but nothing to find.</p>
  
  <p>Is there any special way to connect it</p>
  
  <pre><code>java.lang.NullPointerException
          at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(Unknown Source)
          at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(Unknown Source)
          at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(Unknown Source)
          at java.sql.DriverManager.getDriver(Unknown Source)
          at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDat
  aSource.java:1143)
          at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSo
  urce.java:880)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflecti
  on(AopUtils.java:307)
          at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynami
  cAopProxy.java:196)
          at $Proxy9.getConnection(Unknown Source)
          at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.
  getConnection(LocalDataSourceConnectionProvider.java:81)
          at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:
  84)
          at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2073
  )
          at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
  a:1298)
          at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(Annotat
  ionConfiguration.java:859)
          at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSession
  Factory(LocalSessionFactoryBean.java:855)
          at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessi
  onFactory(LocalSessionFactoryBean.java:774)
          at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPr
  opertiesSet(AbstractSessionFactoryBean.java:211)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBean
  Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBean
  Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1400)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBean
  Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBean
  Factory.createBean(AbstractAutowireCapableBeanFactory.java:450)
          at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
  ject(AbstractBeanFactory.java:290)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
  y.getSingleton(DefaultSingletonBeanRegistry.java:222)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
  an(AbstractBeanFactory.java:287)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
  (AbstractBeanFactory.java:189)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.
  findAutowireCandidates(DefaultListableBeanFactory.java:825)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.
  doResolveDependency(DefaultListableBeanFactory.java:767)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.
  resolveDependency(DefaultListableBeanFactory.java:685)
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanP
  ostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.
  java:559)
          at org.springframework.beans.factory.annotation.InjectionMetadata.inject
  (InjectionMetadata.java:84)
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanP
  ostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java
  :283)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBean
  Factory.populateBean(AbstractAutowireCapableBeanFactory.java:1055)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBean
  Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBean
  Factory.createBean(AbstractAutowireCapableBeanFactory.java:450)
          at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
  ject(AbstractBeanFactory.java:290)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
  y.getSingleton(DefaultSingletonBeanRegistry.java:222)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
  an(AbstractBeanFactory.java:287)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
  (AbstractBeanFactory.java:189)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.
  findAutowireCandidates(DefaultListableBeanFactory.java:825)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.
  doResolveDependency(DefaultListableBeanFactory.java:767)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.
  resolveDependency(DefaultListableBeanFactory.java:685)
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanP
  ostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.j
  ava:478)
          at org.springframework.beans.factory.annotation.InjectionMetadata.inject
  (InjectionMetadata.java:84)
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanP
  ostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java
  :283)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBean
  Factory.populateBean(AbstractAutowireCapableBeanFactory.java:1055)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBean
  Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBean
  Factory.createBean(AbstractAutowireCapableBeanFactory.java:450)
          at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
  ject(AbstractBeanFactory.java:290)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
  y.getSingleton(DefaultSingletonBeanRegistry.java:222)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
  an(AbstractBeanFactory.java:287)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
  (AbstractBeanFactory.java:189)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.
  findAutowireCandidates(DefaultListableBeanFactory.java:825)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.
  doResolveDependency(DefaultListableBeanFactory.java:767)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.
  resolveDependency(DefaultListableBeanFactory.java:685)
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanP
  ostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.j
  ava:478)
          at org.springframework.beans.factory.annotation.InjectionMetadata.inject
  (InjectionMetadata.java:84)
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanP
  ostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java
  :283)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBean
  Factory.populateBean(AbstractAutowireCapableBeanFactory.java:1055)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBean
  Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBean
  Factory.createBean(AbstractAutowireCapableBeanFactory.java:450)
          at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
  ject(AbstractBeanFactory.java:290)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
  y.getSingleton(DefaultSingletonBeanRegistry.java:222)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
  an(AbstractBeanFactory.java:287)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
  (AbstractBeanFactory.java:189)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.
  preInstantiateSingletons(DefaultListableBeanFactory.java:562)
          at org.springframework.context.support.AbstractApplicationContext.finish
  BeanFactoryInitialization(AbstractApplicationContext.java:871)
          at org.springframeorg.springframework.transaction.CannotCreateTransactio
  nException: Could not open Hibernate Session for transaction; nested exception i
  s org.hibernate.exception.GenericJDBCException: Cannot open connection
          at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegi
  n(HibernateTransactionManager.java:596)
          at org.springframework.transaction.support.AbstractPlatformTransactionMa
  nager.getTransaction(AbstractPlatformTransactionManager.java:371)
          at org.springframework.transaction.interceptor.TransactionAspectSupport.
  createTransactionIfNecessary(TransactionAspectSupport.java:354)
          at org.springframework.transaction.interceptor.TransactionInterceptor.in
  voke(TransactionInterceptor.java:103)
          at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
  ReflectiveMethodInvocation.java:172)
          at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynami
  cAopProxy.java:202)
          at $Proxy21.getProducts(Unknown Source)
          at com.max.premcalc.service.CalcServiceImpl.getProducts(CalcServiceImpl.
  java:46)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflecti
  on(AopUtils.java:307)
          at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJo
  inpoint(ReflectiveMethodInvocation.java:183)
          at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
  ReflectiveMethodInvocation.java:150)
          at org.springframework.transaction.interceptor.TransactionInterceptor.in
  voke(TransactionInterceptor.java:108)
          at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
  ReflectiveMethodInvocation.java:172)
          at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynami
  cAopProxy.java:202)
          at $Proxy23.getProducts(Unknown Source)
          at com.max.premcalc.controller.MainController.getRegisterForm(MainContro
  ller.java:47)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.
  doInvokeMethod(HandlerMethodInvoker.java:710)
          at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.
  invokeHandlerMethod(HandlerMethodInvoker.java:167)
          at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandle
  rAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414)
          at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandle
  rAdapter.handle(AnnotationMethodHandlerAdapter.java:402)
          at org.springframework.web.servlet.DispatcherServlet.doDispatch(Dispatch
  erServlet.java:771)
          at org.springframework.web.servlet.DispatcherServlet.doService(Dispatche
  rServlet.java:716)
          at org.springframework.web.servlet.FrameworkServlet.processRequest(Frame
  workServlet.java:647)
          at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServl
  et.java:552)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
  icationFilterChain.java:290)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
  ilterChain.java:206)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
  alve.java:233)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
  alve.java:175)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
  ava:128)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
  ava:102)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
  ve.java:109)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
  a:263)
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
  :844)
          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
  ss(Http11Protocol.java:584)
          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:44
  7)
          at java.lang.Thread.run(Unknown Source)
  Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection
          at org.hibernate.exception.SQLStateConverter.handledNonSpecificException
  (SQLStateConverter.java:103)
          at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.j
  ava:91)
          at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelp
  er.java:43)
          at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelp
  er.java:29)
          at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager
  .java:426)
          at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.
  java:144)
          at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119)
          at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:
  57)
          at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326
  )
          at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegi
  n(HibernateTransactionManager.java:555)
          ... 45 more
  Caused by: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC dr
  iver of class '' for connect URL 'null'
          at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDat
  aSource.java:1150)
          at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSo
  urce.java:880)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflecti
  on(AopUtils.java:307)
          at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynami
  cAopProxy.java:196)
          at $Proxy9.getConnection(Unknown Source)
          at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.
  getConnection(LocalDataSourceConnectionProvider.java:81)
          at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager
  .java:423)
          ... 50 more
  Caused by: java.lang.NullPointerException
          at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(Unknown Source)
          at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(Unknown Source)
          at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(Unknown Source)
          at java.sql.DriverManager.getDriver(Unknown Source)
          at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDat
  aSource.java:1143)
          ... 60 more
  </code></pre>