10 Replies Latest reply on Dec 18, 2006 5:07 AM by thanvi

    UserImpl not mapped

    pedrosacosta

      I'm trying to access jbp_users table from jboss Portal database, but i get the following error:

      org.hibernate.hql.ast.QuerySyntaxException: UserImpl is not mapped. [FROM UserImpl user WHERE 1 = 1 and userName = :userName]
      


      I putted a query string in my program to get a result.

      I've noticed that the mapping file that corresponds to jbp_users tables is

      D:\jboss\jboss-portal-2.2.0-src\core\src\resources\portal-core-sar\conf\hibernate\user\domain.hbm.xml

      and not UserImpl.hbm.xml.

      I putted portal-core-lib.jar in the classpath of my program.

      But still get the error.

      Any help?

      Thanks,
      Pedro

        • 1. Re: UserImpl not mapped
          pedrosacosta

          instead of putted is put. :D

          • 2. Re: UserImpl not mapped

            why don't use the UserModule ?

            • 3. Re: UserImpl not mapped
              pedrosacosta

              Thanks for the quick advice. Now it works.

              • 4. Re: UserImpl not mapped
                pedrosacosta

                No it doesn't work. :(

                1 - Can you put an example that works?

                2 - Should i start a service before doing findUserByUserName?

                UserModule mod = new UserModuleImpl();
                User user = mod.findUserByUserName(username);
                


                I'm asking this question because this snippet gives me the following error:

                java.lang.NullPointerException
                 at org.jboss.portal.core.impl.user.UserModuleImpl.getCurrentSession(UserModuleImpl.java:372)
                 at org.jboss.portal.core.impl.user.UserModuleImpl.findUserByUserName(UserModuleImpl.java:116)
                 at com.link.portal.dao.PortalDAOBean.getUserByUserName(PortalDAOBean.java:220)
                 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:585)
                 at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
                 at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
                 at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:154)
                 at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:106)
                


                And i saw that UserImpl as a protected method startservice.

                The mssql-ds.xml are well configurated.

                Thanks,
                Pedro



                • 5. Re: UserImpl not mapped
                  pedrosacosta

                  To solve this problem do this:

                  UserModule mod = (UserModule) new InitialContext().lookup("java:portal/UserModule");
                  


                  • 6. Re: UserImpl not mapped

                    i think you can inject the service in the portlet :

                    in jboss-portlet.xml:

                    <service>
                     <service-name>UserModule</service-name>
                     <service-class>org.jboss.portal.core.modules.UserModule</service-class>
                     <service-ref>:service=Module,type=User</service-ref>
                     </service>


                    and get the usermodule in the portlet :

                    userModule = (UserModule)getPortletContext().getAttribute("UserModule");




                    • 7. Re: UserImpl not mapped

                      yes this saves a JNDI lookup :-)

                      "cpage" wrote:
                      i think you can inject the service in the portlet :

                      in jboss-portlet.xml:
                      <service>
                       <service-name>UserModule</service-name>
                       <service-class>org.jboss.portal.core.modules.UserModule</service-class>
                       <service-ref>:service=Module,type=User</service-ref>
                       </service>


                      and get the usermodule in the portlet :

                      userModule = (UserModule)getPortletContext().getAttribute("UserModule");




                      • 8. Re: UserImpl not mapped
                        abuayyub

                        Hi,
                        You may know this already but as i have just hit it myself i thought i'd mention this anyway. make sure that you are using stateful session beans with the EntityManager for multiple calls to beans. the annotation should be something like this:

                        @PersistenceContext(unitName="myEjb", type=PersistenceContextType.EXTENDED).
                        The
                        QuerySyntaxException: myEjb not mapped
                        occurs because the injected persistence manager is closed once a stateless been is returned to the pool.

                        regards abuayyub

                        • 9. Re: UserImpl not mapped
                          requiem2460309

                           

                          "pedrosacosta" wrote:
                          instead of putted is put. :D


                          instead of using the name of table in query string you
                          must use the name of class being mapped


                          • 10. Re: UserImpl not mapped
                            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)