<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Problem with AssetRenderer.getURLViewInContext() in 7.2 ?</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=121219165" />
  <subtitle>Problem with AssetRenderer.getURLViewInContext() in 7.2 ?</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=121219165</id>
  <updated>2026-04-07T05:15:35Z</updated>
  <dc:date>2026-04-07T05:15:35Z</dc:date>
  <entry>
    <title>RE: Problem with AssetRenderer.getURLViewInContext() in 7.2 ?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121458886" />
    <author>
      <name>Lee Jordan</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121458886</id>
    <updated>2022-06-30T19:12:00Z</updated>
    <published>2022-06-30T19:09:48Z</published>
    <summary type="html">&lt;p&gt;Try adding a widget page containing a portlet. Such as blogs, I was
  trying to show blog entries in asset publisher and it'll only work now
  for view-in-context if there is a context existing (context means page).&lt;/p&gt;
&lt;p&gt;Example I had to do this to avoid the error:&lt;br /&gt; &amp;lt;#assign
  viewURL = assetRenderer.getURLViewInContext(renderRequest,
  renderResponse,
  viewURL)!&amp;quot;http://www.50shades-o-liferay.com/oddity-base/find-urls-need-pages-to-exist-with-portlets-to-return-a-url.html&amp;quot; /&amp;gt;&lt;/p&gt;
&lt;p&gt;The view in context URL looks something like ...&lt;br /&gt; http://localhost:8080/c/blogs/find_entry?p_l_id=67&amp;amp;noSuchEntryRedirect=null&amp;amp;entryId=88020&lt;/p&gt;</summary>
    <dc:creator>Lee Jordan</dc:creator>
    <dc:date>2022-06-30T19:09:48Z</dc:date>
  </entry>
  <entry>
    <title>Problem with AssetRenderer.getURLViewInContext() in 7.2 ?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121219164" />
    <author>
      <name>Steve Weiss</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121219164</id>
    <updated>2021-10-26T18:38:58Z</updated>
    <published>2021-10-26T18:32:11Z</published>
    <summary type="html">&lt;p&gt;We have a custom search portlet that displays links to the results
  using URLs generated by AssetRenderer. Here is a sample of the code:&lt;/p&gt;
&lt;p style="margin-left: 40.0px;"&gt;String urlMaximzed =
  renderer.getURLView((LiferayPortletResponse) actionResponse, WindowState.MAXIMIZED);&lt;/p&gt;
&lt;p style="margin-left: 40.0px;"&gt;String urlviewincontext =
  renderer.getURLViewInContext((LiferayPortletRequest) actionRequest,
  LiferayPortletResponse) actionResponse, null);&lt;/p&gt;
&lt;p&gt;Printing out these URLs gives:&lt;/p&gt;
&lt;p style="margin-left: 40.0px;"&gt;2021-10-26 18:27:55.739 INFO
   [http-nio-8080-exec-4][CustomSearchPortlet:740] searchDocuments:
  urlMaximized: http://localhost:8080/web/avengers/search?p_p_id=com_liferay_document_library_web_portlet_DLPortlet&amp;amp;p_p_lifecycle=0&amp;amp;p_p_state=maximized&amp;amp;p_p_mode=view&amp;amp;_com_liferay_document_library_web_portlet_DLPortlet_mvcRenderCommandName=%2Fdocument_library%2Fview_file_entry&amp;amp;_com_liferay_document_library_web_portlet_DLPortlet_fileEntryId=35816&lt;/p&gt;
&lt;p style="margin-left: 40.0px;"&gt;
  &lt;br /&gt; 2021-10-26 18:27:55.742 INFO
   [http-nio-8080-exec-4][CustomSearchPortlet:755] searchDocuments:
  urlviewincontext = http://localhost:8080/c/document_library/find_file_entry?p_l_id=20&amp;amp;noSuchEntryRedirect=null&amp;amp;fileEntryId=35816&lt;/p&gt;
&lt;p&gt;Clicking on the first URL (maximized) in the portlet seems to work
  fine for all asset types. Clicking on the second (view in context)
  works for assets other than documents. For documents, clicking on the
  link produces an error with the following stack trace:&lt;/p&gt;
&lt;p&gt;2021-10-26 17:32:29.694 WARN  [http-nio-8080-exec-1][PortalImpl:6884]
  java.lang.NullPointerException&lt;br /&gt;
  java.lang.NullPointerException&lt;br /&gt;     at
  com.liferay.portal.kernel.portlet.PortletIdCodec.decodePortletName(PortletIdCodec.java:48)&lt;br /&gt;
      at
  com.liferay.portal.service.impl.PortletLocalServiceImpl.fetchPortletById(PortletLocalServiceImpl.java:405)&lt;br /&gt;
      at
  com.liferay.portal.service.impl.PortletLocalServiceImpl.getPortletById(PortletLocalServiceImpl.java:523)&lt;br /&gt;
      at sun.reflect.GeneratedMethodAccessor193.invoke(Unknown
  Source)&lt;br /&gt;     at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)&lt;br /&gt;
      at java.lang.reflect.Method.invoke(Method.java:498)&lt;br /&gt;     at
  com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:50)&lt;br /&gt;
      at
  com.liferay.portal.spring.aop.AopInvocationHandler.invoke(AopInvocationHandler.java:49)&lt;br /&gt;
      at com.sun.proxy.$Proxy44.getPortletById(Unknown Source)&lt;br /&gt;   
   at
  com.liferay.portal.kernel.service.PortletLocalServiceUtil.getPortletById(PortletLocalServiceUtil.java:339)&lt;br /&gt;
      at
  com.liferay.portlet.internal.PortletURLFactoryImpl.create(PortletURLFactoryImpl.java:81)&lt;br /&gt;
      at
  com.liferay.portal.kernel.portlet.PortletURLFactoryUtil.create(PortletURLFactoryUtil.java:59)&lt;br /&gt;
      at
  com.liferay.portal.struts.FindStrutsAction.execute(FindStrutsAction.java:99)&lt;br /&gt;
      at
  com.liferay.portal.struts.ActionAdapter.execute(ActionAdapter.java:40)&lt;br /&gt;
      at
  com.liferay.portal.struts.PortalRequestProcessor._process(PortalRequestProcessor.java:415)&lt;br /&gt;
      at
  com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:155)&lt;br /&gt;
      at
  com.liferay.portal.internal.servlet.MainServlet.doGet(MainServlet.java:206)&lt;br /&gt;
      at
  javax.servlet.http.HttpServlet.service(HttpServlet.java:626)&lt;br /&gt;   
   at
  com.liferay.portal.internal.servlet.MainServlet.service(MainServlet.java:623)&lt;br /&gt;
      at
  javax.servlet.http.HttpServlet.service(HttpServlet.java:733)&lt;br /&gt;   
   at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)&lt;br /&gt;
      at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)&lt;br /&gt;
      at
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)&lt;br /&gt;
      at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)&lt;br /&gt;
      at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:124)&lt;br /&gt;
      at
  com.liferay.portal.servlet.filters.password.modified.PasswordModifiedFilter.processFilter(PasswordModifiedFilter.java:62)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)&lt;br /&gt;
      at
  com.liferay.portal.servlet.filters.lockout.LockoutFilter.processFilter(LockoutFilter.java:58)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:147)&lt;br /&gt;
      at
  com.liferay.portal.servlet.filters.secure.BaseAuthFilter.processFilter(BaseAuthFilter.java:357)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:147)&lt;br /&gt;
      at
  com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:88)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:147)&lt;br /&gt;
      at
  com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:270)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:147)&lt;br /&gt;
      at
  com.liferay.portal.monitoring.internal.servlet.filter.MonitoringFilter.processFilter(MonitoringFilter.java:183)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:196)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:99)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:196)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:99)&lt;br /&gt;
      at
  org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)&lt;br /&gt;
      at
  org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)&lt;br /&gt;
      at
  org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)&lt;br /&gt;
      at
  org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:389)&lt;br /&gt;
      at
  com.liferay.portal.servlet.filters.urlrewrite.UrlRewriteFilter.processFilter(UrlRewriteFilter.java:65)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:175)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:99)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:175)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:99)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:196)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:99)&lt;br /&gt;
      at
  com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:104)&lt;br /&gt;
      at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)&lt;br /&gt;
      at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)&lt;br /&gt;
      at
  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)&lt;br /&gt;
      at
  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)&lt;br /&gt;
      at
  org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)&lt;br /&gt;
      at
  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)&lt;br /&gt;
      at
  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)&lt;br /&gt;
      at
  org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)&lt;br /&gt;
      at
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)&lt;br /&gt;
      at
  org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)&lt;br /&gt;
      at
  org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)&lt;br /&gt;
      at
  org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:880)&lt;br /&gt;
      at
  org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1601)&lt;br /&gt;
      at
  org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)&lt;br /&gt;
      at
  java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)&lt;br /&gt;
      at
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)&lt;br /&gt;
      at
  org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)&lt;br /&gt;
      at java.lang.Thread.run(Thread.java:748)&lt;br /&gt; 2021-10-26
  17:32:30.016 ERROR [http-nio-8080-exec-1][status_jsp:854] null&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;All of this worked correctly in 6.x, we're just seeing it now as
  we're migrating to 7.2.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;For brevity, AssetRenderer.getURLView returns a URL that works
  correctly. So does AssetRenderer.getURLExport. Only
  AssetRenderer.getURLViewInContext is returning a bad URL.&lt;/p&gt;</summary>
    <dc:creator>Steve Weiss</dc:creator>
    <dc:date>2021-10-26T18:32:11Z</dc:date>
  </entry>
</feed>
