tomcat apache2 memcached struts2 spring2.5 hibernate3.0 集群问题

梁吉超 发布于 2012/02/03 08:59
阅读 1K+
收藏 1

首页我用的是session共享来集群的

ROOT.xml配置文件:

用来session共享配置

<Context path="ROOT" reloadable="false" docBase="#####">
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
    memcachedNodes="n1:192.168.0.181:11211 n2:192.168.0.19:11211"
    requestUriIgnorePattern=".*\.(png|gif|jpg|css|js)$"
    sessionBackupAsync="false"
    sessionBackupTimeout="100"
    transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"
    copyCollectionsForSerialization="false"
    />
</Context>

我测试登陆两个tomcat没有问题,确实session用的是一个.

这是tomcat的控制台提示:

我用apache2的ab -n 1000 -c 200 http://192.168.0.181/ 口令测试的出现下面的提示

2012-2-3 8:47:21 de.javakaffee.web.msm.BackupSessionTask storeSessionInMemcached
信息: Could not store session 1ED781BBB8D245020C8E7C21AAC251F3-n2.jvm1 in memcached.
2012-2-3 8:47:21 de.javakaffee.web.msm.BackupSessionTask doBackupSession
信息: Could not store session 1ED781BBB8D245020C8E7C21AAC251F3-n2.jvm1 in memcached due to unavailable node n2.
2012-2-3 8:47:25 de.javakaffee.web.msm.BackupSessionTask storeSessionInMemcached
信息: Could not store session FE5F3098C4E9EE02F79B2F12064E3681-n1.jvm1 in memcached.
2012-2-3 8:47:25 de.javakaffee.web.msm.BackupSessionTask doBackupSession
信息: Could not store session FE5F3098C4E9EE02F79B2F12064E3681-n1.jvm1 in memcached due to unavailable node n1.
2012-2-3 8:47:27 de.javakaffee.web.msm.BackupSessionTask storeSessionInMemcached
信息: Could not store session 0D26082EEE5BDC6FC5DB5E17B5C6FBF1-n1.jvm1 in memcached.
2012-2-3 8:47:27 de.javakaffee.web.msm.BackupSessionTask doBackupSession
信息: Could not store session 0D26082EEE5BDC6FC5DB5E17B5C6FBF1-n1.jvm1 in memcached due to unavailable node n1.
Note that this session was relocated to this node because the original node was not available.

这些提示出现之后用出现另一个问题就是:

2012-02-03 08:48:56,953 [org.hibernate.LazyInitializationException]-[ERROR] failed to lazily initialize a collection of role: com.ljc.member.po.Memb

erInfo.shopBases, no session or session was closed

 at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
 at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372)

 at org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:119)
 at org.hibernate.collection.PersistentSet.size(PersistentSet.java:162)
 at de.javakaffee.web.msm.serializer.javolution.ReflectionBinding$XMLCollectionFormat.write(ReflectionBinding.java:381)
 at de.javakaffee.web.msm.serializer.javolution.ReflectionBinding$XMLCollectionFormat.write(ReflectionBinding.java:335)
 at javolution.xml.XMLFormat$OutputElement.add(XMLFormat.java:819)
 at de.javakaffee.web.msm.serializer.javolution.ReflectionFormat.writeElements(ReflectionFormat.java:262)
 at de.javakaffee.web.msm.serializer.javolution.ReflectionFormat.write(ReflectionFormat.java:244)
 at javolution.xml.XMLFormat$OutputElement.add(XMLFormat.java:819)
 at de.javakaffee.web.msm.serializer.javolution.ReflectionBinding$XMLMapFormat.write(ReflectionBinding.java:439)
 at de.javakaffee.web.msm.serializer.javolution.ReflectionBinding$XMLMapFormat.write(ReflectionBinding.java:389)
 at javolution.xml.XMLFormat$OutputElement.add(XMLFormat.java:819)
 at javolution.xml.XMLObjectWriter.write(XMLObjectWriter.java:242)
 at de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoder.doSerialize(JavolutionTranscoder.java:125)
 at de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoder.serializeAttributes(JavolutionTranscoder.java:97)
 at de.javakaffee.web.msm.TranscoderService.serializeAttributes(TranscoderService.java:140)
 at de.javakaffee.web.msm.BackupSessionTask.serializeAttributes(BackupSessionTask.java:150)
 at de.javakaffee.web.msm.BackupSessionTask.call(BackupSessionTask.java:101)
 at de.javakaffee.web.msm.BackupSessionTask.call(BackupSessionTask.java:38)
 at de.javakaffee.web.msm.BackupSessionService$SynchronousExecutorService.submit(BackupSessionService.java:324)
 at de.javakaffee.web.msm.BackupSessionService.backupSession(BackupSessionService.java:195)
 at de.javakaffee.web.msm.MemcachedBackupSessionManager.backupSession(MemcachedBackupSessionManager.java:670)
 at de.javakaffee.web.msm.SessionTrackerValve.backupSession(SessionTrackerValve.java:157)
 at de.javakaffee.web.msm.SessionTrackerValve.invoke(SessionTrackerValve.java:92)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
 at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
 at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
 at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2185)
 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
 at java.lang.Thread.run(Thread.java:662)

这个是延迟加载session可能丢失,但是没有集群的情况下是没有这个情况的.

这是applicationContext.xml其中一个地方配置

<bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

 

<!-- 事务管理器 -->
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory">
            <ref local="sessionFactory" />

 

用hibernate 查询没有问题,但级联查询会session出现问题.

请大家指点一下.谢谢

加载中
0
苏珊大妈
苏珊大妈
这个问题你解决了没。。我也遇到了这个问题
返回顶部
顶部