Session不是mobilefirst服务器/ websphere应用程序服务器中的适配器和java类(servlet)之间的持久性 [英] Session is not persistence between adapter and java class (servlet) in mobilefirst server/websphere application server

查看:172
本文介绍了Session不是mobilefirst服务器/ websphere应用程序服务器中的适配器和java类(servlet)之间的持久性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发部署在websphere应用服务器上的mobilefirst 7.1应用程序 - 网络部署。早期版本此应用程序正在使用worklight 6.1,一切正常。

I am working on mobilefirst 7.1 application which is deployed on websphere application server - network deployment.Earlier version this application is working on worklight 6.1 and everything is working fine.

根据代码,我们在适配器中的会话中设置一个属性,并尝试从java类(servlet)访问它,该类是应用程序的一部分,并使用web.xml文件中的配置公开为servlet。

As per code, we are setting an attribute in session within adapter and try to access it from java class (servlet) which is part of the application and exposed as servlet using configuration in web.xml file.

我的worklight属性配置:

My worklight properties configuration :

mfp.session.independent=false
mfp.attrStore.type=HttpSession

我的适配器代码:

function myProcedure(XXX){
     WL.Server.getClientRequest().getSession().setAttribute("myAtrrib", XXX);
     return { result :"Success"};
}

Java Servlet代码:

Java Servlet Code :

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      String crdAcc = (String) request.getSession(true).getAttribute("myAtrrib");
}

所以这里的问题是当我尝试访问此属性时它给了我

So Problem here is when I try to access this attribute it giving me null.

当我查看会话详细信息时,我发现该会话是新会话。

As I check the session detail and I found is that session is new session.

我不知道知道为什么服务器正在为这个servlet调用创建新的会话,而不是使用mobilefirst适配器使用的相同的会话。类似的代码正在使用worklight 6.1。

I don't know why server is creating new session for this servlet call instead of using same one which is used by mobilefirst adapter. Similar code is working with worklight 6.1.

推荐答案

在之前的一个问题中,你提到过你在群集中,所以可以是在您的服务器和/或负载均衡器中,您没有启用粘性会话配置?这可能解释了新连接的发生和价值不可用。

In a previous question you've mentioned you're on a cluster, so could it be that in your server and/or load balancer, you did not enable the sticky session configuration? This may explain "new connections" happening and values not available.

这篇关于Session不是mobilefirst服务器/ websphere应用程序服务器中的适配器和java类(servlet)之间的持久性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆