Problema com Sessao no Flex [RESOLVIDO]

7 respostas
V

Galera,

Estou com o seguinte problema quando vou logar na minha aplicação.
Eu logo a primeira vez blza, depois vou logar de novo esta dando o seguinte erro:

faultCode:Server.Processing faultString:'java.lang.IllegalStateException : getAttribute: Session already invalidated' faultDetail:'null'

e no log do tomcat esta assim:
31/07/2011 23:00:00 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
GRAVE: The web application [/cescontrole] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@fc7ceb]) and a value of type [flex.messaging.client.FlexClient] (value [flex.messaging.client.FlexClient@f02db7]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

Estou usando o tomcat 7.

Nunca havia deparado com esse erro.

Att

7 Respostas

V

Alguem?

V

Agora apareceu esse outro erro:

faultString:'flex.messaging.LocalizedException : The FlexSession is invalid.' faultDetail:'null'

Alguem pelo amor de Deus sabe o que pode estar dando errado?

Ja fiz de tudo que achei nos forums e nada.

abaixo os meus codigos que estou usando

package br.com.ces.util;


import java.util.List;

import flex.messaging.FlexContext;
import flex.messaging.FlexSession;
import flex.messaging.client.FlexClient;


public class FlexContextUtil {
	private static FlexSession flexSession;
	static{
		flexSession= FlexContext.getFlexSession();
	}
	
	
	public static void setNomeUsuario(String nomeUsuario){
		List<FlexClient>	lista = flexSession.getFlexClients();
		//flexSession.maxConnectionsPerSession();
		if (flexSession.getAttribute("usuarioLogado") == null) {
			flexSession.setAttribute("usuarioLogado", nomeUsuario);
		}
		
		lista = flexSession.getFlexClients();
	
	}
	
	public static String getNomeUsuario(){
		return flexSession.getAttribute("usuarioLogado").toString();
	}
	
	public static void setCodUsuario(Integer codUsuario){
		if (flexSession.getAttribute("codUsuarioLogado") == null) {
			flexSession.setAttribute("codUsuarioLogado", Integer.toString(codUsuario));
		}
	}
	
	public static Integer getCodUsuario(){
		String cod = flexSession.getAttribute("codUsuarioLogado").toString(); 
		return new Integer(cod);
	}
	
}


<?xml version="1.0" encoding="UTF-8"?>
<service id="remoting-service" 
    class="flex.messaging.services.RemotingService">

    <adapters>
        <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/>
    </adapters>

    <default-channels>
        <channel ref="my-amf"/>
    </default-channels>
	<destination id="telemetriaServico">
		<properties>
			<source>br.com.ces.servico.TelemetriaServico</source>
		</properties>
	</destination>
	<destination id="clienteServico">
		<properties>
			<source>br.com.ces.servico.ClienteServico</source>
		</properties>
	</destination>
	<destination id="veiculoServico">
		<properties>
			<source>br.com.ces.servico.VeiculoServico</source>
		</properties>
	</destination>
	<destination id="validaUsuarioServico" channels="my-amf">
		<properties>
			<source>br.com.ces.servico.ValidaUsuarioServico</source>
		</properties>
		<adapter ref="java-object"/>
	</destination>
	
</service>

<?xml version="1.0" encoding="UTF-8"?>
<services-config>

    <services>
        <service-include file-path="remoting-config.xml" />
        <service-include file-path="proxy-config.xml" />
        <service-include file-path="messaging-config.xml" />        
    </services>

    <security auto-config="true" session-fixation-protection="none">
        <login-command class="flex.messaging.security.TomcatLoginCommand" server="Tomcat"/>
        <!-- Uncomment the correct app server
        <login-command class="flex.messaging.security.TomcatLoginCommand" server="JBoss">
		<login-command class="flex.messaging.security.JRunLoginCommand" server="JRun"/>        
        <login-command class="flex.messaging.security.WeblogicLoginCommand" server="Weblogic"/>
        <login-command class="flex.messaging.security.WebSphereLoginCommand" server="WebSphere"/>
        -->

        <!-- 
        <security-constraint id="basic-read-access">
            <auth-method>Basic</auth-method>
            <roles>
                <role>guests</role>
                <role>accountants</role>
                <role>employees</role>
                <role>managers</role>
            </roles>
        </security-constraint>
         -->
    </security>
    <channels>
		<!-- 186.194.0.158 -->
		<!-- 
        <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
            <endpoint url="http://186.194.0.158:8080/cescontrole/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
        </channel-definition>

        <channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel">
            <endpoint url="https://186.194.0.158:8080/cescontrole/messagebroker/amfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/>
            <properties>
                <add-no-cache-headers>false</add-no-cache-headers>
            </properties>
        </channel-definition>

        <channel-definition id="my-polling-amf" class="mx.messaging.channels.AMFChannel">
            <endpoint url="http://186.194.0.158:8080/cescontrole/messagebroker/amfpolling" class="flex.messaging.endpoints.AMFEndpoint"/>
            <properties>
                <polling-enabled>true</polling-enabled>
                <polling-interval-seconds>4</polling-interval-seconds>
            </properties>
        </channel-definition>
	    -->
	  
		<!-- Local host -->
	    
        <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
            <endpoint url="http://localhost:8084/cescontrole/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
        </channel-definition>

        <channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel">
            <endpoint url="https://localhost:8084/cescontrole/messagebroker/amfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/>
            <properties>
                <add-no-cache-headers>false</add-no-cache-headers>
            </properties>
        </channel-definition>

        <channel-definition id="my-polling-amf" class="mx.messaging.channels.AMFChannel">
            <endpoint url="http://localhost:8084/cescontrole/messagebroker/amfpolling" class="flex.messaging.endpoints.AMFEndpoint"/>
            <properties>
                <polling-enabled>true</polling-enabled>
                <polling-interval-seconds>4</polling-interval-seconds>
            </properties>
        </channel-definition>
        
        <!--
        <channel-definition id="my-http" class="mx.messaging.channels.HTTPChannel">
            <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/http" class="flex.messaging.endpoints.HTTPEndpoint"/>
        </channel-definition>

        <channel-definition id="my-secure-http" class="mx.messaging.channels.SecureHTTPChannel">
            <endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/httpsecure" class="flex.messaging.endpoints.SecureHTTPEndpoint"/>
            <properties>
                <add-no-cache-headers>false</add-no-cache-headers>
            </properties>
        </channel-definition>
        -->
    </channels>

    <logging>
        <target class="flex.messaging.log.ConsoleTarget" level="Error">
            <properties>
                <prefix>[BlazeDS] </prefix>
                <includeDate>false</includeDate>
                <includeTime>false</includeTime>
                <includeLevel>false</includeLevel>
                <includeCategory>false</includeCategory>
            </properties>
            <filters>
                <pattern>Endpoint.*</pattern>
                <pattern>Service.*</pattern>
                <pattern>Configuration</pattern>
            </filters>
        </target>
    </logging>

    <system>
        <redeploy>
            <enabled>false</enabled>
            <!-- 
            <watch-interval>20</watch-interval>
            <watch-file>{context.root}/WEB-INF/flex/services-config.xml</watch-file>
            <watch-file>{context.root}/WEB-INF/flex/proxy-config.xml</watch-file>
            <watch-file>{context.root}/WEB-INF/flex/remoting-config.xml</watch-file>
            <watch-file>{context.root}/WEB-INF/flex/messaging-config.xml</watch-file>
            <watch-file>{context.root}/WEB-INF/flex/data-management-config.xml</watch-file>
            <touch-file>{context.root}/WEB-INF/web.xml</touch-file>
             -->
        </redeploy>
    </system>

</services-config>
F

Cara de lixo acumulado no tomcat, pode tentar olhar o web.xml que seta o timeout da sessao.

V

Entao cara, tentei do jeito que vc falou e falhou.

deu o seguinte erro:

faultCode:Server.Processing faultString:'flex.messaging.LocalizedException : The FlexSession is invalid.' faultDetail:'null'
X
private static FlexSession flexSession;  
    static{  
        flexSession= FlexContext.getFlexSession();  
    }

Acredito que por ser static, você deve estar tentando fazer operações em uma session que já foi invalidada pelo flex(BlazeDS). Tente não usar static pra isso, use um hashmap para manter as sessões.

V

De tando que isso me deixou preocupado estava pensando nessa hipótese mesmo. Esse trecho de codigo de sessao do flex eu peguei na net, pq esse é o meu primeiro projeto flex.
Vou ver se é isso mesmo.

Att

V

Resolvi o problema da sessao, mandei ela para a casa do caixa prego.
Deixei o tomcat resolver isso para mim.

Att

Criado 31 de julho de 2011
Ultima resposta 6 de ago. de 2011
Respostas 7
Participantes 3