掲示板

Why is ThemeDisplay null?

7年前 に Chris Babstock によって更新されました。

Why is ThemeDisplay null?

New Member 投稿: 5 参加年月日: 17/02/16 最新の投稿
I am trying to make use of the standard JSON api in Liferay 7.0-ga3 to create a new mbmessage, and I am getting a NullPointerException in PortalImpl line 1704 (line 5 in the below snippet):

ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
	WebKeys.THEME_DISPLAY);

group = getControlPanelDisplayGroup(
	themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId(),
	themeDisplay.getDoAsGroupId(), portletId);


I have traced this back to the fact that themeDisplay is null.

This is a fresh install of Liferay with little to no extra configuration done. All I have done was create a category in the message boards, and then make the following web api call:

/api/jsonws/mbmessage/add-message/category-id/30864/subject/REST%20API%20Test/body/REST%20API%20Test. I have even attempted to do this via the api documentation site at /api/jsonws and it returns the same result:

{
  "exception": "java.lang.NullPointerException",
  "throwable": "java.lang.NullPointerException",
  "error": {
    "message": "java.lang.NullPointerException",
    "type": "java.lang.NullPointerException"
  }
}


Is this a bug in liferay, or is it a configuration issue? Keep in mind that I have not made any changes to the code, nor am I writing any custom portlets. I am only trying to make use of the existing web api.
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Why is ThemeDisplay null?

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Theme display represents where you are in the portal, basically a user context container.

The json guys have no sense of context; each are simply a json rest request.
7年前 に Chris Babstock によって更新されました。

RE: Why is ThemeDisplay null?

New Member 投稿: 5 参加年月日: 17/02/16 最新の投稿
Is there any way, then, to create a message (new thread) without using the GUI? I need a means of integrating our software package with Liferay such that a user can create and view threads from outside the Liferay GUI.
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Why is ThemeDisplay null?

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Liferay's remote apis offer both json and soap apis, so the OOTB ones should work for you.
7年前 に Chris Babstock によって更新されました。

RE: Why is ThemeDisplay null?

New Member 投稿: 5 参加年月日: 17/02/16 最新の投稿
But that's what I'm trying to do, and it's not working. You're not providing any help here.

When I use the standard API, I receive a NullPointerException due to themeDisplay being null. If using the JSON api is not possible because it doesn't support context, then how am I doing to do it using the OOTB api?
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Why is ThemeDisplay null?

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Ok, don't get upset, I'm trying to help you here.

Can you provide a full stack trace and what version you're using?
7年前 に Chris Babstock によって更新されました。

RE: Why is ThemeDisplay null?

New Member 投稿: 5 参加年月日: 17/02/16 最新の投稿
Using 7.0-ga3

java.lang.NullPointerException
        at com.liferay.portal.util.PortalImpl.getControlPanelPortletURL(PortalImpl.java:1704)
        at com.liferay.portal.util.PortalImpl.getControlPanelPortletURL(PortalImpl.java:1716)
        at com.liferay.portal.kernel.util.PortalUtil.getControlPanelPortletURL(PortalUtil.java:631)
        at com.liferay.portlet.messageboards.service.impl.MBMessageLocalServiceImpl.getMessageURL(MBMessageLocalServiceImpl.java:2020)
        at com.liferay.portlet.messageboards.service.impl.MBMessageLocalServiceImpl.startWorkflowInstance(MBMessageLocalServiceImpl.java:2426)
        at com.liferay.portlet.messageboards.service.impl.MBMessageLocalServiceImpl.addMessage(MBMessageLocalServiceImpl.java:435)
        at com.liferay.portlet.messageboards.service.impl.MBMessageLocalServiceImpl.addMessage(MBMessageLocalServiceImpl.java:467)
        at sun.reflect.GeneratedMethodAccessor2620.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:67)
        at com.sun.proxy.$Proxy345.addMessage(Unknown Source)
        at com.liferay.message.boards.kernel.service.MBMessageLocalServiceWrapper.addMessage(MBMessageLocalServiceWrapper.java:117)
        at sun.reflect.GeneratedMethodAccessor2620.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:67)
        at com.sun.proxy.$Proxy346.addMessage(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor2620.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:153)
        at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:85)
        at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:58)
        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
        at com.liferay.portal.service.ServiceContextAdvice.invoke(ServiceContextAdvice.java:40)
        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
        at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
        at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:173)
        at com.sun.proxy.$Proxy116.addMessage(Unknown Source)
        at com.liferay.portlet.messageboards.service.impl.MBMessageServiceImpl.addMessage(MBMessageServiceImpl.java:127)
        at com.liferay.portlet.messageboards.service.impl.MBMessageServiceImpl.addMessage(MBMessageServiceImpl.java:168)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:153)
        at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:85)
        at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:58)
        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
        at com.liferay.portal.service.ServiceContextAdvice.invoke(ServiceContextAdvice.java:40)
        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
        at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
        at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
        at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:173)
        at com.sun.proxy.$Proxy211.addMessage(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.liferay.portal.jsonwebservice.JSONWebServiceActionImpl._invokeActionMethod(JSONWebServiceActionImpl.java:404)
        at com.liferay.portal.jsonwebservice.JSONWebServiceActionImpl.invoke(JSONWebServiceActionImpl.java:76)
        at com.liferay.portal.jsonwebservice.JSONWebServiceServiceAction.getJSON(JSONWebServiceServiceAction.java:69)
        at com.liferay.portal.struts.JSONAction.execute(JSONAction.java:76)
        at com.liferay.portal.servlet.JSONServlet.service(JSONServlet.java:63)
        at com.liferay.portal.jsonwebservice.JSONWebServiceServlet.service(JSONWebServiceServlet.java:61)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:119)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:142)
        at com.liferay.portal.security.sso.ntlm.internal.servlet.filter.NtlmPostFilter.processFilter(NtlmPostFilter.java:107)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
        at com.liferay.sync.security.servlet.filter.SyncAuthFilter.doFilter(SyncAuthFilter.java:65)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
        at com.liferay.sync.internal.servlet.filter.SyncJSONFilter.doFilter(SyncJSONFilter.java:134)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:142)
        at com.liferay.portal.servlet.filters.uploadservletrequest.UploadServletRequestFilter.processFilter(UploadServletRequestFilter.java:93)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:142)
        at com.liferay.portal.servlet.filters.authverifier.AuthVerifierFilter.processFilter(AuthVerifierFilter.java:169)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:142)
        at com.liferay.portal.servlet.filters.jsoncontenttype.JSONContentTypeFilter.processFilter(JSONContentTypeFilter.java:42)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:142)
        at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:88)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:142)
        at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:260)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
        at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
        at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
        at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
        at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394)
        at com.liferay.portal.servlet.filters.urlrewrite.UrlRewriteFilter.processFilter(UrlRewriteFilter.java:65)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:168)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:168)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:115)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Why is ThemeDisplay null?

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
After digging through the code, to me this looks like a bug.

The json web service servlet does not seem to execute the ServicePreActions where the ThemeDisplay object is initialized and set as a request attribute, yet at the same time the addMessage() method needs to create a URL to the control panel using PortalUtil when preparing to do the workflow thing (whether workflow is enabled for messages or not).

There is an internal ticket open reporting same issue, but no LPS tickets. It will likely make it into DXP some time soon, no idea about LR7CE.

I'd open a ticket on issues.liferay.com so that it may make it into a CE release in the future.