为什么我在liferay中得到NullPointerException? [英] Why am I getting NullPointerException in liferay?

查看:102
本文介绍了为什么我在liferay中得到NullPointerException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在以下一行收到 NullPointerException

originalStrutsPortletAction.processAction(
                    originalStrutsPortletAction, portletConfig, actionRequest,
                        actionResponse);

我正在打印所有值:

System.out.println(originalStrutsPortletAction);
System.out.println(portletConfig);
System.out.println(actionRequest);
System.out.println(actionResponse);

输出:

com.liferay.portal.struts.StrutsPortletActionAdapter@2f20c4be
com.liferay.portlet.PortletConfigImpl@5f4268dd
com.liferay.portlet.ActionRequestImpl@1054ae1e
com.liferay.portlet.ActionResponseImpl@27733bf2

那我为什么要的NullPointerException ?请帮忙。谢谢。
完整堆栈跟踪如下: -

So why am I getting NullPointerException? Please help.Thanks in advance. The full stack trace is as follows:-

java.lang.NullPointerException
    at com.liferay.portlet.login.action.LoginAction.login(LoginAction.java:196)
    at com.liferay.portlet.login.action.LoginAction.processAction(LoginAction.java:93)
    at com.liferay.portal.struts.StrutsPortletActionAdapter.processAction(StrutsPortletActionAdapter.java:60)
    at com.liferay.portal.kernel.struts.BaseStrutsPortletAction.processAction(BaseStrutsPortletAction.java:44)
    at com.abhishek.ExampleLoginAction.check(ExampleLoginAction.java:185)
    at org.apache.jsp.jsp.otpCheck_jsp._jspService(otpCheck_jsp.java:71)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    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:728)
    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:116)
    at sun.reflect.GeneratedMethodAccessor503.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:67)
    at com.sun.proxy.$Proxy660.doFilter(Unknown Source)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:165)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
    at com.liferay.portal.kernel.servlet.PortalClassLoaderFilter.doFilter(PortalClassLoaderFilter.java:74)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:96)
    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:502)
    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:953)
    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:1023)
    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.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)


推荐答案

简单回答:你没有在那个位置得到NullpointerException-至少不是根据stacktrace你发布。 Liferay的LoginAction没有originalStrutsAction。如果您使用的是6.2 GA5,这是抛出NullpointerException的代码。为什么?这不是你问的。

Simple answer: You don't get a NullpointerException at that location- at least not according to the stacktrace you post. Liferay's LoginAction does not have an originalStrutsAction. In case you're using 6.2 GA5, this is the code that throws the NullpointerException. Why? That's not what you asked.

或者,用不同的方式表达它:你得到一个NullpointerException,因为你取消引用了Nullpointer。您只需要确定实际获得它的位置。堆栈跟踪有帮助。谁知道你的ExampleLoginAction在调用你发布的行之前做了什么......

Or, to phrase it differently: You're getting a NullpointerException because you dereference a Nullpointer. You'll just need to identify where you actually get it. The stacktrace helps. Who knows what your ExampleLoginAction does before it calls the line that you're posting...

这篇关于为什么我在liferay中得到NullPointerException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆