7 Replies Latest reply on Nov 13, 2007 11:37 PM by meyerschalk

    UserModule via JNDI

    agathon

      Hello all,

      Since my client is unsatisfied with the current registration/user management features that are bundled with JBoss Portal (i.e. the UserPortlet), I have been attempting to implement my own using JSF, and Spring. What I'm trying to do is grab the UserModule using JNDI. The JNDI lookup goes well, but calling any of the UserModule's methods throws a ModuleExcepton. Any help would be greatly appreciated! Thanks!

      Sincerely,
      James

      JBoss Version: 4.0.3SP1
      JBoss Portal Version: 2.2.1

      Stacktrace:
      org.jboss.portal.core.modules.ModuleException: Cannot find user by name test
      at org.jboss.portal.core.impl.user.UserModuleImpl.findUserByUserName(UserModuleImpl.java:131)
      at chn.portal.core.service.impl.JBossUserServiceImpl.findUserByEmail(JBossUserServiceImpl.java:94)
      ... 37 more
      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:604)
      at org.jboss.portal.core.impl.user.UserModuleImpl.getCurrentSession(UserModuleImpl.java:372)
      at org.jboss.portal.core.impl.user.UserModuleImpl.findUserByUserName(UserModuleImpl.java:116)
      ... 38 more

        • 1. Re: UserModule via JNDI
          agathon

          I was able to resolve this issue. The solution is to create a "jboss-portlet.xml" file and inject the relevant services into the portlet context.

          • 2. Re: UserModule via JNDI
            thanvi

            Hi

            I am tryign to connect to UserModule using the JNDI anme /portal/UserModule. Its throwing the excpetion.

            I need to connect to userModule from my plain java class. How to go about it.

            I have tried the followig
            UserModule mod = (UserModule) new InitialContext().lookup("java:/portal/UserModule");

            It gives the following error

            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.getUserCount(UserModuleImpl.java:304)
            at com.reuters.lipper.dwr.UserDAO.countUsers(UserDAO.java:49)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:324)
            at uk.ltd.getahead.dwr.impl.ExecuteQuery.execute(ExecuteQuery.java:239)
            at uk.ltd.getahead.dwr.impl.DefaultExecProcessor.handle(DefaultExecProcessor.java:48)
            at uk.ltd.getahead.dwr.impl.DefaultProcessor.handle(DefaultProcessor.java:81)

            • 3. Re: UserModule via JNDI
              theute

              There are a couple of Forum topics about this.

              • 4. Re: UserModule via JNDI
                thanvi

                Is there a solution for this. I have beentryingto find in the forums

                • 5. Re: UserModule via JNDI
                  theute

                  Yes.

                  You need to open a JTA connection (or reuse one that is already open) before you do the call.

                  UserTransaction ut = (UserTransaction)(initCtx.lookup("java:comp/UserTransaction"));
                  ut.begin();
                  


                  Would open one.

                  • 6. Re: UserModule via JNDI
                    thanvi

                    Thanks a lot

                    It worked.

                    • 7. Re: UserModule via JNDI
                      meyerschalk

                      I have the same problem when I access the usermodule through DWR,

                      Let me know if you get any information on this please