package com.cmbj.soa.servicemonitor.view.service.impl;

import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession; import flex.messaging.HttpFlexSession;
import flex.messaging.MessageBrokerServlet; public class KMessageBrokerServlet extends MessageBrokerServlet {
@Override
public void service(HttpServletRequest req, HttpServletResponse res) {
HttpSession httpSession = req.getSession(true);
HttpFlexSession flexSession = (HttpFlexSession)httpSession.getAttribute("__flexSession");
if( flexSession != null && !flexSession.isValid()){
httpSession.removeAttribute("__flexSession");
}
// HttpSession httpSession = req.getSession(true);
//
// Enumeration<String> names = httpSession.getAttributeNames();
// String name = null;
// for (; names.hasMoreElements();) {
// name = names.nextElement();
// if (httpSession.getAttribute(name) instanceof HttpFlexSession) {
// HttpFlexSession flexSession = (HttpFlexSession) httpSession.getAttribute(name);
// if(null != flexSession && !flexSession.isValid()){
// httpSession.setAttribute(name,null);
// httpSession.removeAttribute(name);
// }
// System.out.println("HttpFlexSession_name is " + name);
// }
// }
super.service(req, res);
}
}

重写MessageBrokerServlet的service方法,因为异常的源头来自该servlet用了一个invalid的HttpFlexSession去获取Principal,所以只要再service方法之前先判断下当前的HttpFlexSession是否已经无效,无效的话我们就从当前的HttpSession中移除这个无效的HttpFlexSession即可。这样,就能保证MessageBrokerServlet中所用的HttpFlexSession一定是有效的

The FlexSession is invalid问题的更多相关文章

  1. js报错: Uncaught RangeError: Invalid string length

    在ajax请求后得到的json数据,遍历的时候chrome控制台报这个错误:Uncaught RangeError: Invalid string length,在stackoverflow查找答案时 ...

  2. PhpStorm和WAMP配置调试参数,问题描述Error. Interpreter is not specified or invalid. Press “Fix” to edit your project configuration.

    PhpStorm和WAMP配置调试参数 问题描述: Error. Interpreter is not specified or invalid. Press “Fix” to edit your p ...

  3. org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

    org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): da.huying.usermanag ...

  4. 【解决方案】cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'. One of '{"http://java.sun.com/xml/ns/javaee":run-as, "http://java.sun.com/xml/ns/javaee":security-role-r

    [JAVA错误] cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'. One o ...

  5. ABP Zero示例项目登录报错“Empty or invalid anti forgery header token.”问题解决

    ABP Zero项目,登录时出现如图"Empty or invalid anti forgery header token."错误提示的解决方法: 在 WebModule.cs的P ...

  6. Android之RecyclerView的原生Bug-Inconsistency detected. Invalid view holder adapter positionViewHolder{a1bbfa3 position=2 id=-1, oldPos=-1, pLpos:-1 no parent}

    今天在运行自己编写的App时,突然发现App在运行时闪退,然后就查看了Android Studio的Log,发现了这个错误,上网查了一下,才知道是RecyclerView的原生Bug,在数据更新时会出 ...

  7. {"errcode":40097,"errmsg":"invalid args hint: [vjNe7xxxxxx8vr19]"}——记录一次微信错误处理

    错误情况概述: 启动应用之后,微信调用 相机拍照 等接口是可以正常使用的, 但是过了一段时间(2个小时左右--token/jsapi_ticket的过期时间),微信调用相机拍照的功能失效,启用debu ...

  8. [LeetCode] Remove Invalid Parentheses 移除非法括号

    Remove the minimum number of invalid parentheses in order to make the input string valid. Return all ...

  9. Apache报错信息之Invalid command 'Order', perhaps misspelled or defined by a module not included in the server config

    今天配置开启Apache虚拟主机时, 然后日志报错提示: Invalid command 'Order', perhaps misspelled or defined by a module not ...

随机推荐

  1. Android Camera调用过程分析

    源代码版本:allwinner 4.0.4 frameworks代码: frameworks/base/core/java/android/hardware/Camera.java JNI层代码: f ...

  2. 邀请朋友富途开户赢iPhone6的史上最强攻略

    最近有关沪港通的消息很多,加上阿里巴巴马上IPO,所以上个月我在朋友推荐下,来富途开了个户.本来对邀请不太感兴趣,但这次的奖品实在诱人,因为超级想要iPhone6,所以也加入了邀请大队.到发贴的时候, ...

  3. Codeforces Round #316 (Div. 2B) 570B Simple Game 贪心

    题目:Click here #include <bits/stdc++.h> using namespace std; typedef long long ll; const int IN ...

  4. ARM异常---一个DataAbort的触发过程:

    一个DataAbort异常的触发过程://////////////////////////////xxxx.inc_STACK_BASEADDRESS EQU 0x33ff8000_MMUTT_STA ...

  5. CSS Filter

    支持的效果有: blur(模糊) grayscale(灰度) drop-shadow(阴影) sepia(褐色滤镜) brightness(亮度) contrast(对比) hue-rotate(色相 ...

  6. Calling 64-bit assembly language functions lodged inside the Delphi source code

    Code: http://www.atelierweb.com/calling-64-bit-assembly-language-functions-lodged-inside-the-delphi- ...

  7. zabbix 添加主机成功失败判断

    zabbix 成功添加后: $VAR1 = bless( { 'version' => 0, 'content' => { 'jsonrpc' => '2.0', 'id' => ...

  8. SilkTest天龙八部系列5-类的属性

    SilkTest的面向对象机制让用户可以为类定义属性,用property语句实现.除此以外用户在类中还可以定义成员变量和不可变的setting属性.也就是是说Silktest类中可以有以下三种属性/变 ...

  9. MapReduce调度与执行原理之任务调度(续)

    前言 :本文旨在理清在Hadoop中一个MapReduce作业(Job)在提交到框架后的整个生命周期过程,权作总结和日后参考,如有问题,请不吝赐教.本文不涉及Hadoop的架构设计,如有兴趣请参考相关 ...

  10. 网页制作之JavaScript部分3--事件及事件传输方式(函数调用 练习题 )重要---持续更新中

    一. 事件:说白了就是调用函数的一种方式.它包括:事件源.事件数据.事件处理程序. JS事件 1.js事件通常和函数结合来使用,这样可以通过发生的事件来驱动函数的执行,从而引起html出现不同的效果. ...