0 Replies Latest reply on Mar 15, 2014 10:22 AM by Michael Kucinski

    Netbeans /GlassFish 4 Discussion

    Michael Kucinski Newbie

      Hello everybody!

       

      I'm hoping that all of the GlassFish users of the forum can collaborate to get PicketLink up and running 100%.

       

      The problem is transaction related. When the partition is initialized, PicketLink uses the entity manager that is produced by the user to add the default realm. During this time, the transaction is not yet active. Therefore, a TransactionRequiredException is thrown.

       

      Some attempts have been made to begin and commit a user transaction during the PartitionManagerCreateEvent with mixed results.

       

      I have been able to get PicketLink to launch under GlassFish in a work related project but it is not fully functional. It bootstraps successfully and adds all the users and groups in a @Singleton @Startup bean. I can login, check permissions, and all of those wonderful things. The issue comes when trying to add users after startup. The very same transaction required exception that causes others PicketLink GlassFish projects to fail is thrown when adding users using the IdentityManager. I've tried using a UserTransaction to begin and commit before and after the call to the IdentityManager. This seems to work occasionally; sometimes the UserTransaction is active, and other times is it is not. I cannot explained why that project works. The only difference is that it is an EAR project.

       

      I wish I could share the entire source code for that project because it works better than any other attempt I have made. However, it is for work, so I cannot. I have copied the startup code into a separate project (which doesn't work, for some unexplainable reason) and I've included the link in this thread. Please excuse the somewhat messy code. It's very experimental.

       

      Here are the things that I have attempted so far that have not worked:

       

      1) Adding a UserTransaction begin/commit around all PicketLink calls which may utilize the entityManager.

       

      2) Adding the annotation @TransactionAttribute(REQUIRED) around the methods which may call the EntityManager. This annotation is suppose to ensure that there is transaction upon invocation. If there is not one, a new one will be created by the container.

       

      3) Using a non-container managed transaction type. For the producer method, I would return EntityManagerFactory.createEntityManager(). However, when PicketLink looks for an instance, the EntityManagerFactory is still closed.

       

      Here is the link to the original issue

      Here is the link to my source.

      Here is a link to the suggested PartitionInitializer fix.

       

      I hope we can get this fixed soon!

       

      Relevant reading:

       

      Attempting to execute an operation on a closed EntityManagerFactory, GlassFish error

      Container-Managed Transactions Tutorial


      EDIT: For some reason, the very same build that was giving me problems yesterday is now working. The source is on github, maybe somebody else can try it out to confirm.

      Screen Shot 2014-03-15 at 10.19.27 AM.png