Salem's Euphoria

Sharing Experience

Leave a comment

Detected duplicate HTTP-based FlexSessions… so what?

Apache Flex

This annoying particular problem is quite easy to solve in most cases. What makes it complicated sometimes, is either the misleading message tail:

generally due to the remote host disabling session cookies. Session cookies must be enabled to manage the client connection correctly.

which will guide you to a wrong road generally, either the initial concurrent calls to BlazeDs Server associating two different flex ID with the same JEE session.

  • Identifying the root cause

    • Install flash player debugger version on your Firefox
    • Enable BlazeDs debug traces

<target class="flex.messaging.log.ConsoleTarget" level="DEBUG">

    • Enable log4j debug traces
    • Identify Flex remote object calls


  • Must-know before troubleshooting

  1. Flex Session is different from JEE session (JSEESSIONID)
  2. You don’t have to disable duplicate session check in BlazeDs, that’s why I won’t tell you how to do it.
  3. Each Endpoint is associated with a distinct flex client; So if you are using two endpoints for example you have two flex client at the same time created on first method call.
  • Flex Session mechanism

  1. On the first call for JEE server, the Flex application has a null Session ID.
  2. When BlazeDs receives a call from a session with a null ID, it generates a new Flex session ID and binds it with the current Java server session.
  3. The SWF holds this id for the relative Endpoint and assign it on every call to that endpoint.
  • The problem

Somehow, BlazeDS received two calls from the SWF with null ID, “at the same time”, so he creates and ID for the first call and another one for the second call. Those IDs are binded to the active Java session.

On the next remote object call, BlaseDS will check the Flex session associated with this Java session and will detect that two different flex session IDs are associated with the same Java session… and throw the famous “Detectd duplicate HTTP-based FlexSessions”, but that’s not due to host disabling session cookies.

  • How to solve the issue

  1. Load you application inside a JSP: Instead of calling your HTML main project page, let’s say it FlexProject.html, load your page inside a JSP page FlexProject.jsp

<%@ include file="FlexProject.html" %>

If that won’t help, you may consider Lin’s blog from adobe team. There’s also an in depth explanation of the issue in Alex Glosband blog.


Leave a comment

Spring Flex3 Quick Integration


Eclipse 3.3 (Europa) + WTP plugin
Flex Builder 3 Plugin Installed on Eclipse
MySql Server
Apache Tomcat 6

Step By Step:

1) Create New Dynamic Web Application:

2) Right click on the new created application, go to Flex Project Nature > Add Flex Project Nature

It's not really LiveCycle Data Cycle, rather BlazeDs

Choose the J2EE Application server Type. Then check the “use remote object access service” and keep LCDS selected. It’s not really LCDS, but its Open Source version (BlazeDs).

3) Click Next, Browse, Navigate to the blazeds.war:

then click Finish.

4) In the problem’s view, you may see this error:
the solution is quite there 😉

5) Go to project properties > Flex Server > Context Root and change  the “/WebContent” to “/[YourProjectName]”

6) Go to the WebContent/WEB-INF, add a directory(config) and create an xml file (webApplicationContext.xml)

7)  a- Add the datasource bean to your configuration file:

b- Then the sessionFactory one:

c- the most important part in the integration is the servelet mapping, and you can do it as described here:

8)  Then go the web.xml file and put the current configuration:

Keep in mind the /slmDem/* url template. we’ll need it later.

9) Now, unzip the spring integration with dependencies files and copy all the jars into your lib directory. You’ll find some double version jars, so just choose the newest.

10)  Add a java entity to your src dir. In this project, we start with a small sample class “Document”:
domain model for document database entity and then create a database table called Document with three fields (id:Integer,type:varchar(20), title:varchar(50));

11) Create the DTO class that extends the HibernateDaoSupport. Here is my DTO:

That’s all with Spring and hibernate code. we need just to add those entities to our configuration file:
add the annotated class to your session factory:

Click to enlarge
and  then declare and expose your  service (DTO) to the flex consumers:

12)Now move to the Flex part and create the corresponding AS3(ActionScript 3) entity to your Java ‘Document’ class.
Note the meta-tag RemoteClass that describes the corresponding class on the Java side. It’s crucial to keep the same names of attributes, but don’t care that much about the scope (private/public/…) of the AS class attribute.

13) Create a simple form with WISYWIG designer of FlexBuilder with 3 fields (id,type,title) and a button to insert a “Document”.

and then declare the mx:RemoteObject and some code for insert operation:

14) Go to WebContent\WEB-INF\flex and open the services-config.xml. You still remember the /slmDemo/pattern. We need it here to correctly route our request:

you need to add a default channel to you services-config.xml file for general use.
15) One final Step. You don’t need your application to be re loadable, but for some reason, leaving it re loadable by default give me some perm-gen space errors.  So, run your project as >run on server. Choose the tomcat 6 server and then click finish. Stop your application and go to a second project in your workspace called Servers. Open the server.xml file  of this application, and scroll to the last line; Change the reloadable property to false:
Your project hierarchy should look like :
This is the result:
Send Me an email to ( with the title of the post as subject to get source code.