PrettyFaces, CDI and the case of the missing ?cid=xxx…

Splash Forums PrettyFaces Users PrettyFaces, CDI and the case of the missing ?cid=xxx…


This topic contains 43 replies, has 3 voices, and was last updated by  Christian Kaltepoth 9 years, 10 months ago.

Viewing 15 posts - 1 through 15 (of 44 total)
  • Author
  • #18149

    Tony Herstell


    I have seeing a particular problem with CDI conversations that I see using prettyfaces.

    The problem is explained:

    Initially on Primefaces Forum:

    and then on the Weld form

    The project is vanilla CDI and prettyfaces (actually extended out from the Jboss7 quickstart example code).

    I am happy to send the project if required as its in its infancy or give access to bitbucket repository.

    Thanks in advance for your input.

    Using: JBoss7 ( (CDI-Weld), Primefaces (3.0.1) and Prettyfaces (3.3.2)… and that’s about it so far!



    thank you very much for your post. Yes, I also saw some posts on the PrettyFaces forums regarding this. So there really seems to be something wrong here.

    It would be absolutely fantastic to get an example application that reproduces this behavior. Could you perhaps upload the project somewhere or send it to me via email (christian (at) kaltepoth [dot] de)? It would be great if you could include a small textual description of what exactly doesn’t work and what would be the correct behavior.

    Thank you very much



    Tony Herstell

    Hi Christian,

    Please email me a personal email for me to send you ‘stuff’.



    Tony Herstell

    Once you synch then the only thing you need to set up is the PU and the Database schema I guess.

    This is the simplest way of setting up the system with MySQL I have found and details the setup with MySQL and JBoss7:

    This is in the file persistence.xml under META-INF in the project…

    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="2.0"
    xmlns="" xmlns:xsi=""

    <!-- JBoss7 JBoss7 JBoss7 JBoss7 JBoss7 JBoss7 JBoss7 JBoss7 JBoss7 JBoss7 JBoss7 JBoss7 JBoss7 JBoss7
    Download MySQLConnector (was in my case)
    Add a new directory: modules/com/mysql/main
    put the MySQLConnector in the new directory: modules/com/mysql/main
    Create a new file in directory: modules/com/mysql/main called module.xml and add in this code:

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

    <module xmlns="urn:jboss:module:1.0" name="com.mysql">
    <resource-root path="mysql-connector-java-5.1.18-bin.jar"/>
    <module name="javax.api"/>

    Edit the file in the existing directory : /standalone/configuration called standalone.xml and add in this code inside the <drivers> tags:

    <driver name="mysql" module="com.mysql"/>

    now add in this code inside the <datasource> tags:

    <datasource jndi-name="java:/datasources/entermyeventsDatasource" pool-name="my_pool" enabled="true" jta="true" use-java-context="true" use-ccm="true">

    Run up server and look for something like:
    04:45:09,525 INFO [org.jboss.jpa] (MSC service thread 1-3) JBAS011402: Starting Persistence Unit Service 'entermyevents.war#entermyeventsDatasource'


    <persistence-unit name="entermyeventsDatasource">
    <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
    <property name="" value="update" /> <!-- create-drop update -->
    <property name="hibernate.show_sql" value="true" />
    <property name="hibernate.format_sql" value="true" />
    <!-- These are the default for JBoss EJB3, but not for HEM: -->
    <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider" />
    <property name="hibernate.transaction.manager_lookup_class"
    value="org.hibernate.transaction.JBossTransactionManagerLookup" />
    <property name=""
    value="java:/essistantEntityManagerFactories" />


    I guess you probably don’t need this but just want to ensure I provide as much info as possible…



    Tony Herstell

    Once you get the project and get it running.

    Go to “manage users” and then click [Done]

    You will get a stack trace as [Done] is trying to close a conversation that does not exist.

    04:53:21,799 INFO  [com.entermyevents.userManagement.UserManagementController] (http-- +++CONVERSATION END for conversation:null
    04:53:21,802 INFO [] (http-- JBAS014101: Failed to find {[0, 60, 48, -124, 1, -102, 72, 53, -100, -48, 98, 47, 55, -32, 14, -27]} in cache
    04:53:21,803 ERROR [org.jboss.ejb3.invocation] (http-- JBAS014134: EJB Invocation failed on component UserManagementController for method public java.lang.String com.entermyevents.userManagement.UserManagementController.finished(): javax.ejb.EJBException: org.jboss.weld.exceptions.IllegalStateException: WELD-000215 Attempt to call end() on a transient conversation
    at [jboss-as-ejb3-7.1.0.CR1b.jar:7.1.0.CR1b]

    You can see the Conversation was started in the logs.

    I can manually “fix” this by looking in the logs for the conversation starting

    04:49:51,576 INFO  [com.entermyevents.userManagement.UserManagementController] (http-- +++CONVERSATION START
    04:49:51,577 INFO [com.entermyevents.userManagement.UserManagementController] (http-- conversation:1

    and append onto the URL the test:


    and re-fresh the page.

    Now I can mess around on the page and all is well as the conversation is maintained… finally hitting [Done] will close the conversation without a stack trace.

    It seems that between CDI and PrettyFaces the initial


    is being stripped off.

    Hopefully it’s a simple fix to stop this being stripped.


    Tony Herstell

    There is a file (import.sql) in the classpath (/entermyevents/src/import.sql) that i use to pre-populate some data.

    This is not really important for this problem but if you do furkle about and try to add a new user you will find a problem in that the primary key has already been used up.

    This is a new “feature” of hibernate that didn’t used to happen in Seam 2 and is nothing to do with this problem.


    Tony Herstell


    Your email was in the original message.

    Tip: Don’t read emails at 0430!

    project on way…


    Dear Tony,

    thanks for sharing this detailed information for your project. I’ll have a look at it as soon as possible. I think I’ll find some time tomorrow. I’ll let you know if I find anything that may cause this issue.

    Best regards



    Hey Tony,

    I haven’t looked at your app, but one of the issues with the CID is that you need to manually add it for some types of JSF navigation.

    There is code in PrettyFaces which is specifically designed to make sure that the CID, and other parameters added to redirect URLs, are preserved, but it sounds like there is something wrong with this.

    @Christian, want help?



    Tony Herstell

    Hi Lincoln,

    It is passed round fine… As LONG is there to start with!

    If I land on a page with a conversation running then it simply is not added to the end of the URL to start with (or is stripped).

    I have a button mapped to an “init” method and I start the conversation in this method.. then I return via a PrettyFaces “rule”… I think this rule is not checking to see if there is a conversation for this page.

    What do you think.


    Tony Herstell

    To be very clear about this.

    The page has NOT been rendered before… the init method STARTS a conversation and then “launches” the very first render of the page.


    Hey Tony,

    I just want to keep you informed that I’m working on this. I can reproduce the issue you are describing. It really weird. The problem is that I don’t know how Weld adds the cid parameter to the URL. It seems like the HttpServletResponse is not wrapped, so it is reasonable that the cid is not added as this is typically one in such a wrapper.

    We are first calling ExternalContext.getResponse().encodeRedirectUrl() and then ExternalContext.redirect().



    IMHO this class in Weld should be responsible for appending the cid parameter:


    BTW: Mojarra only calls HttpServletResponse.sendRedirect() in case of non-AJAX requests. For AJAX requests it adds some script to the response that performs the redirect using JavaScript. In this case the Weld filter won’t work. But as I wrote before is seems like this filter isn’t active in AS7 as the response isn’t wrapped.

    This is very difficult to debug.


    Hey Christian,

    Take a look at the ExternalContextWrapperImpl that comes with JSF. I believe that is where teh CID is added. Either there or the NavigationHandlerImpl.

    I am trying to find time to look in to this issue :/ Hopefully later today.


Viewing 15 posts - 1 through 15 (of 44 total)

The forum ‘PrettyFaces Users’ is closed to new topics and replies.

Comments are closed.