我们必须在一个耳朵项目中使用websphere扩展在2个不同的Web模块中使用相同的会话。如何从其他Web模块中的一个Web模块获取会话。我们正在使用IBM RAD 7.5,WebSphere 7.0,JSP Frame工作。
到现在为止我们已经尝试了这个approch
共同会话的共同项目 EAR项目 网络项目1 网络项目2
java.lang.ClassCastException:common.session.Sess与common.session.Sess不兼容
答案 0 :(得分:0)
尝试将EAR类加载器策略更改为APPLICATION并使用Singleton模式,或者您可以使用DistributedMap(http://www-01.ibm.com/support/knowledgecenter/SSEQTP_7.0.0/com.ibm.websphere.javadoc.doc/web/apidocs/com/ibm/websphere/cache/DistributedMap.html?lang=en),它特定于WebSphere,但可以为对象存储和检索提供非常强大的类似Map的接口。 / p>
答案 1 :(得分:0)
看一下这个页面 - Assembling so that session data can be shared,它描述了允许应用程序之间进行会话共享所需的所有步骤和配置。一般来说,你需要:
在应用程序中检索会话对象
HttpSession session = request.getSession();
将此对象转换为IBMSession对象并调用getIBMApplicationSession方法。
IBMApplicationSession appSession =((IBMSession)session).getIBMApplicationSession();
像普通会话对象一样使用appSession。
配置应用程序以使用共享会话扩展 - 使用以下属性创建ibm-application-ext.xml
<?xml version="1.0" encoding="UTF-8"?>
<application-ext xmlns="http://websphere.ibm.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-application-ext_1_1.xsd" version="1.1">
<shared-session-context value="true"/>
</application-ext>