Announcement Announcement Module
Collapse
No announcement yet.
Problem with HibernateInterceptor Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with HibernateInterceptor

    I am trying HibernateInterceptor and HibernateTemplate. HibernateTemplate works like a charm. No luck with HibernateInterceptor though. Here is my spring config file:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
    
    <beans>
    
    	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    		<property name="driverClassName">
    			<value>org.hsqldb.jdbcDriver</value>
    		</property>
    		<property name="url">
    			<value>jdbc&#58;hsqldb&#58;data/projectx</value>
    		</property>
    		<property name="username">
    			<value>sa</value>
    		</property>
    		<property name="password">
    			<value>
    			</value>
    		</property>
    	</bean>
    
    	<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    		<property name="dataSource">
    			<ref local="dataSource" />
    		</property>
    		<property name="mappingResources">
    			<value>projectx.hbm.xml</value>
    		</property>
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.dialect">net.sf.hibernate.dialect.HSQLDialect</prop>
    			</props>
    		</property>
    	</bean>
    
    	<bean id="myHibernateInterceptor" class="org.springframework.orm.hibernate.HibernateInterceptor">
    		<property name="sessionFactory">
    			<ref local="sessionFactory" />
    		</property>
    	</bean>
    
    	<bean id="userDAOTarget" class="com.projectx.dao.UserDAOHibernateInterceptorImpl">
    		<property name="sessionFactory">
    			<ref local="sessionFactory" />
    		</property>
    	</bean>
    
    	<bean id="userDAO" class="org.springframework.aop.framework.ProxyFactoryBean">
    		<property name="proxyInterfaces">
    			<value>com.projectx.dao.UserDAO</value>
    		</property>
    		<property name="interceptorNames">
    			<list>
    				<value>myHibernateInterceptor</value>
    				<value>userDAOTarget</value>
    			</list>
    		</property>
    	</bean>
    
    </beans>
    Here is the hibernate.properties file:
    Code:
    hibernate.dialect=net.sf.hibernate.dialect.HSQLDialect
    hibernate.connection.driver_class=org.hsqldb.jdbcDriver
    hibernate.connection.url=jdbc&#58;hsqldb&#58;data/projectx
    hibernate.connection.username=sa
    hibernate.connection.password=
    Here is the error that I get:
    Code:
    18&#58;57&#58;20,009  INFO Environment&#58;469 - Hibernate 2.1.6
    18&#58;57&#58;20,069  INFO Environment&#58;503 - loaded properties from resource hibernate.properties&#58; &#123;hibernate.connection.username=sa, hibernate.connection.password=, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.sf.hibernate.dialect.HSQLDialect, hibernate.connection.url=jdbc&#58;hsqldb&#58;data/projectx, hibernate.connection.driver_class=org.hsqldb.jdbcDriver&#125;
    18&#58;57&#58;20,079  INFO Environment&#58;529 - using CGLIB reflection optimizer
    18&#58;57&#58;20,439  INFO Binder&#58;229 - Mapping class&#58; com.projectx.model.User -> user
    18&#58;57&#58;20,620  INFO Configuration&#58;627 - processing one-to-many association mappings
    18&#58;57&#58;20,620  INFO Configuration&#58;636 - processing one-to-one association property references
    18&#58;57&#58;20,620  INFO Configuration&#58;661 - processing foreign key constraints
    18&#58;57&#58;20,670  INFO Dialect&#58;82 - Using dialect&#58; net.sf.hibernate.dialect.HSQLDialect
    18&#58;57&#58;20,680  INFO SettingsFactory&#58;63 - Use outer join fetching&#58; true
    18&#58;57&#58;20,690  INFO ConnectionProviderFactory&#58;53 - Initializing connection provider&#58; org.springframework.orm.hibernate.LocalDataSourceConnectionProvider
    18&#58;57&#58;20,700  INFO TransactionManagerLookupFactory&#58;33 - No TransactionManagerLookup configured &#40;in JTA environment, use of process level read-write cache is not recommended&#41;
    18&#58;57&#58;21,561  WARN JDBCExceptionReporter&#58;38 - SQL Error&#58; -33, SQLState&#58; S1000
    18&#58;57&#58;21,561 ERROR JDBCExceptionReporter&#58;46 - Access is denied
    18&#58;57&#58;21,581  WARN SettingsFactory&#58;96 - Could not obtain connection metadata
    java.sql.SQLException&#58; Access is denied
    	at org.hsqldb.jdbc.jdbcUtil.sqlException&#40;Unknown Source&#41;
    	at org.hsqldb.jdbc.jdbcConnection.<init>&#40;Unknown Source&#41;
    	at org.hsqldb.jdbcDriver.getConnection&#40;Unknown Source&#41;
    	at org.hsqldb.jdbcDriver.connect&#40;Unknown Source&#41;
    	at java.sql.DriverManager.getConnection&#40;Unknown Source&#41;
    	at java.sql.DriverManager.getConnection&#40;Unknown Source&#41;
    	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager&#40;DriverManagerDataSource.java&#58;156&#41;
    	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager&#40;DriverManagerDataSource.java&#58;144&#41;
    	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnection&#40;DriverManagerDataSource.java&#58;132&#41;
    	at org.springframework.orm.hibernate.LocalDataSourceConnectionProvider.getConnection&#40;LocalDataSourceConnectionProvider.java&#58;59&#41;
    	at net.sf.hibernate.cfg.SettingsFactory.buildSettings&#40;SettingsFactory.java&#58;73&#41;
    	at net.sf.hibernate.cfg.Configuration.buildSettings&#40;Configuration.java&#58;1155&#41;
    	at net.sf.hibernate.cfg.Configuration.buildSessionFactory&#40;Configuration.java&#58;789&#41;
    	at org.springframework.orm.hibernate.LocalSessionFactoryBean.newSessionFactory&#40;LocalSessionFactoryBean.java&#58;467&#41;
    	at org.springframework.orm.hibernate.LocalSessionFactoryBean.afterPropertiesSet&#40;LocalSessionFactoryBean.java&#58;405&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods&#40;AbstractAutowireCapableBeanFactory.java&#58;991&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;288&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;208&#41;
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;204&#41;
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;136&#41;
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons&#40;DefaultListableBeanFactory.java&#58;224&#41;
    	at org.springframework.context.support.AbstractApplicationContext.refresh&#40;AbstractApplicationContext.java&#58;284&#41;
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;80&#41;
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;65&#41;
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;56&#41;
    	at com.projectx.dao.UserDAOTestAbstract.setUp&#40;UserDAOTestAbstract.java&#58;25&#41;
    	at junit.framework.TestCase.runBare&#40;TestCase.java&#58;125&#41;
    	at junit.framework.TestResult$1.protect&#40;TestResult.java&#58;106&#41;
    	at junit.framework.TestResult.runProtected&#40;TestResult.java&#58;124&#41;
    	at junit.framework.TestResult.run&#40;TestResult.java&#58;109&#41;
    	at junit.framework.TestCase.run&#40;TestCase.java&#58;118&#41;
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests&#40;RemoteTestRunner.java&#58;421&#41;
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run&#40;RemoteTestRunner.java&#58;305&#41;
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main&#40;RemoteTestRunner.java&#58;186&#41;
    18&#58;57&#58;21,591  INFO SettingsFactory&#58;103 - Use scrollable result sets&#58; false
    18&#58;57&#58;21,591  INFO SettingsFactory&#58;106 - Use JDBC3 getGeneratedKeys&#40;&#41;&#58; false
    18&#58;57&#58;21,591  INFO SettingsFactory&#58;109 - Optimize cache for minimal puts&#58; false
    18&#58;57&#58;21,591  INFO SettingsFactory&#58;118 - Query language substitutions&#58; &#123;&#125;
    18&#58;57&#58;21,601  INFO SettingsFactory&#58;129 - cache provider&#58; net.sf.hibernate.cache.EhCacheProvider
    18&#58;57&#58;21,601  INFO Configuration&#58;1116 - instantiating and configuring caches
    18&#58;57&#58;21,952  INFO SessionFactoryImpl&#58;118 - building session factory
    18&#58;57&#58;22,602  INFO SessionFactoryObjectFactory&#58;82 - Not binding factory to JNDI, no JNDI name configured
    18&#58;57&#58;22,783  WARN SQLErrorCodesFactory&#58;274 - Error while getting database metadata
    org.springframework.jdbc.support.MetaDataAccessException&#58; Error while getting connection; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException&#58; Could not get JDBC connection; nested exception is java.sql.SQLException&#58; Access is denied
    org.springframework.jdbc.CannotGetJdbcConnectionException&#58; Could not get JDBC connection; nested exception is java.sql.SQLException&#58; Access is denied
    java.sql.SQLException&#58; Access is denied
    	at org.hsqldb.jdbc.jdbcUtil.sqlException&#40;Unknown Source&#41;
    	at org.hsqldb.jdbc.jdbcConnection.<init>&#40;Unknown Source&#41;
    	at org.hsqldb.jdbcDriver.getConnection&#40;Unknown Source&#41;
    	at org.hsqldb.jdbcDriver.connect&#40;Unknown Source&#41;
    	at java.sql.DriverManager.getConnection&#40;Unknown Source&#41;
    	at java.sql.DriverManager.getConnection&#40;Unknown Source&#41;
    	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager&#40;DriverManagerDataSource.java&#58;156&#41;
    	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager&#40;DriverManagerDataSource.java&#58;144&#41;
    	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnection&#40;DriverManagerDataSource.java&#58;132&#41;
    	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection&#40;DataSourceUtils.java&#58;165&#41;
    	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection&#40;DataSourceUtils.java&#58;144&#41;
    	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection&#40;DataSourceUtils.java&#58;120&#41;
    	at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData&#40;JdbcUtils.java&#58;93&#41;
    	at org.springframework.jdbc.support.SQLErrorCodesFactory.getErrorCodes&#40;SQLErrorCodesFactory.java&#58;209&#41;
    	at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.setDataSource&#40;SQLErrorCodeSQLExceptionTranslator.java&#58;115&#41;
    	at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.<init>&#40;SQLErrorCodeSQLExceptionTranslator.java&#58;96&#41;
    	at org.springframework.orm.hibernate.SessionFactoryUtils.newJdbcExceptionTranslator&#40;SessionFactoryUtils.java&#58;122&#41;
    	at org.springframework.orm.hibernate.HibernateAccessor.getJdbcExceptionTranslator&#40;HibernateAccessor.java&#58;158&#41;
    	at org.springframework.orm.hibernate.HibernateAccessor.afterPropertiesSet&#40;HibernateAccessor.java&#58;201&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods&#40;AbstractAutowireCapableBeanFactory.java&#58;991&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;288&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;208&#41;
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;204&#41;
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;136&#41;
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons&#40;DefaultListableBeanFactory.java&#58;230&#41;
    	at org.springframework.context.support.AbstractApplicationContext.refresh&#40;AbstractApplicationContext.java&#58;284&#41;
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;80&#41;
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;65&#41;
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;56&#41;
    	at com.projectx.dao.UserDAOTestAbstract.setUp&#40;UserDAOTestAbstract.java&#58;25&#41;
    	at junit.framework.TestCase.runBare&#40;TestCase.java&#58;125&#41;
    	at junit.framework.TestResult$1.protect&#40;TestResult.java&#58;106&#41;
    	at junit.framework.TestResult.runProtected&#40;TestResult.java&#58;124&#41;
    	at junit.framework.TestResult.run&#40;TestResult.java&#58;109&#41;
    	at junit.framework.TestCase.run&#40;TestCase.java&#58;118&#41;
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests&#40;RemoteTestRunner.java&#58;421&#41;
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run&#40;RemoteTestRunner.java&#58;305&#41;
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main&#40;RemoteTestRunner.java&#58;186&#41;
    18&#58;57&#58;22,863  WARN SQLErrorCodesFactory&#58;274 - Error while getting database metadata
    org.springframework.jdbc.support.MetaDataAccessException&#58; Error while getting connection; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException&#58; Could not get JDBC connection; nested exception is java.sql.SQLException&#58; Access is denied
    org.springframework.jdbc.CannotGetJdbcConnectionException&#58; Could not get JDBC connection; nested exception is java.sql.SQLException&#58; Access is denied
    java.sql.SQLException&#58; Access is denied
    	at org.hsqldb.jdbc.jdbcUtil.sqlException&#40;Unknown Source&#41;
    	at org.hsqldb.jdbc.jdbcConnection.<init>&#40;Unknown Source&#41;
    	at org.hsqldb.jdbcDriver.getConnection&#40;Unknown Source&#41;
    	at org.hsqldb.jdbcDriver.connect&#40;Unknown Source&#41;
    	at java.sql.DriverManager.getConnection&#40;Unknown Source&#41;
    	at java.sql.DriverManager.getConnection&#40;Unknown Source&#41;
    	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager&#40;DriverManagerDataSource.java&#58;156&#41;
    	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager&#40;DriverManagerDataSource.java&#58;144&#41;
    	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnection&#40;DriverManagerDataSource.java&#58;132&#41;
    	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection&#40;DataSourceUtils.java&#58;165&#41;
    	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection&#40;DataSourceUtils.java&#58;144&#41;
    	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection&#40;DataSourceUtils.java&#58;120&#41;
    	at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData&#40;JdbcUtils.java&#58;93&#41;
    	at org.springframework.jdbc.support.SQLErrorCodesFactory.getErrorCodes&#40;SQLErrorCodesFactory.java&#58;209&#41;
    	at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.setDataSource&#40;SQLErrorCodeSQLExceptionTranslator.java&#58;115&#41;
    	at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.<init>&#40;SQLErrorCodeSQLExceptionTranslator.java&#58;96&#41;
    	at org.springframework.orm.hibernate.SessionFactoryUtils.newJdbcExceptionTranslator&#40;SessionFactoryUtils.java&#58;122&#41;
    	at org.springframework.orm.hibernate.HibernateAccessor.getJdbcExceptionTranslator&#40;HibernateAccessor.java&#58;158&#41;
    	at org.springframework.orm.hibernate.HibernateAccessor.afterPropertiesSet&#40;HibernateAccessor.java&#58;201&#41;
    	at org.springframework.orm.hibernate.HibernateTemplate.<init>&#40;HibernateTemplate.java&#58;113&#41;
    	at org.springframework.orm.hibernate.support.HibernateDaoSupport.createHibernateTemplate&#40;HibernateDaoSupport.java&#58;87&#41;
    	at org.springframework.orm.hibernate.support.HibernateDaoSupport.setSessionFactory&#40;HibernateDaoSupport.java&#58;74&#41;
    	at sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Native Method&#41;
    	at sun.reflect.NativeMethodAccessorImpl.invoke&#40;Unknown Source&#41;
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;Unknown Source&#41;
    	at java.lang.reflect.Method.invoke&#40;Unknown Source&#41;
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue&#40;BeanWrapperImpl.java&#58;684&#41;
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue&#40;BeanWrapperImpl.java&#58;588&#41;
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue&#40;BeanWrapperImpl.java&#58;720&#41;
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValues&#40;BeanWrapperImpl.java&#58;747&#41;
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValues&#40;BeanWrapperImpl.java&#58;736&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues&#40;AbstractAutowireCapableBeanFactory.java&#58;797&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean&#40;AbstractAutowireCapableBeanFactory.java&#58;637&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;271&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;208&#41;
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;204&#41;
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;136&#41;
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons&#40;DefaultListableBeanFactory.java&#58;230&#41;
    	at org.springframework.context.support.AbstractApplicationContext.refresh&#40;AbstractApplicationContext.java&#58;284&#41;
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;80&#41;
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;65&#41;
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;56&#41;
    	at com.projectx.dao.UserDAOTestAbstract.setUp&#40;UserDAOTestAbstract.java&#58;25&#41;
    	at junit.framework.TestCase.runBare&#40;TestCase.java&#58;125&#41;
    	at junit.framework.TestResult$1.protect&#40;TestResult.java&#58;106&#41;
    	at junit.framework.TestResult.runProtected&#40;TestResult.java&#58;124&#41;
    	at junit.framework.TestResult.run&#40;TestResult.java&#58;109&#41;
    	at junit.framework.TestCase.run&#40;TestCase.java&#58;118&#41;
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests&#40;RemoteTestRunner.java&#58;421&#41;
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run&#40;RemoteTestRunner.java&#58;305&#41;
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main&#40;RemoteTestRunner.java&#58;186&#41;
    18&#58;57&#58;23,213  WARN JDBCExceptionReporter&#58;38 - SQL Error&#58; -33, SQLState&#58; S1000
    18&#58;57&#58;23,223 ERROR JDBCExceptionReporter&#58;46 - Access is denied
    18&#58;57&#58;23,233  WARN JDBCExceptionReporter&#58;38 - SQL Error&#58; -33, SQLState&#58; S1000
    18&#58;57&#58;23,233 ERROR JDBCExceptionReporter&#58;46 - Access is denied
    18&#58;57&#58;23,233 ERROR JDBCExceptionReporter&#58;38 - Cannot open connection
    java.sql.SQLException&#58; Access is denied
    	at org.hsqldb.jdbc.jdbcUtil.sqlException&#40;Unknown Source&#41;
    	at org.hsqldb.jdbc.jdbcConnection.<init>&#40;Unknown Source&#41;
    	at org.hsqldb.jdbcDriver.getConnection&#40;Unknown Source&#41;
    	at org.hsqldb.jdbcDriver.connect&#40;Unknown Source&#41;
    	at java.sql.DriverManager.getConnection&#40;Unknown Source&#41;
    	at java.sql.DriverManager.getConnection&#40;Unknown Source&#41;
    	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager&#40;DriverManagerDataSource.java&#58;156&#41;
    	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager&#40;DriverManagerDataSource.java&#58;144&#41;
    	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnection&#40;DriverManagerDataSource.java&#58;132&#41;
    	at org.springframework.orm.hibernate.LocalDataSourceConnectionProvider.getConnection&#40;LocalDataSourceConnectionProvider.java&#58;59&#41;
    	at net.sf.hibernate.impl.BatcherImpl.openConnection&#40;BatcherImpl.java&#58;286&#41;
    	at net.sf.hibernate.impl.SessionImpl.connect&#40;SessionImpl.java&#58;3326&#41;
    	at net.sf.hibernate.impl.SessionImpl.connection&#40;SessionImpl.java&#58;3286&#41;
    	at net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement&#40;BatcherImpl.java&#58;65&#41;
    	at net.sf.hibernate.loader.Loader.prepareQueryStatement&#40;Loader.java&#58;779&#41;
    	at net.sf.hibernate.loader.Loader.doQuery&#40;Loader.java&#58;265&#41;
    	at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections&#40;Loader.java&#58;133&#41;
    	at net.sf.hibernate.loader.Loader.doList&#40;Loader.java&#58;1033&#41;
    	at net.sf.hibernate.loader.Loader.list&#40;Loader.java&#58;1024&#41;
    	at net.sf.hibernate.hql.QueryTranslator.list&#40;QueryTranslator.java&#58;854&#41;
    	at net.sf.hibernate.impl.SessionImpl.find&#40;SessionImpl.java&#58;1544&#41;
    	at net.sf.hibernate.impl.SessionImpl.find&#40;SessionImpl.java&#58;1521&#41;
    	at net.sf.hibernate.impl.SessionImpl.find&#40;SessionImpl.java&#58;1517&#41;
    	at com.projectx.dao.UserDAOHibernateInterceptorImpl.findUser&#40;UserDAOHibernateInterceptorImpl.java&#58;34&#41;
    	at sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Native Method&#41;
    	at sun.reflect.NativeMethodAccessorImpl.invoke&#40;Unknown Source&#41;
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;Unknown Source&#41;
    	at java.lang.reflect.Method.invoke&#40;Unknown Source&#41;
    	at org.springframework.aop.framework.AopProxyUtils.invokeJoinpointUsingReflection&#40;AopProxyUtils.java&#58;61&#41;
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint&#40;ReflectiveMethodInvocation.java&#58;149&#41;
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed&#40;ReflectiveMethodInvocation.java&#58;116&#41;
    	at org.springframework.orm.hibernate.HibernateInterceptor.invoke&#40;HibernateInterceptor.java&#58;163&#41;
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed&#40;ReflectiveMethodInvocation.java&#58;138&#41;
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke&#40;JdkDynamicAopProxy.java&#58;152&#41;
    	at $Proxy0.findUser&#40;Unknown Source&#41;
    	at com.projectx.dao.UserDAOTestAbstract.setUp&#40;UserDAOTestAbstract.java&#58;28&#41;
    	at junit.framework.TestCase.runBare&#40;TestCase.java&#58;125&#41;
    	at junit.framework.TestResult$1.protect&#40;TestResult.java&#58;106&#41;
    	at junit.framework.TestResult.runProtected&#40;TestResult.java&#58;124&#41;
    	at junit.framework.TestResult.run&#40;TestResult.java&#58;109&#41;
    	at junit.framework.TestCase.run&#40;TestCase.java&#58;118&#41;
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests&#40;RemoteTestRunner.java&#58;421&#41;
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run&#40;RemoteTestRunner.java&#58;305&#41;
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main&#40;RemoteTestRunner.java&#58;186&#41;

    Here is the code:
    Code:
    /*
     * Created on Sep 3, 2004
     * Created by Prashant
     */
    package com.projectx.dao;
    
    import junit.framework.TestCase;
    
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    
    import com.projectx.model.User;
    
    /**
     * @author Prashant
     *
     */
    public abstract class UserDAOTestAbstract extends TestCase &#123;
    	
    	private UserDAO userDAO;
    	
    	/*
    	 * @see TestCase#setUp&#40;&#41;
    	 */
    	protected void setUp&#40;&#41; throws Exception &#123;
    		ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext&#40;getApplicationContextPath&#40;&#41;&#41;;
    		this.userDAO = &#40;UserDAO&#41; ctx.getBean&#40;"userDAO"&#41;;
    		
    		User user = userDAO.findUser&#40;"firstuser"&#41;;
    		if &#40;user != null&#41; userDAO.deleteUser&#40;user&#41;;
    		user = userDAO.findUser&#40;"firstuser-changed"&#41;;
    		if &#40;user != null&#41; userDAO.deleteUser&#40;user&#41;;
    	&#125;	
    
    	public abstract String getApplicationContextPath&#40;&#41;;	
    	
    	public static void main&#40;String&#91;&#93; args&#41; &#123;
    		junit.textui.TestRunner.run&#40;UserDAOTestAbstract.class&#41;;
    	&#125;
    
    	/*
    	 * @see TestCase#tearDown&#40;&#41;
    	 */
    	protected void tearDown&#40;&#41; throws Exception &#123;
    		super.tearDown&#40;&#41;;
    	&#125;
    
    	public void testCreateAndFindUser&#40;&#41; &#123;
    		// See if user already exists
    		User user1 = userDAO.findUser&#40;"firstuser"&#41;;
    		if &#40;user1 != null&#41; &#123;
    			// user exists, check if it correct user 
    			assertEquals&#40;user1.getUserName&#40;&#41;, "firstuser"&#41;;
    			
    			// delete the user to test create
    			userDAO.deleteUser&#40;user1&#41;;
    		&#125; 
    		
    		// create user
    		User user = new User&#40;&#41;;
    		user.setUserName&#40;"firstuser"&#41;;
    		user.setPassword&#40;"firstuserpassword"&#41;;
    		userDAO.createUser&#40;user&#41;;
    		
    		// find user
    		User user2 = userDAO.findUser&#40;"firstuser"&#41;;
    		
    		// make sure they are same
    		assertEquals&#40;user, user2&#41;;	
    		
    		// delte user
    		userDAO.deleteUser&#40;user&#41;;
    	&#125;
    
    	public void testUpdateUser&#40;&#41; &#123;
    		// See if user already exists
    		User user1 = userDAO.findUser&#40;"firstuser"&#41;;
    		if &#40;user1 != null&#41; &#123;
    			// user exists, check if it correct user 
    			assertEquals&#40;user1.getUserName&#40;&#41;, "firstuser"&#41;;
    			
    			// delete the user to test create
    			userDAO.deleteUser&#40;user1&#41;;
    		&#125; 
    		
    		// create user
    		User user = new User&#40;&#41;;
    		user.setUserName&#40;"firstuser"&#41;;
    		user.setPassword&#40;"firstuserpassword"&#41;;
    		userDAO.createUser&#40;user&#41;;
    		
    		// change user
    		user.setUserName&#40;"firstuser-changed"&#41;;
    		user.setPassword&#40;"firstuserpassword-changed"&#41;;
    		
    		// update user
    		userDAO.updateUser&#40;user&#41;;
    		
    		// find again
    		User user2 = userDAO.findUser&#40;"firstuser-changed"&#41;;
    		
    		// are the updates there?
    		assertEquals&#40;user, user2&#41;;
    		
    		// delte user
    		userDAO.deleteUser&#40;user&#41;;
    	&#125;
    	
    	public void testDuplicateInsert&#40;&#41; &#123;
    		// create user
    		User user = new User&#40;&#41;;
    		user.setUserName&#40;"firstuser"&#41;;
    		user.setPassword&#40;"firstuserpassword"&#41;;
    		userDAO.createUser&#40;user&#41;;
    		
    		// create another user, duplicate of first one
    		User user1 = new User&#40;&#41;;
    		user1.setUserName&#40;"firstuser"&#41;;
    		user1.setPassword&#40;"firstuserpassword"&#41;;
    		
    		try &#123;
    			userDAO.createUser&#40;user1&#41;;
    		&#125; catch &#40;Exception e&#41;&#123;
    			// exception must be raise, as test is trying to insert duplicate rows
    			assertTrue&#40;true&#41;;
    			return;
    		&#125;
    		
    		// if exception was not raised, then test failed
    		assertTrue&#40;false&#41;;
    	&#125;
    	
    	public void testDuplicateUpdate&#40;&#41; &#123;
    		// create one user
    		User user = userDAO.findUser&#40;"firstuser"&#41;;
    		if &#40;user == null&#41; &#123;
    			user = new User&#40;&#41;;
    			user.setUserName&#40;"firstuser"&#41;;
    			user.setPassword&#40;"firstuserpassword"&#41;;
    			userDAO.createUser&#40;user&#41;;
    		&#125; 		
    		// create another
    		User user1 = userDAO.findUser&#40;"firstuser-changed"&#41;;
    		if &#40;user1 == null&#41; &#123;
    			user1 = new User&#40;&#41;;
    			user1.setUserName&#40;"firstuser-changed"&#41;;
    			user1.setPassword&#40;"firstuserpassword-changed"&#41;;
    			userDAO.createUser&#40;user1&#41;;
    		&#125;
    		
    		// find the first one
    		User user2 = userDAO.findUser&#40;"firstuser"&#41;;
    		
    		// change it to match values of second one
    		user2.setUserName&#40;"firstuser-changed"&#41;;
    		user2.setPassword&#40;"firstuserpassword-changed"&#41;;
    		
    		// update it, should result in exception
    		try &#123;
    		userDAO.updateUser&#40;user2&#41;;
    		&#125; catch &#40;Exception e&#41; &#123;
    			assertTrue&#40;true&#41;;
    			return;
    		&#125;
    		
    		// if it reaches here, then test failed as it allowed to update a user to be with same username as another user. 
    		assertTrue&#40;false&#41;;
    	&#125;	
    	
    
    &#125;
    Code:
    /*
     * Created on Sep 3, 2004
     * Created by Prashant
     */
    package com.projectx.dao;
    
    /**
     * @author Prashant
     *  
     */
    public class UserDAOTestHibernateInterceptor extends UserDAOTestAbstract &#123;
    	/*
    	 * &#40;non-Javadoc&#41;
    	 * 
    	 * @see com.projectx.dao.UserDAOTestAbstract#getApplicationContextPath&#40;&#41;
    	 */
    	public String getApplicationContextPath&#40;&#41; &#123;
    		return &#40;"applicationContext-hibernate-interceptor.xml"&#41;;
    	&#125;
    &#125;
    Code:
    /*
     * Created on Sep 3, 2004
     * Created by Prashant
     */
    package com.projectx.dao;
    
    import java.util.Iterator;
    import java.util.List;
    
    import net.sf.hibernate.Hibernate;
    import net.sf.hibernate.HibernateException;
    import net.sf.hibernate.Session;
    
    import org.springframework.orm.hibernate.SessionFactoryUtils;
    import org.springframework.orm.hibernate.support.HibernateDaoSupport;
    
    import com.projectx.model.User;
    
    /**
     * @author Prashant
     *  
     */
    public class UserDAOHibernateInterceptorImpl extends HibernateDaoSupport
    		implements UserDAO &#123;
    
    	/**
    	 * @param userName
    	 * @return User object for the given userName
    	 */
    	public User findUser&#40;String userName&#41; &#123;
    		Session session = SessionFactoryUtils.getSession&#40;getSessionFactory&#40;&#41;,
    				false&#41;;
    		try &#123;
    			List list = session.find&#40;"from User user where user.userName=?", userName, Hibernate.STRING&#41;;
    			Iterator iterator = list.iterator&#40;&#41;;
    			while &#40;iterator.hasNext&#40;&#41;&#41; &#123;
    				User user = &#40;User&#41; iterator.next&#40;&#41;;
    				return user;
    			&#125;
    			return null;
    		&#125; catch &#40;HibernateException ex&#41; &#123;
    			throw SessionFactoryUtils.convertHibernateAccessException&#40;ex&#41;;
    		&#125;
    	&#125;
    
    	/**
    	 * @param user
    	 *            User object to be updated
    	 */
    	public void updateUser&#40;User user&#41; &#123;
    		return;
    	&#125;
    
    	/**
    	 * @param user
    	 *            User object to be created
    	 */
    	public void createUser&#40;User user&#41; &#123;
    		Session session = SessionFactoryUtils.getSession&#40;getSessionFactory&#40;&#41;,
    				false&#41;;
    		try &#123;
    			session.save&#40;user&#41;;
    			return;
    		&#125; catch &#40;HibernateException ex&#41; &#123;
    			throw SessionFactoryUtils.convertHibernateAccessException&#40;ex&#41;;
    		&#125;
    	&#125;
    
    	/**
    	 * @param user
    	 *            User object to be deleted
    	 */
    	public void deleteUser&#40;User user&#41; &#123;
    		return;
    	&#125;
    &#125;
    The hibernate mapping file is:
    Code:
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
              "http&#58;//hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
    
    <hibernate-mapping>
    
      <class name="com.projectx.model.User" table="user">
        <meta attribute="class-description">
          Represents a user.
        </meta>
    
        <id name="id" type="int" column="user_id">
          <meta attribute="scope-set">protected</meta>
          <generator class="native"/>
        </id>
    
        <property name="userName" type="string">
          <meta attribute="use-in-tostring">true</meta>
          <column name="username" not-null="true" unique="true"/>
        </property>
    
        <property name="password" type="string">
          <meta attribute="use-in-tostring">true</meta>
          <column name="password" not-null="true"/>
        </property>
    
      </class>
    
    </hibernate-mapping>

    I am using spring 1.1 and hibernate 2.1.6.

    I am using the sample for HibernateInterceptor from Spring documentation as a starting point.

    Thanks,
    Prashant Rane

  • #2
    18:57:21,581 WARN SettingsFactory:96 - Could not obtain connection metadata
    java.sql.SQLException: Access is denied
    at org.hsqldb.jdbc.jdbcUtil.sqlException(Unknown Source)
    at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source)
    at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
    at org.hsqldb.jdbcDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    Are you sure the jdbc connection configuration parameters are OK?
    also try replacing
    jdbc:hsqldb:data/projectx
    by full path to your database files.

    Comment


    • #3
      One more thing, are you trying to use Hibernate without transaction managements?
      for an example of Transaction management for Hibernate using TransactionInterceptor, take a look at this thread.

      HTH
      Last edited by Rod Johnson; Jan 18th, 2006, 10:46 AM.

      Comment


      • #4
        Originally posted by irbouho
        18:57:21,581 WARN SettingsFactory:96 - Could not obtain connection metadata
        java.sql.SQLException: Access is denied
        at org.hsqldb.jdbc.jdbcUtil.sqlException(Unknown Source)
        at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source)
        at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
        at org.hsqldb.jdbcDriver.connect(Unknown Source)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at java.sql.DriverManager.getConnection(Unknown Source)
        Are you sure the jdbc connection configuration parameters are OK?
        also try replacing
        jdbc:hsqldb:data/projectx
        by full path to your database files.
        My HibernateTemplate based DAO works just fine with the same hibernate configuration. I am trying two different spring configurations: One that uses HibernateTemplate (works fine) and another that uses HibernateInterceptor and doesn't work.

        This works.
        XML config
        Code:
        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
        
        <beans>
        
        	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        		<property name="driverClassName"><value>org.hsqldb.jdbcDriver</value></property>
        		<property name="url"><value>jdbc&#58;hsqldb&#58;data/projectx</value></property>
        		<property name="username"><value>sa</value></property>
        		<property name="password"><value></value></property>
        	</bean>
        
        	<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
        		<property name="dataSource"><ref local="dataSource"/></property>
        		<property name="mappingResources">
        			<value>projectx.hbm.xml</value>
        		</property>
        		<property name="hibernateProperties">
        			<props>
        				<prop key="hibernate.dialect">net.sf.hibernate.dialect.HSQLDialect</prop>
        			</props>
        		</property>
        	</bean>
        
        	<bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
        		<property name="sessionFactory"><ref local="sessionFactory"/></property>
        	</bean>
        
        	<bean id="userDAO" class="com.projectx.dao.UserDAOHibernateTemplateImpl">
        		<property name="sessionFactory"><ref local="sessionFactory"/></property>
        	</bean>
        
        </beans>
        Associate DAO java file that works.
        Code:
        /*
         * Created on Sep 3, 2004
         * Created by Prashant
         */
        package com.projectx.dao;
        
        import java.util.Iterator;
        import java.util.List;
        
        import org.springframework.orm.hibernate.support.HibernateDaoSupport;
        
        import com.projectx.model.User;
        
        /**
         * @author Prashant
         *  
         */
        public class UserDAOHibernateTemplateImpl extends HibernateDaoSupport implements
        		UserDAO &#123;
        
        	/**
        	 * @param userName
        	 * @return User object for the given userName
        	 */
        	public User findUser&#40;String userName&#41; &#123;
        		List list = getHibernateTemplate&#40;&#41;.find&#40;
        				"from User user where user.userName=?", userName&#41;;
        		if &#40;list == null&#41;
        			return null;
        		Iterator iter = list.iterator&#40;&#41;;
        		while &#40;iter.hasNext&#40;&#41;&#41; &#123;
        			User user = &#40;User&#41; iter.next&#40;&#41;;
        			return user;
        		&#125;
        		return null;
        	&#125;
        
        	/**
        	 * @param user
        	 *            User object to be updated
        	 */
        	public void updateUser&#40;User user&#41; &#123;
        		getHibernateTemplate&#40;&#41;.update&#40;user&#41;;
        		return;
        	&#125;
        
        	/**
        	 * @param user
        	 *            User object to be created
        	 */
        	public void createUser&#40;User user&#41; &#123;
        		getHibernateTemplate&#40;&#41;.save&#40;user&#41;;
        		return;
        	&#125;
        
        	/**
        	 * @param user
        	 *            User object to be deleted
        	 */
        	public void deleteUser&#40;User user&#41; &#123;
        		getHibernateTemplate&#40;&#41;.delete&#40;user&#41;;
        		return;
        	&#125;
        
        &#125;
        This doesn't work:
        XML file
        Code:
        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
        
        <beans>
        
        	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        		<property name="driverClassName">
        			<value>org.hsqldb.jdbcDriver</value>
        		</property>
        		<property name="url">
        			<value>jdbc&#58;hsqldb&#58;data/projectx</value>
        		</property>
        		<property name="username">
        			<value>sa</value>
        		</property>
        		<property name="password">
        			<value>
        			</value>
        		</property>
        	</bean>
        
        	<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
        		<property name="dataSource">
        			<ref local="dataSource" />
        		</property>
        		<property name="mappingResources">
        			<value>projectx.hbm.xml</value>
        		</property>
        		<property name="hibernateProperties">
        			<props>
        				<prop key="hibernate.dialect">net.sf.hibernate.dialect.HSQLDialect</prop>
        			</props>
        		</property>
        	</bean>
        
        	<bean id="myHibernateInterceptor" class="org.springframework.orm.hibernate.HibernateInterceptor">
        		<property name="sessionFactory">
        			<ref local="sessionFactory" />
        		</property>
        	</bean>
        
        	<bean id="userDAOTarget" class="com.projectx.dao.UserDAOHibernateInterceptorImpl">
        		<property name="sessionFactory">
        			<ref local="sessionFactory" />
        		</property>
        	</bean>
        
        	<bean id="userDAO" class="org.springframework.aop.framework.ProxyFactoryBean">
        		<property name="proxyInterfaces">
        			<value>com.projectx.dao.UserDAO</value>
        		</property>
        		<property name="interceptorNames">
        			<list>
        				<value>myHibernateInterceptor</value>
        				<value>userDAOTarget</value>
        			</list>
        		</property>
        	</bean>
        
        </beans>
        Associated DAO java file
        Code:
        /*
         * Created on Sep 3, 2004
         * Created by Prashant
         */
        package com.projectx.dao;
        
        import java.util.Iterator;
        import java.util.List;
        
        import net.sf.hibernate.Hibernate;
        import net.sf.hibernate.HibernateException;
        import net.sf.hibernate.Session;
        
        import org.springframework.orm.hibernate.SessionFactoryUtils;
        import org.springframework.orm.hibernate.support.HibernateDaoSupport;
        
        import com.projectx.model.User;
        
        /**
         * @author Prashant
         *  
         */
        public class UserDAOHibernateInterceptorImpl extends HibernateDaoSupport
        		implements UserDAO &#123;
        
        	/**
        	 * @param userName
        	 * @return User object for the given userName
        	 */
        	public User findUser&#40;String userName&#41; &#123;
        		Session session = SessionFactoryUtils.getSession&#40;getSessionFactory&#40;&#41;,
        				false&#41;;
        		try &#123;
        			List list = session.find&#40;"from User user where user.userName=?", userName, Hibernate.STRING&#41;;
        			Iterator iterator = list.iterator&#40;&#41;;
        			while &#40;iterator.hasNext&#40;&#41;&#41; &#123;
        				User user = &#40;User&#41; iterator.next&#40;&#41;;
        				return user;
        			&#125;
        			return null;
        		&#125; catch &#40;HibernateException ex&#41; &#123;
        			throw SessionFactoryUtils.convertHibernateAccessException&#40;ex&#41;;
        		&#125;
        	&#125;
        
        	/**
        	 * @param user
        	 *            User object to be updated
        	 */
        	public void updateUser&#40;User user&#41; &#123;
        		return;
        	&#125;
        
        	/**
        	 * @param user
        	 *            User object to be created
        	 */
        	public void createUser&#40;User user&#41; &#123;
        		Session session = SessionFactoryUtils.getSession&#40;getSessionFactory&#40;&#41;,
        				false&#41;;
        		try &#123;
        			session.save&#40;user&#41;;
        			return;
        		&#125; catch &#40;HibernateException ex&#41; &#123;
        			throw SessionFactoryUtils.convertHibernateAccessException&#40;ex&#41;;
        		&#125;
        	&#125;
        
        	/**
        	 * @param user
        	 *            User object to be deleted
        	 */
        	public void deleteUser&#40;User user&#41; &#123;
        		return;
        	&#125;
        &#125;

        Comment


        • #5
          Resolve the issue: Stupid eclipse ant editor as XML editor

          I was using Eclipse's ant editor as XML editor to edit spring's config files. I was also using built-in formating functionality to format the XML file. Well, the stupid thing added a newline at the very wrong place, my dataSource's password value. No wonder it was saying access denied. I thought, it wasn't getting intercepted to set correct sessionFactory.

          Code:
          	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
          		<property name="driverClassName">
          			<value>org.hsqldb.jdbcDriver</value>
          		</property>
          		<property name="url">
          			<value>jdbc&#58;hsqldb&#58;data/projectx</value>
          		</property>
          		<property name="username">
          			<value>sa</value>
          		</property>
          		<property name="password">
          			<value></value>
          		</property>
          	</bean>
          Above fragment get's turned into following fragment after applying eclipse auto format:
          Code:
          	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
          		<property name="driverClassName">
          			<value>org.hsqldb.jdbcDriver</value>
          		</property>
          		<property name="url">
          			<value>jdbc&#58;hsqldb&#58;data/projectx</value>
          		</property>
          		<property name="username">
          			<value>sa</value>
          		</property>
          		<property name="password">
          			<value>
          			</value>
          		</property>
          	</bean>
          Notice the newline in password value. That's why I was getting access denied error.

          Comment


          • #6
            irbouho

            18:57:21,581 WARN SettingsFactory:96 - Could not obtain connection metadata
            java.sql.SQLException: Access is denied
            at org.hsqldb.jdbc.jdbcUtil.sqlException(Unknown Source)
            at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source)
            at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
            at org.hsqldb.jdbcDriver.connect(Unknown Source)
            at java.sql.DriverManager.getConnection(Unknown Source)
            at java.sql.DriverManager.getConnection(Unknown Source)
            This is thrown when hibernate can't load the meta data from the database because the driver doesnt support that action. It isnt a bug. The database connection should work. I looks like a SQLException but hibernate actually catches it and displayes a WARN message.

            Comment

            Working...
            X