0

我在 Liferay 6.1 中创建注册 portlet 并将用户帐户存储User_在数据库的默认表中时遇到问题。

我正在使用默认 Liferay 类UserLocalServiceUtil及其方法UserLocalServiceUtil.addUser(creatorUserId, companyId, autoPassword, password1, password2, autoScreenName, screenName, emailAddress, facebookId, openId, locale, firstName, middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle, groupIds, organizationIds, roleIds, userGroupIds, sendEmail, serviceContext);

我面临这个错误:

java.lang.NullPointerException
    at com.liferay.portal.security.pwd.PwdToolkitUtil.validate(PwdToolkitUtil.java:40)
    at com.liferay.portal.service.impl.UserLocalServiceImpl.validate(UserLocalServiceImpl.java:5405)
    at com.liferay.portal.service.impl.UserLocalServiceImpl.addUserWithWorkflow(UserLocalServiceImpl.java:592)
    at com.liferay.portal.service.impl.UserLocalServiceImpl.addUser(UserLocalServiceImpl.java:463)
    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:112)
    at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:71)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:108)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:59)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:108)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:59)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:108)
    at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:211)
    at $Proxy96.addUser(Unknown Source)
    at com.liferay.portal.service.UserLocalServiceUtil.addUser(UserLocalServiceUtil.java:445)
    at org.apache.jsp.register_jsp._jspService(register_jsp.java:123)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:113)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:70)
    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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
    at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:593)
    at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:530)
    at com.liferay.portlet.PortletRequestDispatcherImpl.dispatch(PortletRequestDispatcherImpl.java:316)
    at com.liferay.portlet.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:105)
    at com.liferay.util.bridges.mvc.MVCPortlet.include(MVCPortlet.java:366)
    at com.liferay.util.bridges.mvc.MVCPortlet.include(MVCPortlet.java:382)
    at com.liferay.util.bridges.mvc.MVCPortlet.doDispatch(MVCPortlet.java:315)
    at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
...
4

2 回答 2

1

看起来您正试图从 portlet 的呈现状态直接从 jsp 调用此方法 - 您应该在呈现之前从操作状态执行此操作。在渲染期间,您不应该更改任何状态。

阅读有关 portlet 生命周期的详细信息,其中对此进行了更详细的解释。简而言之:如果您习惯于在 servlet 中从 jsps 做所有事情,那么您将不得不重新学习 portlet:action 和 render 是完全分离的状态。通常,portlet 呈现的频率比它实际处理动作的频率高得多(因为许多不同的 portlet 可以在一个页面上,所以只有一个可能会处理一个动作,而所有的 portlet 都可能显示/呈现。

于 2012-09-03T16:11:59.440 回答
0

您的 password1 或 password2 可能为空,并且 autoPassword 设置为 true。Liferay 尝试验证给定的密码,当比较空值时,会出现 NullPointerException。

于 2012-09-04T15:26:41.510 回答