4 Replies Latest reply: Oct 29, 2012 5:52 PM by YueZ-Oracle RSS

    com.liferay.portal.service.base.UserLocalServiceBaseImpl.addUser failed

    YueZ-Oracle
      com.liferay.portal.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
           at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.processException(BasePersistenceImpl.java:182)
           at com.liferay.portal.service.persistence.UserPersistenceImpl.updateImpl(UserPersistenceImpl.java:471)
           at com.liferay.portal.service.persistence.UserPersistenceImpl.updateImpl(UserPersistenceImpl.java:84)
           at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.update(BasePersistenceImpl.java:258)
           at com.liferay.portal.service.base.UserLocalServiceBaseImpl.addUser(UserLocalServiceBaseImpl.java:213)

      I have no problem at user through Studio UI.

      Any idea?
        • 1. Re: com.liferay.portal.service.base.UserLocalServiceBaseImpl.addUser failed
          920261
          What are you trying to do? Are you writing custom code to add a user? Or is this error occurring when Studio is trying to add a user by its normal means?

          If you are writing custom code, are you using the UserLocalServiceUtil.addUser method or trying to use the UserLocalServiceBaseImpl.addUser method directly? I would recommend using the utility class. It is set up to initialize the UserService correctly and make calls to methods like addUser statically.

          Dave
          • 2. Re: com.liferay.portal.service.base.UserLocalServiceBaseImpl.addUser failed
            YueZ-Oracle
            yes. I am writing an AutoLogin hook. I am able to retrieve existing user.

            I use UserLocalServiceUtil.addUser. The environment is prebuild quickstart (Endeca 2.3.0) using Tomcat and HSQL.

            BTW, do you know which library should I use to call an external web service? JAX-WS or Axis?

            Edited by: user721333 on Oct 26, 2012 2:55 PM

            Edited by: user721333 on Oct 26, 2012 2:56 PM
            • 3. Re: com.liferay.portal.service.base.UserLocalServiceBaseImpl.addUser failed
              920261
              Well, I've never run across this error myself, but I have used the UserLocalServiceUtil.addUser method successfully before. But I used the variant where you pass in all the data as parameters. I defined the bare minimum parameters and ended up with this. Maybe it'll work for you?

                        User user = null;
                        
                        try {
                             long creatorUserId = 0;
                             boolean autoPassword = true;
                             String password1 = null;
                             String password2 = null;
                             boolean autoScreenName = false;
                             String emailAddress = screenName + "test@oracle.com";
                             String openId = "";
                             Locale locale = Locale.US;
                             String firstName = "Test";
                             String middleName = "";
                             String lastName = "User";
                             int prefixId = 0;
                             int suffixId = 0;
                             boolean male = true;
                             int birthdayMonth = 1;
                             int birthdayDay = 1;
                             int birthdayYear = 1970;
                             String jobTitle = "";
                             long[] groupIds = null;
                             long[] organizationIds = null;
                             long[] roleIds = null;
                             long[] userGroupIds = null;
                             boolean sendEmail = false;
                             ServiceContext serviceContext = new ServiceContext();
                             
                             user = UserLocalServiceUtil.addUser(creatorUserId, companyId, autoPassword,
                                       password1, password2, autoScreenName, screenName, emailAddress, openId,
                                       locale, firstName, middleName, lastName, prefixId, suffixId, male,
                                       birthdayMonth, birthdayDay, birthdayYear, jobTitle, groupIds, organizationIds,
                                       roleIds, userGroupIds, sendEmail, serviceContext);
                        }
                        catch (Exception e) {
                             _log.error(e, e);
                        }
              • 4. Re: com.liferay.portal.service.base.UserLocalServiceBaseImpl.addUser failed
                YueZ-Oracle
                it works!

                I used CounterLocalServiceUtil.increment() as userId before (instead of 0). That may caused the issue.

                Thank you very much for your help.

                Edited by: user721333 on Oct 29, 2012 3:52 PM