掲示板

Cannot add new user

12年前 に Kadir BASOL によって更新されました。

Cannot add new user

Junior Member 投稿: 91 参加年月日: 10/08/10 最新の投稿
Hi , i m trying to add new users from webservices ,
but i cant add.

This code can some of webservices methods with success , like ; UserSoap soapUserModel = soapUser.getUserById(11002);
but when addUser is called at last stage ,

i got this exception.


debug:
Have no file for C:\Program Files (x86)\Java\jdk1.6.0_25\jre\lib\modules\jdk.boot.jar
log4j:WARN No appenders could be found for logger (org.apache.axis.i18n.ProjectResourceBundle).
log4j:WARN Please initialize the log4j system properly.
AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode: 
 faultString: java.rmi.RemoteException
 faultActor: 
 faultNode: 
 faultDetail: 
        {http://xml.apache.org/axis/}hostname:host.server.com

java.rmi.RemoteException
        at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
        at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
        at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2938)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
        at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
        at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
        at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
        at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
        at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)
        at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
        at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
        at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
        at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
        at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
        at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
        at org.apache.axis.client.Call.invoke(Call.java:2767)
        at org.apache.axis.client.Call.invoke(Call.java:2443)
        at org.apache.axis.client.Call.invoke(Call.java:2366)
        at org.apache.axis.client.Call.invoke(Call.java:1812)
        at com.liferay.client.soap.portal.service.http.Portal_UserServiceSoapBindingStub.addUser(Portal_UserServiceSoapBindingStub.java:1263)
        at javaapplication16.Main.main(Main.java:57)
BUILD SUCCESSFUL (total time: 8 seconds)






/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javaapplication16;


import com.liferay.client.soap.portal.model.UserSoap;
import com.liferay.client.soap.portal.service.http.UserServiceSoap;
import com.liferay.client.soap.portal.service.http.UserServiceSoapServiceLocator;
import java.net.URL;

/**
 *
 * @author kadirbasol
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        try {
            UserServiceSoapServiceLocator locatorUser = new UserServiceSoapServiceLocator( );
            UserServiceSoap soapUser = locatorUser.getPortal_UserService(new URL("http://xxxx:xxxx@216.120.250.211/tunnel/secure/axis/Portal_UserService"));
            
            if (null != soapUser) {
                
                UserSoap soapUserModel = soapUser.getUserById(11002);

                long facebook_id = soapUserModel.getFacebookId();;
                String openid_str = soapUserModel.getOpenId();
                long companyId = soapUserModel.getCompanyId();
                int prefix_id = 0;
                int suffixId = 0;
                boolean male = true;
                int birthdayMonth = 1 , birthdayDay = 1 , birthdayYear = 1982;
                
                long groupIds[] = new long[1];
                groupIds[0] = -1;
                long organizationIds[] = new long[1];
                organizationIds[0] = -1;

                long roleIds[] = new long[1];
                roleIds[0] = 0; //-1;

                long userGroupIds[] = new long[1];
                userGroupIds[0] = -1;
                
                soapUser.addUser(companyId,false,"pwd1","pwd1",false,"screen_name", "kadir@bayner.com", facebook_id, openid_str, "TR", "FirstName", "Middle", "Last", prefix_id, suffixId, male ,  birthdayMonth, birthdayDay, birthdayYear, "Job Title", groupIds, organizationIds, roleIds, userGroupIds, true, null);
                System.out.println(" getEmailAddress:" + soapUserModel.getEmailAddress());
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}




How can i add user remotely ? Please someone help ?!
I lost my 2 days ;(
thumbnail
12年前 に James Falkner によって更新されました。

RE: Cannot add new user

Liferay Legend 投稿: 1399 参加年月日: 10/09/17 最新の投稿
Screenname is invalid (it has an underscore) and the ids for groupIds, roleIds, usergroupIds, and organizationIds are all -1 which are non-existant. Instead, just pass null. So, this worked for me:

soapUser.addUser(companyId,false,"pwd1","pwd1",false,"screenname", "kadir@bayner.com", facebook_id, openid_str, "TR", "FirstName", "Middle", "Last", prefix_id, suffixId, male , birthdayMonth, birthdayDay, birthdayYear, "Job Title", null, null, null, null, true, null);
thumbnail
12年前 に James Falkner によって更新されました。

RE: Cannot add new user

Liferay Legend 投稿: 1399 参加年月日: 10/09/17 最新の投稿
BTW, I figured this out by watching the server logs (catalina.out in the case of Tomcat).

I got

13:49:38,087 ERROR [UserServiceSoap:165] com.liferay.portal.UserScreenNameException
com.liferay.portal.UserScreenNameException

and

then after fixing the screenname I got

13:50:00,732 ERROR [UserServiceSoap:165] com.liferay.portal.NoSuchUserGroupException: No UserGroup exists with the primary key -1
com.liferay.portal.NoSuchUserGroupException: No UserGroup exists with the primary key -1
12年前 に Kadir BASOL によって更新されました。

RE: Cannot add new user

Junior Member 投稿: 91 参加年月日: 10/08/10 最新の投稿
Thanks yes , now it worked.
Thanks for help