cancel
Showing results for 
Search instead for 
Did you mean: 

Custom UserManager and GroupManager Issue

pedwards
Champ on-the-rise
Champ on-the-rise
Hi Guys,

Hope someone can help. Not sure if this is a bug or what. I've created my own custom user and group managers, and the sessionfactories. I've setup the spring to load them. All good. They don't do anything, they are just debug wrapping the methods so I could see what was getting passed, with the aim of then integrating with own user management.

Now it all appears to work fine, I can still login as kermit (as well I should), however I'm seeing the following exception in the console. Any help gratefully received.

Thanks
Paul.


11:42:57,909 [http-bio-8080-exec-22] DEBUG com.contextspace.CustomUserManager  - findUserById called with userId: kermit
11:42:57,910 [http-bio-8080-exec-22] DEBUG com.contextspace.CustomUserManager  - Found user - id:kermit fullname:Kermit The Frog
11:42:57,911 [http-bio-8080-exec-22] DEBUG com.contextspace.CustomUserManager  - checkPassword called with userId: kermit passwd: kermit result: true
11:42:57,911 [http-bio-8080-exec-22] DEBUG com.contextspace.CustomUserManager  - CreateNewUserQuery called
11:42:57,912 [http-bio-8080-exec-22] DEBUG com.contextspace.CustomUserManager  - FindUserByQueryCriteria called, query: org.activiti.engine.impl.UserQueryImpl@885acc2 page: null
11:42:57,996 [http-bio-8080-exec-22] ERROR org.activiti.engine.impl.interceptor.CommandContext  - Error while closing command context
org.activiti.engine.ActivitiIllegalArgumentException: userId is null
   at org.activiti.engine.impl.cmd.GetUserPictureCmd.execute(GetUserPictureCmd.java:41)
   at org.activiti.engine.impl.cmd.GetUserPictureCmd.execute(GetUserPictureCmd.java:30)
   at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:61)
   at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
   at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
   at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
   at org.activiti.engine.impl.IdentityServiceImpl.getUserPicture(IdentityServiceImpl.java:99)
   at org.activiti.explorer.ui.task.TaskEventsPanel.addTaskEventPicture(TaskEventsPanel.java:134)
   at org.activiti.explorer.ui.task.TaskEventsPanel.addTaskEvents(TaskEventsPanel.java:127)
   at org.activiti.explorer.ui.task.TaskEventsPanel.refreshTaskEvents(TaskEventsPanel.java:93)
   at org.activiti.explorer.ui.task.TaskEventsPanel.setTaskId(TaskEventsPanel.java:102)
   at org.activiti.explorer.ui.task.TaskPage.createDetailComponent(TaskPage.java:133)
   at org.activiti.explorer.ui.task.TaskPage$1.valueChange(TaskPage.java:117)
   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 com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510)
   at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164)
   at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1219)
   at com.vaadin.ui.AbstractField.fireValueChange(AbstractField.java:897)
   at com.vaadin.ui.AbstractField.setValue(AbstractField.java:529)
   at com.vaadin.ui.AbstractSelect.setValue(AbstractSelect.java:676)
   at com.vaadin.ui.AbstractSelect.setValue(AbstractSelect.java:645)
   at com.vaadin.ui.Table.setValue(Table.java:3572)
   at com.vaadin.ui.AbstractSelect.select(AbstractSelect.java:1422)
   at org.activiti.explorer.ui.AbstractTablePage.selectElement(AbstractTablePage.java:81)
   at org.activiti.explorer.ui.task.TaskPage.initUi(TaskPage.java:70)
   at org.activiti.explorer.ui.AbstractPage.attach(AbstractPage.java:43)
   at com.vaadin.ui.AbstractComponent.setParent(AbstractComponent.java:560)
   at com.vaadin.ui.AbstractComponentContainer.addComponent(AbstractComponentContainer.java:211)
   at com.vaadin.ui.CssLayout.addComponent(CssLayout.java:95)
   at org.activiti.explorer.ui.mainlayout.MainLayout.setMainContent(MainLayout.java:58)
   at org.activiti.explorer.ui.MainWindow.switchView(MainWindow.java:79)
   at org.activiti.explorer.DefaultViewManager.switchView(DefaultViewManager.java:342)
   at org.activiti.explorer.DefaultViewManager.showInboxPage(DefaultViewManager.java:172)
   at org.activiti.explorer.DefaultViewManager.showDefaultPage(DefaultViewManager.java:90)
   at org.activiti.explorer.ui.login.LoginPage$ActivitiLoginListener.onLogin(LoginPage.java:101)
   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 com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510)
   at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164)
   at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1219)
   at com.vaadin.ui.LoginForm$2.handleParameters(LoginForm.java:103)
   at com.vaadin.ui.Window.handleParameters(Window.java:515)
   at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:528)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
   at org.activiti.explorer.filter.ExplorerFilter.doFilter(ExplorerFilter.java:44)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:947)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
   at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1009)
   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
   at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   at java.lang.Thread.run(Thread.java:619)

11 REPLIES 11

jbarrez
Star Contributor
Star Contributor
That does seem like a bug … however, if you haven't changed anything I don't see how it could fail?

pedwards
Champ on-the-rise
Champ on-the-rise
Thats correct, I haven't changed anything, except to extend the manger classes and add some print statements before calling the superclass.

I have attached the classes, and the little bit of changed code is below.

<code>
  <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
   <property name="dataSource" ref="dataSource" />
   <property name="transactionManager" ref="transactionManager" />
   <property name="databaseSchemaUpdate" value="true" />
   <property name="jobExecutorActivate" value="true" />
    <property name="customFormTypes">
      <list>
        <bean class="org.activiti.explorer.form.UserFormType"/>
        <bean class="org.activiti.explorer.form.ProcessDefinitionFormType"/>
        <bean class="org.activiti.explorer.form.MonthFormType"/>
      </list>
    </property>
    <property name="customSessionFactories">
        <list>
            <bean class="com.contextspace.CustomGroupManagerFactory" />
            <bean class="com.contextspace.CustomUserManagerFactory" />
        </list>
    </property>
  </bean>
</code>

PS: please change the file upload to allow java files, its annoying to have to rename everything

jbarrez
Star Contributor
Star Contributor
I looked really long at your code and the code where the exception is thrown, but I don't see what could cause it.

Does it visually have an impact on Explorer? Do you know  which task event it tries to render and why the user id is wrong?

pedwards
Champ on-the-rise
Champ on-the-rise
I get that exception logging in. It seems to stop the log in, however if I hit the login again, it lets me in, and everything looks ok, except it seems to think that I have thousands of tasks waiting for me, and its all the sample data.

Try wacking the following jar into your activiti, update your config to have the same customSessionFactories as above and try logging in. Using all the demo data.

You will need to rename the file to jar.

pedwards
Champ on-the-rise
Champ on-the-rise
I should be clear, some of my jars are built from the 5.13 checkout, while some of it is 5.12.1. I'm not sure that this would effect it, as its working fine with no exceptions until I start fiddling with custom auth.

pedwards
Champ on-the-rise
Champ on-the-rise
Sorry, ignore the last comment, this is all against 5.12.1, it was the rest where I had a mixture. I have removed the rest module from the picture, so the only thing running on my system is the explorer, and its using ALL 5.12.1.

All I've done is add the jar I supplied above, and setup the xml. All I'm trying to do is login as kermit at the login screen:

<code>
INFO: Server startup in 16310 ms
11:59:58,053 [http-bio-8080-exec-7] DEBUG com.contextspace.CustomUserManager  - CreateNewUserQuery called
11:59:58,055 [http-bio-8080-exec-7] DEBUG com.contextspace.CustomUserManager  - findUserCountByQueryCriteria called, query: org.activiti.engine.impl.UserQueryImpl@7deb41d6
11:59:58,093 [http-bio-8080-exec-7] DEBUG com.contextspace.CustomUserManager  - Found 3 users
11:59:58,094 [http-bio-8080-exec-7] INFO  org.activiti.explorer.cache.TrieBasedUserCache  - Caching users 0 to 25
11:59:58,094 [http-bio-8080-exec-7] DEBUG com.contextspace.CustomUserManager  - CreateNewUserQuery called
11:59:58,095 [http-bio-8080-exec-7] DEBUG com.contextspace.CustomUserManager  - FindUserByQueryCriteria called, query: org.activiti.engine.impl.UserQueryImpl@324e68fb page: null
12:00:03,795 [http-bio-8080-exec-2] DEBUG com.contextspace.CustomUserManager  - findUserById called with userId: kermit
12:00:03,800 [http-bio-8080-exec-2] DEBUG com.contextspace.CustomUserManager  - Found user - id:kermit fullname:Kermit The Frog
12:00:03,801 [http-bio-8080-exec-2] DEBUG com.contextspace.CustomUserManager  - checkPassword called with userId: kermit passwd: kermit result: true
12:00:03,802 [http-bio-8080-exec-2] DEBUG com.contextspace.CustomUserManager  - CreateNewUserQuery called
12:00:03,803 [http-bio-8080-exec-2] DEBUG com.contextspace.CustomUserManager  - FindUserByQueryCriteria called, query: org.activiti.engine.impl.UserQueryImpl@21ef48fb page: null
12:00:03,977 [http-bio-8080-exec-2] ERROR org.activiti.engine.impl.interceptor.CommandContext  - Error while closing command context
org.activiti.engine.ActivitiIllegalArgumentException: userId is null
at org.activiti.engine.impl.cmd.GetUserPictureCmd.execute(GetUserPictureCmd.java:41)
at org.activiti.engine.impl.cmd.GetUserPictureCmd.execute(GetUserPictureCmd.java:30)
at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:61)
at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
at org.activiti.engine.impl.IdentityServiceImpl.getUserPicture(IdentityServiceImpl.java:99)
at org.activiti.explorer.ui.task.TaskEventsPanel.addTaskEventPicture(TaskEventsPanel.java:134)
at org.activiti.explorer.ui.task.TaskEventsPanel.addTaskEvents(TaskEventsPanel.java:127)
at org.activiti.explorer.ui.task.TaskEventsPanel.refreshTaskEvents(TaskEventsPanel.java:93)
at org.activiti.explorer.ui.task.TaskEventsPanel.setTaskId(TaskEventsPanel.java:102)
at org.activiti.explorer.ui.task.TaskPage.createDetailComponent(TaskPage.java:133)
at org.activiti.explorer.ui.task.TaskPage$1.valueChange(TaskPage.java:117)
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 com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164)
at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1219)
at com.vaadin.ui.AbstractField.fireValueChange(AbstractField.java:897)
at com.vaadin.ui.AbstractField.setValue(AbstractField.java:529)
at com.vaadin.ui.AbstractSelect.setValue(AbstractSelect.java:676)
at com.vaadin.ui.AbstractSelect.setValue(AbstractSelect.java:645)
at com.vaadin.ui.Table.setValue(Table.java:3572)
at com.vaadin.ui.AbstractSelect.select(AbstractSelect.java:1422)
at org.activiti.explorer.ui.AbstractTablePage.selectElement(AbstractTablePage.java:81)
at org.activiti.explorer.ui.task.TaskPage.initUi(TaskPage.java:70)
at org.activiti.explorer.ui.AbstractPage.attach(AbstractPage.java:43)
at com.vaadin.ui.AbstractComponent.setParent(AbstractComponent.java:560)
at com.vaadin.ui.AbstractComponentContainer.addComponent(AbstractComponentContainer.java:211)
at com.vaadin.ui.CssLayout.addComponent(CssLayout.java:95)
at org.activiti.explorer.ui.mainlayout.MainLayout.setMainContent(MainLayout.java:58)
at org.activiti.explorer.ui.MainWindow.switchView(MainWindow.java:79)
at org.activiti.explorer.DefaultViewManager.switchView(DefaultViewManager.java:342)
at org.activiti.explorer.DefaultViewManager.showInboxPage(DefaultViewManager.java:172)
at org.activiti.explorer.DefaultViewManager.showDefaultPage(DefaultViewManager.java:90)
at org.activiti.explorer.ui.login.LoginPage$ActivitiLoginListener.onLogin(LoginPage.java:101)
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 com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164)
at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1219)
at com.vaadin.ui.LoginForm$2.handleParameters(LoginForm.java:103)
at com.vaadin.ui.Window.handleParameters(Window.java:515)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:528)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.activiti.explorer.filter.ExplorerFilter.doFilter(ExplorerFilter.java:44)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:947)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1009)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)

</code>

trademak
Star Contributor
Star Contributor
Hi,

I gave your example jar a go, and the problem I ran into is that the createNewGroup method throws an UnsupportedOperationException. So the demo data generator fails somewhere in the middle and your db is not filled correctly. That's probably the cause of your issue.

Best regards,

marhta83
Champ in-the-making
Champ in-the-making
This article on forums.activiti.org is bookmark worthy in my opinion. It's worth saving for future reference. It's fascinating reading with many valid points for contemplation. I have to concur on almost every point made within this article.

pedwards
Champ on-the-rise
Champ on-the-rise
Tijs,

Looks like that is the answer. Looks like I had db corruption, or an imcomplete db. I was pretty sure I had loaded the db before I ever started with my plugin. All create clauses in the spring were false, so its sometime since I loaded the db. Interesting, all my rest calls using kermit were working prefectly, I was creating/deploying workflow etc….

However this has raised some questions looking at the output.

1. When a user logs in, it calls "CreateNewUserQuery", which in turn calls: return new UserQueryImpl(Context.getProcessEngineConfiguration().getCommandExecutorTxRequired()); Not quite sure what this query is. Can you explain what it does? Why?

2. Why cache 0-25 users? In our system there are thousands of users. I assume its not going to try and cache them all?

<code>
03:19:17,777 [http-bio-8080-exec-7] DEBUG com.contextspace.CustomUserManager  - CreateNewUserQuery called
03:19:17,809 [http-bio-8080-exec-7] DEBUG com.contextspace.CustomUserManager  - findUserCountByQueryCriteria called, query: org.activiti.engine.impl.UserQueryImpl@14c7b5e7
03:19:17,921 [http-bio-8080-exec-7] DEBUG com.contextspace.CustomUserManager  - Found 3 users
03:19:17,923 [http-bio-8080-exec-7] INFO  org.activiti.explorer.cache.TrieBasedUserCache  - Caching users 0 to 25
03:19:17,925 [http-bio-8080-exec-7] DEBUG com.contextspace.CustomUserManager  - CreateNewUserQuery called
03:19:17,926 [http-bio-8080-exec-7] DEBUG com.contextspace.CustomUserManager  - FindUserByQueryCriteria called, query: org.activiti.engine.impl.UserQueryImpl@7108759d page: null
03:19:23,641 [http-bio-8080-exec-10] DEBUG com.contextspace.CustomUserManager  - findUserById called with userId: kermit
03:19:23,654 [http-bio-8080-exec-10] DEBUG com.contextspace.CustomUserManager  - Not a contextspace user, try using the activiti system to find user
03:19:23,658 [http-bio-8080-exec-10] DEBUG com.contextspace.CustomUserManager  - Found user - id:kermit fullname:Kermit The Frog
03:19:23,659 [http-bio-8080-exec-10] DEBUG com.contextspace.CustomUserManager  - checkPassword called (using activiti auth, not cs auth) with userId: kermit passwd: kermit result: true
03:19:23,661 [http-bio-8080-exec-10] DEBUG com.contextspace.CustomUserManager  - CreateNewUserQuery called
03:19:23,664 [http-bio-8080-exec-10] DEBUG com.contextspace.CustomUserManager  - FindUserByQueryCriteria called, query: org.activiti.engine.impl.UserQueryImpl@4d5825d6 page: null

</code>