-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: java.lang.IllegalStateException: Cache is not alive.
PostPosted: Wed Jun 23, 2004 3:33 am 
Newbie

Joined: Wed Feb 25, 2004 10:57 am
Posts: 2
Hello we have a web application where we use the Spring framework together with Hibernate and ehcache. The web application works fine. Howeve we want to deploy the same application under a different web app name. The reason for doing so is to have one application access the db and the other one access an old database and let the user search for older records.

These two webapps do not share any mapping files, classes or XML files. They are two separate and distinct web applications (at least I think so).

The problem we encounter is that when both applications are running we get an

Code:
java.lang.IllegalStateException: The gr.ges.ddb.bus.domain.Unit Cache is not alive.
at net.sf.ehcache.Cache.checkStatus(Cache.java:408)
at net.sf.ehcache.Cache.get(Cache.java:219)
at net.sf.ehcache.hibernate.Plugin.get(Plugin.java:119)
at net.sf.hibernate.cache.NonstrictReadWriteCache.get(NonstrictReadWriteCache.java:39)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2072)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1955)
at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1917)
at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:68)
at net.sf.hibernate.type.EntityType.resolveIdentifier(EntityType.java:215)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2169)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:240)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:950)
at net.sf.hibernate.loader.Loader.list(Loader.java:941)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at org.springframework.orm.hibernate.HibernateTemplate$18.doInHibernate(HibernateTemplate.java:341)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:150)
at org.springframework.orm.hibernate.HibernateTemplate.executeFind(HibernateTemplate.java:170)
at org.springframework.orm.hibernate.HibernateTemplate.find(HibernateTemplate.java:337)
at gr.ges.ddb.db.GesDdbAdminServicesDAOHibernate.getUserFromLoginName(GesDdbAdminServicesDAOHibernate.java:99)
at gr.ges.ddb.bus.services.AdminServicesImpl.getUserFromLoginName(AdminServicesImpl.java:182)
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.springframework.aop.framework.AopProxyUtils.invokeJoinpointUsingReflection(AopProxyUtils.java:59)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:138)
at $Proxy8.getUserFromLoginName(Unknown Source)
at gr.ges.ddb.web.GesDdbLoginController.handleRequest(GesDdbLoginController.java:41)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:45)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:389)
at org.springframework.web.servlet.FrameworkServlet.serviceWrapper(FrameworkServlet.java:339)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:315)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)

The point where one of the classes we have written is referenced, points to this line of Java code (GesDdbAdminServicesDAOHibernate.java:99):

return getHibernateTemplate().find("from User user where user.login = ?", loginName);

Note that the above line should return a List of "User" objects but the error message complains about "Unit" objects (a "User" contains a "Unit").

Not sure what is going on. I did a search but I couldn't find any information. Any help is appreciated.

Thank you.

Our Hibernate version is 2, we use WebLogic Server 8.1 under Linux RedHat 9, MSSQL Server 2000 and the mapping documents follow:

User.hbm.xml

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
    PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

    <class name="gr.ges.ddb.bus.domain.User" table="users">
    <cache usage="nonstrict-read-write"/>

        <id name="userCode" type="int" unsaved-value="0" >
            <column name="code_user" sql-type="INTEGER(4)" not-null="true"/>
            <generator class="native"/>
        </id>

        <property name="firstName">
            <column name="fname_user" sql-type="nvarchar"/>
        </property>

        <property name="lastName">
            <column name="lname_user" sql-type="nvarchar"/>
        </property>

        <property name="rank">
            <column name="rank" sql-type="varchar"/>
        </property>

        <property name="duty">
            <column name="duty" sql-type="varchar"/>
        </property>

        <property name="login">
            <column name="login" sql-type="varchar"/>
        </property>

        <property name="password">
            <column name="password" sql-type="varchar"/>
        </property>
       
        <property name="phone">
            <column name="phone" sql-type="varchar"/>
        </property>


        <property name="active">
            <column name="active_user" sql-type="bit(1)"/>
        </property>

        <property name="inactiveDate">
            <column name="inactive_date" />
        </property>

<!-- temp - 2b replaced by unit class maping
        <property name="unitCode">
            <column name="code_unit" sql-type="int"/>
        </property>
-->

<many-to-one name="unit" class="gr.ges.ddb.bus.domain.Unit" column="code_unit"/>


<!--       
<one-to-one name="role" class="gr.ges.ddb.bus.domain.Role" constrained="true" />
-->
       
<many-to-one name="role" class="gr.ges.ddb.bus.domain.Role" column="code_role"/>
       


    </class>

</hibernate-mapping>


Unit.hbm.xml

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
    PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

    <class name="gr.ges.ddb.bus.domain.Unit" table="unit">
    <cache usage="nonstrict-read-write"/>

        <!-- A 32 hex character is our surrogate key. It's automatically
            generated by Hibernate with the UUID pattern. -->
<id name="unitCode" type="int" unsaved-value="0" >
            <column name="code_unit" sql-type="INTEGER(4)" not-null="true"/>
            <generator class="native"/>
        </id>

        <property name="description">
            <column name="desc1_unit" sql-type="varchar"/>
        </property>

        <property name="descriptionExtra">
            <column name="desc2_unit" sql-type="varchar"/>
        </property>

        <property name="shortDescription">
            <column name="sdesc_unit" sql-type="varchar"/>
        </property>

        <property name="city">
            <column name="city" sql-type="varchar"/>
        </property>
       
        <property name="active">
            <column name="active_unit" sql-type="bit(1)"/>
        </property>

        <property name="inactiveDate">
            <column name="inactive_date" />
        </property>
       

<!-- temp. 2b replaced by other unit
        <property name="code_unit_secr">
            <column name="code_unit_secr" sql-type="int"/>
        </property>
-->       
       
<many-to-one name="node" class="gr.ges.ddb.bus.domain.Node" column="code_node" outer-join="true"/>
       
<many-to-one name="secretaryUnit" class="gr.ges.ddb.bus.domain.Unit" column="code_unit_secr"/>

<many-to-one name="adminUnit" class="gr.ges.ddb.bus.domain.Unit" column="code_unit_admin"/>


    </class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject: Upgrade to Hibernate 3.1 - check your Spring contexts
PostPosted: Tue Dec 20, 2005 6:26 pm 
Newbie

Joined: Thu Jun 16, 2005 6:44 pm
Posts: 6
Location: Salt Lake City, UT
The problem is likely due to the fact that EHCache uses a singleton CacheManager and that Hibernate's EhCacheProvider calls shutDown() on this singleton when a SessionFactory is being built. If you have two SessionFactories, then the building of one of them may be causing the errors in the other one. The SessionFactories will be sharing the same instance of CacheManager due to it being a singleton.

When you upgrade to Hibernate 3.1, you will get their new implementation of EhCacheProvider that keeps a static count of how many times EhCacheProvider.start() has been called. It decrements this count when EhCacheProvider.stop() is called, and then only calls CacheManager.shutDown() if the count has returned to 0.

Also possible is that you are using Spring's EhCacheManagerFactoryBean to use EHCache in other places in your application. If a Spring context is stopped then the EhCacheManagerFactoryBean.destroy() method will also call CacheManager.shutdown(), leaving it in a not-alive state for other users.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.