Neil Griffin created PLUTO-765:
----------------------------------

             Summary: The wrong ClassLoader is used to load the portlet 
ResourceBundle in portlet-skin.jsp
                 Key: PLUTO-765
                 URL: https://issues.apache.org/jira/browse/PLUTO-765
             Project: Pluto
          Issue Type: Bug
          Components: portlet container
    Affects Versions: 3.0.1, 3.0.0
            Reporter: Neil Griffin
            Assignee: Neil Griffin
             Fix For: 3.0.2


As shown in the following code fragment, portlet-skin.jsp uses the 
<pluto:title/> JSP tag in order to render the title of each portlet on the 
portal page:

{code:xml|title=portlet-skin.jsp}
<!-- Use pluto portlet tag to render the portlet -->
<pluto:portlet portletId="${portlet}">

  <!-- Assemble the rendering result -->
  <div class="portlet">
    <table class="header" width="100%">
        <tr>
            <td class="header" align="left">
                <!-- Portlet Title -->
                <h2 class="title"><pluto:title/></h2>
            </td>
            ...
        </tr>
        ...
    <table>
    ...
</pluto:portlet>
{code}

This in turn invokes {{PortletTitleTag.doStartTag()}} which does the following:

{code:java|tile=PortletTitleTag.java}
...
PortletConfig config = driverConfig.getPortletConfig(portletId);
...
Locale defaultLocale = request.getLocale();
ResourceBundle bundle = config.getResourceBundle(defaultLocale);
title = bundle.getString("javax.portlet.title");
{code}

The call to {{config.getResourceBundle(defaultLocale)}} eventually calls 
{{DriverPortletConfigImpl.getResourceBundle(Locale)}} which in turn calls 
{{ResourceBundleFactory.getResourceBundle(Locale)}}.

The {{ResourceBundleFactory.getResourceBundle(Locale)}} method uses the 
[TCCL|https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#getContextClassLoader()]
 in order to load the resource bundle resource:

{code:java|title=ResourceBundleFactory.java}
ClassLoader loader = Thread.currentThread().getContextClassLoader();
bundle = ResourceBundle.getBundle(bundleName, locale, loader);
{code}

The problem is that the {{ClassLoader}} associated with portlet-skin is the one 
for the "/pluto" webapp context, not the one for the portlet. This causes the 
resource bundle lookup to fail, which in turn causes the resource bundle cache 
to contain a bundle that has no property values.

One possible fix for this problem would be to ensure that the portlet itself 
obtains the resource bundle before pluto-skin.jsp tries to do it.




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to