Hi Rajika,

You are trying to add a role to a user, but this role is not in the
database. You need to add the role before trying to assign it to a user.

thanks,
dimuthul

On Thu, Mar 22, 2012 at 1:25 PM, Rajika Kumarasiri <[email protected]> wrote:

> I am trying add a user dynamically using the UM API.
>
> I used the UserStoreManager#addUser(String userName, Object credential,
> String[] roleList,Map<String, String> claims, String profileName, boolean
> requirePasswordChange)
>
> to add a user and I am ending up with the below stack trace. I tried to
> identify the SQL query that is being executed at
> JDBCUserStoreManager#updateStringValuesToDatabase and noticed the
> following.
>
> prep15: INSERT INTO UM_USER (UM_USER_NAME, UM_USER_PASSWORD,
> UM_SALT_VALUE, UM_REQUIRE_CHANGE, UM_CHANGED_TIME, UM_TENANT_ID) VALUES (?,
> ?, ?, ?, ?, ?) {1: 'csg-user', 2:
> 'gQ+rsFNnMoXqtRw8wcZMeZx3oQMyD7BaoLQtxxPl0Ro=', 3:
> '/eYO8nIFMI3QfodZuxR67A==', 4: FALSE, 5: TIMESTAMP '2012-03-22
> 13:13:29.461', 6: 0};
>
> Then I tried a Junit test case to see how the API is used by trying
> AdvancedJDBCRealmTest#doUserStuff and it ran without any error. The SQL
> query was in that instance as below.
>
> prep41: INSERT INTO UM_USER (UM_USER_NAME, UM_USER_PASSWORD,
> UM_SALT_VALUE, UM_REQUIRE_CHANGE, UM_CHANGED_TIME, UM_TENANT_ID) VALUES (?,
> ?, ?, ?, ?, ?) {1: 'vajira', 2:
> 'My/s+Z78+gTXvd9q9sq42wkwanpnEoIOVUFp93jGFtM=', 3:
> '231iUS978QnHVaRXIZIxrQ==', 4: FALSE, 5: TIMESTAMP '2012-03-22
> 13:10:42.738', 6: 0};
>
> Although there is no difference between the two sql queries I am ending up
> the below exception. Any idea what's wrong ?
>
> Rajika
>
>
>
> 2012-03-22 13:14:09,567] ERROR - DatabaseUtil NULL not allowed for column
> "UM_ROLE_ID"; SQL statement:
> INSERT INTO UM_USER_ROLE (UM_ROLE_ID, UM_USER_ID, UM_TENANT_ID) VALUES
> ((SELECT UM_ID FROM UM_ROLE WHERE UM_ROLE_NAME=? AND
> UM_TENANT_ID=?),(SELECT UM_ID FROM UM_USER WHERE UM_USER_NAME=? AND
> UM_TENANT_ID=?), ?) [90006-140]
> org.h2.jdbc.JdbcBatchUpdateException: NULL not allowed for column
> "UM_ROLE_ID"; SQL statement:
> INSERT INTO UM_USER_ROLE (UM_ROLE_ID, UM_USER_ID, UM_TENANT_ID) VALUES
> ((SELECT UM_ID FROM UM_ROLE WHERE UM_ROLE_NAME=? AND
> UM_TENANT_ID=?),(SELECT UM_ID FROM UM_USER WHERE UM_USER_NAME=? AND
> UM_TENANT_ID=?), ?) [90006-140]
>  at
> org.h2.jdbc.JdbcPreparedStatement.executeBatch(JdbcPreparedStatement.java:1098)
> at
> org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
>  at
> org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
> at
> org.wso2.carbon.user.core.util.DatabaseUtil.udpateUserRoleMappingInBatchMode(DatabaseUtil.java:277)
>  at
> org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager.persistUser(JDBCUserStoreManager.java:779)
> at
> org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager.addUser(JDBCUserStoreManager.java:685)
>  at
> org.wso2.carbon.cloud.csg.internal.CSGServiceComponent.addCSGUser(CSGServiceComponent.java:187)
> at
> org.wso2.carbon.cloud.csg.internal.CSGServiceComponent.activate(CSGServiceComponent.java:88)
>  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:597)
>  at
> org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:252)
> at
> org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
>  at
> org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:346)
> at
> org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:588)
>  at
> org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:196)
> at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:328)
>  at
> org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:221)
> at
> org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:104)
>  at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
> at
> org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
>  at
> org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
> at
> org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
>  at
> org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
> at
> org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
>  at
> org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
> at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
>  at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:451)
> at
> org.wso2.carbon.user.core.internal.Activator.startDeploy(Activator.java:67)
>  at
> org.wso2.carbon.user.core.internal.BundleCheckActivator.start(BundleCheckActivator.java:54)
> at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
>  at java.security.AccessController.doPrivileged(Native Method)
> at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
>  at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
> at
> org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
>  at
> org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:389)
> at
> org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1130)
>  at
> org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
> at
> org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
>  at
> org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
> at
> org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
>  at
> org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
> at
> org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
>  at
> org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
> at
> org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
>
>
>
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Dimuthu Leelarathne
Technical Lead

WSO2, Inc. (http://wso2.com)
email: [email protected]

Lean . Enterprise . Middleware
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to