6 Replies Latest reply on Nov 13, 2006 4:43 AM by rashmi_setty

    Calling UserModule service

      Hi
      We are using JBOSS Portal 2.4 GA
      we have requirement where registration should be done in Simple JSF application and not using Portlet.
      So we devleoped JSF application in which i am calling userModule as shown below

      String userModuleJNDIName = "java:/portal/UserModule";
       UserModule userModule = (UserModule)(new InitialContext()).lookup(userModuleJNDIName);
       User user = userModule.createUser(subID, userBean.getPwd(), "user@portal.com");

      I deployed the this JSF application war file in same Jboss Portal server.
      I am getting userModule but while creating the user it throwing exception as
      Caused by: org.hibernate.HibernateException: Unable to locate current JTA transaction
       at org.hibernate.context.JTASessionContext.currentSession(JTASessionContext.java:61)
      at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:541)
       at org.jboss.portal.identity.db.UserModuleImpl.getCurrentSession(UserModuleImpl.java:327)
       at org.jboss.portal.identity.db.UserModuleImpl.createUser(UserModuleImpl.java:212)


      Is this the corrct way to call userModule.Should i set some parameter in xml file

      Please help
      Thanx

        • 1. Re: Calling UserModule service
          theute

          You need to have a JTA transaction open before you call the method "createUser" on the UserModule if you are using the database implementation of the user module.



          • 2. Re: Calling UserModule service

            Can u tell me how to open JTA transaction.

            Thanks in advance

            • 3. Re: Calling UserModule service
              bdaw

              in jboss-portlet.xml

              <portlet-app>

              <portlet-name>Name</portlet-name>

              <trans-attribute>Required</trans-attribute>

              .....

              • 4. Re: Calling UserModule service

                As i have metioned it is not portal application.It is just simple JSF application.I am not using Portlet.
                Can anybody tell me how to open JTA transaction before calling UserModule

                • 5. Re: Calling UserModule service

                   

                  TransactionManager tm;
                   try {
                   tm = (TransactionManager)new InitialContext().lookup("java:/TransactionManager");
                   TypeX x = (TypeX)Transactions.required(tm, new Transactions.Runnable()
                   {
                   public Object run() throws Exception
                   { ....return something in TypeX


                  look in the UserPortlet Code or in the IdentityLoginModule Code how they use UserModule services.

                  regards,



                  • 6. Re: Calling UserModule service

                    hi cpage,
                    Thx for your reply.
                    Actually can i open JTA Transaction as shown below.This code is working fine now.But i dont know whether i can call this way though i am getting result.


                    UserTransaction ut = (UserTransaction)(initCtx.lookup("java:comp/UserTransaction"));
                     ut.begin();
                     user = userModule.createUser(subID, userBean.getPwd(), "user@portal.com");


                    regards,