Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Christian Freihoff
Add User Programmatically fails with noSuchOrganizationException
March 22, 2013 8:43 AM
Answer

Christian Freihoff

Rank: Junior Member

Posts: 36

Join Date: December 3, 2012

Recent Posts

Hi at all!

I tried to add a user via java code using the UserLocalServiceUtil. It seems that my method (that one with one million parameters) causes a noSuchOrganizationException. I gave the organizationId[] with just one zero inside, because i did not define any organization in my portal.

Do i have to define an organization before adding users this way?

thanks in advance
Hitoshi Ozawa
RE: Add User Programmatically fails with noSuchOrganizationException
March 22, 2013 6:59 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7990

Join Date: March 23, 2010

Recent Posts

Do i have to define an organization before adding users this way?


Yes.
Christian Freihoff
RE: Add User Programmatically fails with noSuchOrganizationException
March 25, 2013 6:40 AM
Answer

Christian Freihoff

Rank: Junior Member

Posts: 36

Join Date: December 3, 2012

Recent Posts

thank You! But how to create an organization the best way?

the addOrganization-method needs a userId and a parent organization. there ist no parent organization, and users shall be created after that.
Vitaliy Koshelenko
RE: Add User Programmatically fails with noSuchOrganizationException
March 25, 2013 7:06 AM
Answer

Vitaliy Koshelenko

Rank: Regular Member

Posts: 222

Join Date: March 25, 2011

Recent Posts

Hi, Christian.

I gave the organizationId[] with just one zero inside


>> If you have no organizations yet, you shouldn't spicify zero inside (beacause you'll get noSuchOrganizationException for '0' value) , just create emptry organizationIds array:

1long[] organizationIds = {};


Hope this will help,
Vitaliy
Christian Freihoff
RE: Add User Programmatically fails with noSuchOrganizationException
March 25, 2013 8:06 AM
Answer

Christian Freihoff

Rank: Junior Member

Posts: 36

Join Date: December 3, 2012

Recent Posts

thx, i'm just trying that

hmmmm.... now getting a noSuchUserException. "user with that primary key not found" (used counter service increment to generate userId).

i thought the large addUser method would be enough. obviously not, what do i have to do else?
Christian Freihoff
RE: Add User Programmatically fails with noSuchOrganizationException
March 25, 2013 8:21 AM
Answer

Christian Freihoff

Rank: Junior Member

Posts: 36

Join Date: December 3, 2012

Recent Posts

ooooooops, the required userId is not the id of the new user,

it has to be the id of the user who creates the new user, what is the default user created on first run...

now it works, thx very much!!