Session is not persistence between adapter and java class (servlet) in mobilefirst server/websphere application server

断了今生、忘了曾经 提交于 2019-12-12 02:44:52

问题


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.

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.

My worklight properties configuration :

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

My adapter code :

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

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.

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.


回答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.



来源:https://stackoverflow.com/questions/40394870/session-is-not-persistence-between-adapter-and-java-class-servlet-in-mobilefir

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!