Hi, more problems with the application (using hibernate and the spring framework) I am working on...
I have a hierarchy (parent/child) consisting of three concrete types. I want to add caching to improve database retrieval performance, and am trying to integrate with ehcache.
But when I start Tomcat, I get an Exception - which has something to do with the setup of the cache. I think it is specifically related to the ehcache.xml file.
If I remove the ehcache.xml file, then I do not get an error (and of course no caching). If the ehcache.xml file is there, then I get the exception on startup.
Hibernate version:
2.1.6
Mapping documents:
My node.hbm.xml:
<hibernate-mapping>
<class name="dk.ciber.danbro.common.impl.AbstractBase" table="BASE" >
<cache usage="read-write" />
<id name="id" type="long" column="ID">
<generator class="increment"/>
</id>
<joined-subclass name="dk.ciber.danbro.common.impl.AbstractNode" table="NODE">
<key column="ID" />
<set name="children" table="NODE">
<key column="PARENT_ID"/>
<one-to-many class="dk.ciber.danbro.common.impl.AbstractNode"/>
</set>
<many-to-one name="parent" column="PARENT_ID" class="dk.ciber.danbro.common.impl.AbstractNode" />
<joined-subclass name="dk.ciber.danbro.facility.impl.DefaultFacilityNode" table="FACILITY">
<key column="ID" />
<property name="name" column="NAME" type="string" />
<property name="number" column="FACILITY_NUMBER" type="long" />
<joined-subclass name="dk.ciber.danbro.facility.impl.DefaultNameNode" table="VD">
<key column="ID" />
</joined-subclass>
<joined-subclass name="dk.ciber.danbro.facility.impl.DefaultConstructionNode" table="CONSTRUCTION">
<key column="ID" />
</joined-subclass>
<joined-subclass name="dk.ciber.danbro.facility.impl.DefaultElementNode" table="ELEMENT">
<key column="ID" />
</joined-subclass>
</joined-subclass>
</joined-subclass>
</class>
</hibernate-mapping>
My ehcache.xml:
<ehcache>
<cache name="dk.ciber.danbro.common.impl.AbstractBase"
maxElementsInMemory="20000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
overflowToDisk="false"
/>
</ehcache>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
2004-09-08 15:11:23,671 ERROR [org.springframework.web.servlet.DispatcherServlet] - <Context initialization failed>
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mainController' defined in resource [/WEB-INF/danbroII-servlet.xml] of ServletContext: Can't resolve reference to bean 'facilityMgr' while setting property 'facilityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'facilityMgr' defined in resource [/WEB-INF/danbroII-servlet.xml] of ServletContext: Can't resolve reference to bean 'dao' while setting property 'constructor argument'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dao' defined in resource [/WEB-INF/danbroII-servlet.xml] of ServletContext: Can't resolve reference to bean 'hibernateSessionFactory' while setting property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateSessionFactory' defined in resource [/WEB-INF/danbroII-servlet.xml] of ServletContext: Initialization of bean failed; nested exception is java.lang.NullPointerException: null
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'facilityMgr' defined in resource [/WEB-INF/danbroII-servlet.xml] of ServletContext: Can't resolve reference to bean 'dao' while setting property 'constructor argument'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dao' defined in resource [/WEB-INF/danbroII-servlet.xml] of ServletContext: Can't resolve reference to bean 'hibernateSessionFactory' while setting property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateSessionFactory' defined in resource [/WEB-INF/danbroII-servlet.xml] of ServletContext: Initialization of bean failed; nested exception is java.lang.NullPointerException: null
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dao' defined in resource [/WEB-INF/danbroII-servlet.xml] of ServletContext: Can't resolve reference to bean 'hibernateSessionFactory' while setting property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateSessionFactory' defined in resource [/WEB-INF/danbroII-servlet.xml] of ServletContext: Initialization of bean failed; nested exception is java.lang.NullPointerException: null
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateSessionFactory' defined in resource [/WEB-INF/danbroII-servlet.xml] of ServletContext: Initialization of bean failed; nested exception is java.lang.NullPointerException: null
java.lang.NullPointerException
at net.sf.ehcache.config.Configuration$DefaultCache.access$100(Configuration.java:308)
at net.sf.ehcache.config.Configuration.getDefaultCache(Configuration.java:129)
at net.sf.ehcache.CacheManager.configure(CacheManager.java:159)
at net.sf.ehcache.CacheManager.<init>(CacheManager.java:128)
at net.sf.ehcache.CacheManager.create(CacheManager.java:180)
at net.sf.ehcache.CacheManager.getInstance(CacheManager.java:196)
at net.sf.ehcache.hibernate.Plugin.<init>(Plugin.java:92)
at net.sf.ehcache.hibernate.Provider.buildCache(Provider.java:89)
at net.sf.hibernate.cfg.Configuration.configureCaches(Configuration.java:1130)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:790)
at org.springframework.orm.hibernate.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:436)
at org.springframework.orm.hibernate.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:374)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:948)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:284)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:204)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:136)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveReference(AbstractAutowireCapableBeanFactory.java:866)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveValueIfNecessary(AbstractAutowireCapableBeanFactory.java:809)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:751)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:604)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:267)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:204)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:136)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveReference(AbstractAutowireCapableBeanFactory.java:866)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveValueIfNecessary(AbstractAutowireCapableBeanFactory.java:809)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveConstructorArguments(AbstractAutowireCapableBeanFactory.java:487)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:391)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:247)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:204)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:136)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveReference(AbstractAutowireCapableBeanFactory.java:866)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveValueIfNecessary(AbstractAutowireCapableBeanFactory.java:809)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:751)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:604)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:267)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:204)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:136)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:209)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:279)
at org.springframework.web.context.support.XmlWebApplicationContext.refresh(XmlWebApplicationContext.java:131)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:283)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:231)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:201)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:102)
at javax.servlet.GenericServlet.init(GenericServlet.java:256)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1044)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:887)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3959)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4284)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:866)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:850)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:638)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:320)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:875)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:727)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:477)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1008)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:394)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:166)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1134)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:832)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1126)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:521)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2345)
at org.apache.catalina.startup.Catalina.start(Catalina.java:594)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:297)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:398)
Name and version of the database you are using:
Hypersonic
Debug level Hibernate log excerpt:
2004-09-08 15:11:23,140 INFO [net.sf.hibernate.cfg.Environment] - <Hibernate 2.1.6>
2004-09-08 15:11:23,140 INFO [net.sf.hibernate.cfg.Environment] - <hibernate.properties not found>
2004-09-08 15:11:23,140 INFO [net.sf.hibernate.cfg.Environment] - <using CGLIB reflection optimizer>
2004-09-08 15:11:23,203 DEBUG [net.sf.hibernate.util.DTDEntityResolver] - <trying to locate
http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath under net/sf/hibernate/>
2004-09-08 15:11:23,203 DEBUG [net.sf.hibernate.util.DTDEntityResolver] - <found
http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath>
2004-09-08 15:11:23,359 INFO [net.sf.hibernate.cfg.Binder] - <Mapping class: dk.ciber.danbro.common.impl.AbstractBase -> BASE>
2004-09-08 15:11:23,359 DEBUG [net.sf.hibernate.cache.CacheFactory] - <cache for: dk.ciber.danbro.common.impl.AbstractBase usage strategy: read-write>
2004-09-08 15:11:23,437 DEBUG [net.sf.hibernate.cfg.Binder] - <Mapped property: id -> ID, type: long>
2004-09-08 15:11:23,515 INFO [net.sf.hibernate.cfg.Binder] - <Mapping joined-subclass: dk.ciber.danbro.common.impl.AbstractNode -> NODE>
2004-09-08 15:11:23,546 DEBUG [net.sf.hibernate.cfg.Binder] - <Mapped property: children, type: java.util.Set>
2004-09-08 15:11:23,546 DEBUG [net.sf.hibernate.cfg.Binder] - <Mapped property: parent -> PARENT_ID, type: dk.ciber.danbro.common.impl.AbstractNode>
2004-09-08 15:11:23,546 INFO [net.sf.hibernate.cfg.Binder] - <Mapping joined-subclass: dk.ciber.danbro.facility.impl.DefaultFacilityNode -> FACILITY>
2004-09-08 15:11:23,546 DEBUG [net.sf.hibernate.cfg.Binder] - <Mapped property: name -> NAME, type: string>
2004-09-08 15:11:23,546 DEBUG [net.sf.hibernate.cfg.Binder] - <Mapped property: number -> FACILITY_NUMBER, type: long>
2004-09-08 15:11:23,546 INFO [net.sf.hibernate.cfg.Binder] - <Mapping joined-subclass: dk.ciber.danbro.facility.impl.DefaultNameNode -> VD>
2004-09-08 15:11:23,546 INFO [net.sf.hibernate.cfg.Binder] - <Mapping joined-subclass: dk.ciber.danbro.facility.impl.DefaultConstructionNode -> CONSTRUCTION>
2004-09-08 15:11:23,546 INFO [net.sf.hibernate.cfg.Binder] - <Mapping joined-subclass: dk.ciber.danbro.facility.impl.DefaultElementNode -> ELEMENT>
2004-09-08 15:11:23,562 INFO [org.springframework.orm.hibernate.LocalSessionFactoryBean] - <Building new Hibernate SessionFactory>
2004-09-08 15:11:23,562 INFO [net.sf.hibernate.cfg.Configuration] - <processing one-to-many association mappings>
2004-09-08 15:11:23,562 DEBUG [net.sf.hibernate.cfg.Binder] - <Second pass for collection: dk.ciber.danbro.common.impl.AbstractNode.children>
2004-09-08 15:11:23,562 INFO [net.sf.hibernate.cfg.Binder] - <Mapping collection: dk.ciber.danbro.common.impl.AbstractNode.children -> NODE>
2004-09-08 15:11:23,562 DEBUG [net.sf.hibernate.cfg.Binder] - <Mapped collection key: PARENT_ID, one-to-many: dk.ciber.danbro.common.impl.AbstractNode>
2004-09-08 15:11:23,562 INFO [net.sf.hibernate.cfg.Configuration] - <processing one-to-one association property references>
2004-09-08 15:11:23,562 INFO [net.sf.hibernate.cfg.Configuration] - <processing foreign key constraints>
2004-09-08 15:11:23,562 DEBUG [net.sf.hibernate.cfg.Configuration] - <resolving reference to class: dk.ciber.danbro.facility.impl.DefaultFacilityNode>
2004-09-08 15:11:23,562 DEBUG [net.sf.hibernate.cfg.Configuration] - <resolving reference to class: dk.ciber.danbro.common.impl.AbstractBase>
2004-09-08 15:11:23,562 DEBUG [net.sf.hibernate.cfg.Configuration] - <resolving reference to class: dk.ciber.danbro.common.impl.AbstractNode>
2004-09-08 15:11:23,562 DEBUG [net.sf.hibernate.cfg.Configuration] - <resolving reference to class: dk.ciber.danbro.facility.impl.DefaultFacilityNode>
2004-09-08 15:11:23,562 DEBUG [net.sf.hibernate.cfg.Configuration] - <resolving reference to class: dk.ciber.danbro.facility.impl.DefaultFacilityNode>
2004-09-08 15:11:23,562 DEBUG [net.sf.hibernate.cfg.Configuration] - <resolving reference to class: dk.ciber.danbro.common.impl.AbstractNode>
2004-09-08 15:11:23,578 INFO [net.sf.hibernate.dialect.Dialect] - <Using dialect: net.sf.hibernate.dialect.HSQLDialect>
2004-09-08 15:11:23,593 INFO [net.sf.hibernate.cfg.SettingsFactory] - <Use outer join fetching: true>
2004-09-08 15:11:23,593 INFO [net.sf.hibernate.connection.ConnectionProviderFactory] - <Initializing connection provider: org.springframework.orm.hibernate.LocalDataSourceConnectionProvider>
2004-09-08 15:11:23,593 INFO [net.sf.hibernate.transaction.TransactionManagerLookupFactory] - <No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)>
2004-09-08 15:11:23,593 DEBUG [org.springframework.jdbc.datasource.DriverManagerDataSource] - <Creating new JDBC connection to [jdbc:hsqldb:hsql://localhost:21116]>
2004-09-08 15:11:23,640 INFO [net.sf.hibernate.cfg.SettingsFactory] - <Use scrollable result sets: true>
2004-09-08 15:11:23,640 INFO [net.sf.hibernate.cfg.SettingsFactory] - <Use JDBC3 getGeneratedKeys(): false>
2004-09-08 15:11:23,640 INFO [net.sf.hibernate.cfg.SettingsFactory] - <Optimize cache for minimal puts: false>
2004-09-08 15:11:23,640 INFO [net.sf.hibernate.cfg.SettingsFactory] - <Query language substitutions: {true=1, false=0}>
2004-09-08 15:11:23,640 INFO [net.sf.hibernate.cfg.SettingsFactory] - <cache provider: net.sf.ehcache.hibernate.Provider>
2004-09-08 15:11:23,640 INFO [net.sf.hibernate.cfg.Configuration] - <instantiating and configuring caches>
2004-09-08 15:11:23,656 DEBUG [net.sf.hibernate.cfg.Configuration] - <instantiating cache dk.ciber.danbro.common.impl.AbstractBase>
2004-09-08 15:11:23,656 DEBUG [net.sf.ehcache.CacheManager] - <Creating new CacheManager with default config>
2004-09-08 15:11:23,656 DEBUG [net.sf.ehcache.CacheManager] - <Configuring ehcache from classpath.>
2004-09-08 15:11:23,671 DEBUG [net.sf.ehcache.config.Configurator] - <Configuring ehcache from ehcache.xml found in the classpath: file:/C:/Tomcat%205.0/webapps/danbroII/WEB-INF/classes/ehcache.xml>
What could cause the exception?
Thanks,
Peter