Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
xun ren
"Group" not created when creating "User"
July 23, 2012 1:59 AM
Answer

xun ren

Rank: Junior Member

Posts: 82

Join Date: April 1, 2008

Recent Posts

Hello,

I encountered a problem when creating an "User" : a "Group" associated has not been created.
Do have have experience on this, please?

For info : there is no LDAP behind. We use a SSO to create users manually by calling :
UserLocalServiceUtil.addUser(XXXX)

Environnement: jBoss5.1GA, Liferay 5.2.3 CE, Oracle.

Thanks a lot.
Jignesh Vachhani
RE: "Group" not created when creating "User"
July 23, 2012 3:25 AM
Answer

Jignesh Vachhani

Rank: Liferay Master

Posts: 792

Join Date: March 10, 2008

Recent Posts

Hi Xun,

Which and all parameters you are passing in addUser method ?

Also you are saying that 'a "Group" associated has not been created.' , what it means ?
Does Groups already created in liferay ?
Pinkesh Gandhi
RE: "Group" not created when creating "User"
July 23, 2012 4:32 AM
Answer

Pinkesh Gandhi

Rank: Regular Member

Posts: 100

Join Date: January 26, 2012

Recent Posts

Do you want to create UserGroup?

Can you please elaborate your problem in more detail?
xun ren
RE: "Group" not created when creating "User"
July 23, 2012 7:16 AM
Answer

xun ren

Rank: Junior Member

Posts: 82

Join Date: April 1, 2008

Recent Posts

Jignesh Vachhani:
Hi Xun,

Which and all parameters you are passing in addUser method ?

Also you are saying that 'a "Group" associated has not been created.' , what it means ?
Does Groups already created in liferay ?


Hi,

Thanks for your reply.
To anwser your question :
In "UserLocalServiceImpl.java" of Liferay Source, in the method "addUser"(line 403 of version 5.2.3 CE), I saw a line like this:
1groupLocalService.addGroup(
2            user.getUserId(), User.class.getName(), user.getUserId(), null,
3            null, 0, StringPool.SLASH + screenName, true, null);


That means Liferay will create a "Group" object associated with an "User".
For us, sometimes this "group" is not created but the object "user" is created successfully. So when we try to connect to the portal with this user, there will be a "NullPointerException", because there is no "group".
The problem for us is that, we do not have the detail of "NullPointerException" because we got another problem of Log4j in jBoss.

The problem for log4j of jBoss is that:
we changed the default server of jboss from "default" to "all", and start the server with parameter like this : "./run.sh -c all".
By changing the default server, we have also changed the configuration of jboss-log4j.xml in the server "all" to adding le log for our authentification. But maybe, the jBoss server looks still in the server "default" instead of "all" for the logging. That's why we do not have the detail of NullPointerException.

So either resolve the problem of logging or the problem of creation of user could help us out.
Thanks a lot, guys.

Sincerely,
Denis.
xun ren
RE: "Group" not created when creating "User"
July 23, 2012 7:23 AM
Answer

xun ren

Rank: Junior Member

Posts: 82

Join Date: April 1, 2008

Recent Posts

Pinkesh Gandhi:
Do you want to create UserGroup?

Can you please elaborate your problem in more detail?



Hi,
Thank you Pinkesh Gandhi, the same as above. The problem happens not all the time, but just for some users. And there is no obsvious different information (like firstname, email, screenname etc.) for these users.

I forgot to tell that the parameters we sent :


 1
 2boolean autoPassword = true;
 3String password1 = null;
 4String password2 = null;
 5boolean autoScreenName = false;
 6String openId = StringPool.BLANK;
 7String middleName = StringPool.BLANK;
 8int prefixId = 0;
 9int suffixId = 0;
10boolean male = true;
11Calendar cal = Calendar.getInstance();
12cal.setTimeInMillis(0l);
13int birthdayMonth = cal.get(Calendar.MONTH);
14int birthdayDay = cal
15        .get(Calendar.DAY_OF_MONTH);
16int birthdayYear = cal.get(Calendar.YEAR);
17String jobTitle = StringPool.BLANK;
18long[] groupIds = null;
19long[] organizationIds = null;
20long[] roleIds = null;
21long[] userGroupIds = null;
22boolean sendEmail = false;
23String screenName = "S0037318";
24String firstName = "Toto";
25String lastName = "Tata";
26String emailAddress = "toto@liferay.com";
27
28user = UserLocalServiceUtil.addUser(0,
29    companyId, autoPassword, password1,
30    password2, autoScreenName, screenName,
31    emailAddress, openId,
32    LocaleUtil.getDefault(), firstName,
33    middleName, lastName, prefixId,
34    suffixId, male, birthdayMonth,
35    birthdayDay, birthdayYear, jobTitle,
36    groupIds, organizationIds, roleIds,
37    userGroupIds, sendEmail,
38    new ServiceContext());
Hitoshi Ozawa
RE: "Group" not created when creating "User"
July 23, 2012 8:37 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

we changed the default server of jboss from "default" to "all",


Not very wise. There was somebody who did that and was always complaining about liferay problems. Liferay wasn't meant to run on jboss cluster.

line 403 of version 5.2.3 CE


This isn't very wise either. Better to upgrade to the most current 6.1.0 CE. If you can't support it yourself, get professional support from liferay.com or upgrade to the version which most community members are using - which I think now is 6.0.6 in production and 6.1.0 CE in development.
Jignesh Vachhani
RE: "Group" not created when creating "User"
July 23, 2012 9:58 PM
Answer

Jignesh Vachhani

Rank: Liferay Master

Posts: 792

Join Date: March 10, 2008

Recent Posts

Xun

The API which you are using is only creates user but not create groups.
So first you have to create user with the API which you already using and then you need to call UserGroupLocalServiceUtil.addUserGroup(userId,companyId,name,description); and updateUserGroup(companyId,userGroupId,name,description)
which will create or update group association depending you put suitable condition.
xun ren
RE: "Group" not created when creating "User"
July 24, 2012 1:55 AM
Answer

xun ren

Rank: Junior Member

Posts: 82

Join Date: April 1, 2008

Recent Posts

Hitoshi Ozawa:
we changed the default server of jboss from "default" to "all",


Not very wise. There was somebody who did that and was always complaining about liferay problems. Liferay wasn't meant to run on jboss cluster.

line 403 of version 5.2.3 CE


This isn't very wise either. Better to upgrade to the most current 6.1.0 CE. If you can't support it yourself, get professional support from liferay.com or upgrade to the version which most community members are using - which I think now is 6.0.6 in production and 6.1.0 CE in development.


Hi,

Thanks Hitoshi Ozawa.
For the first point : we are using the server "all" of jBoss, because we are using some service like EJB and JMX and some other services the server "default" can not provide. So our project is based on Liferay but not only Liferay.

For the second point : it's a big application already online. It is not as easy as you said to simply upgrad it to the version 6. We need to count the cost, the time etc. In addition, the most important, we do not have the permission of the boss to do so.

So at this moment, we need to find out the problem and solve it instead of avoid it.

Thanks anyway.
xun ren
RE: "Group" not created when creating "User"
July 24, 2012 2:00 AM
Answer

xun ren

Rank: Junior Member

Posts: 82

Join Date: April 1, 2008

Recent Posts

Jignesh Vachhani:
Xun

The API which you are using is only creates user but not create groups.
So first you have to create user with the API which you already using and then you need to call UserGroupLocalServiceUtil.addUserGroup(userId,companyId,name,description); and updateUserGroup(companyId,userGroupId,name,description)
which will create or update group association depending you put suitable condition.


Hello,

Sorry, I haven't made it clear. In fact, we need an object "Group" created instead of "UserGroup".
As I said, if you take a look at the source of "UserLocalServiceImpl.java", you will find that in the method "addUser", it will call
1groupLocalService.addGroup(
2            user.getUserId(), User.class.getName(), user.getUserId(), null,
3            null, 0, StringPool.SLASH + screenName, true, null);

to add an object "Group".

The "UserGroup" you mentioned is another object which make the association of Users and Groups. There are two different objects and there are saved in two different tables.
Jignesh Vachhani
RE: "Group" not created when creating "User"
July 24, 2012 2:06 AM
Answer

Jignesh Vachhani

Rank: Liferay Master

Posts: 792

Join Date: March 10, 2008

Recent Posts

Xun

If you have seen UserGroupLocalServiceUtil class and addUserGroup method , there already adding group object only at last.


groupLocalService.addGroup(
userId, UserGroup.class.getName(), userGroup.getUserGroupId(),
String.valueOf(userGroupId), null, 0, null, false, true, null);

xun ren
RE: "Group" not created when creating "User"
July 24, 2012 5:27 AM
Answer

xun ren

Rank: Junior Member

Posts: 82

Join Date: April 1, 2008

Recent Posts

Hello,

We've reproduced the problem on our Integration environnement. And we've found why there is an NullPointerException. We have posted a question here : https://www.liferay.com/community/forums/-/message_boards/message/15004160

So the only question now is why the "group" of an user is not created sometimes.