我正在尝试使用类GroupLocalServiceUtil的addGroup方法在 Liferay 中创建一个新组。我根据文档传递参数类型,但是它会莫名其妙地抛出一个。这是我的纯代码:IllegalArgumentException
ServiceContext sc = new ServiceContext();
sc.setScopeGroupId(10);
GroupLocalServiceUtil.addGroup(11101, "com.liferay.portal.model.Group", 0, 0, "aaa","foo", description,
10, null, true, true, sc);
怎么了?我可以将 ServiceContext 参数设置为 null 吗?
更新:我使用的版本是 6.1。异常的堆栈跟踪是:
Caused by: java.lang.IllegalStateException: Something went wrong:
at com.pro.liferay.startUpHook.ReadGroupFromCsv.addData(ReadGroupFromCsv.java:69)
at com.pro.liferay.startUpHook.CreateUserOnStartUp.run(CreateUserOnStartUp.java:27)
at com.liferay.portal.kernel.events.InvokerSimpleAction.run(InvokerSimpleAction.java:42)
at com.liferay.portal.deploy.hot.HookHotDeployListener.initEvent(HookHotDeployListener.java:1177)
at com.liferay.portal.deploy.hot.HookHotDeployListener.initEvents(HookHotDeployListener.java:1239)
at com.liferay.portal.deploy.hot.HookHotDeployListener.initPortalProperties(HookHotDeployListener.java:1595)
at com.liferay.portal.deploy.hot.HookHotDeployListener.doInvokeDeploy(HookHotDeployListener.java:563)
at com.liferay.portal.deploy.hot.HookHotDeployListener.invokeDeploy(HookHotDeployListener.java:273)
... 23 more
Caused by: java.lang.IllegalArgumentException
at com.liferay.portal.service.impl.GroupLocalServiceImpl.addGroup(GroupLocalServiceImpl.java:276)
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.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:122)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:71)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
at com.liferay.portal.security.pacl.PACLAdvice.invoke(PACLAdvice.java:51)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:211)
at $Proxy23.addGroup(Unknown Source)
at com.liferay.portal.service.GroupLocalServiceUtil.addGroup(GroupLocalServiceUtil.java:300)
at com.pro.liferay.startUpHook.customutils.GroupUtil.addGroup(GroupUtil.java:63)
at com.pro.liferay.startUpHook.customutils.GroupUtil.addGroup(GroupUtil.java:69)
at com.pro.liferay.startUpHook.ReadGroupFromCsv.addData(ReadGroupFromCsv.java:67)
... 30 more