RE: LR 7.1 - StackOverflowError when customizing language keys

Jan Tošovský, modified 6 Years ago. Liferay Master Posts: 576 Join Date: 7/22/10 Recent Posts
I am trying to customize login module language keys following this tutorial:
https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-1/overriding-a-modules-language-keys

@Component(
        immediate = true,
        property = {
            "bundle.symbolic.name=com.liferay.login.web",
            "resource.bundle.base.name=content.Language",
            "servlet.context.name=login-web"
        }
)
public class LoginResourceBundleLoader implements ResourceBundleLoader {

    private static final Log LOGGER = LogFactoryUtil.getLog(LoginResourceBundleLoader.class);

    @Override
    public ResourceBundle loadResourceBundle(Locale locale) {
        LOGGER.info("loadResourceBundle: " + locale.toString());
        return _resourceBundleLoader.loadResourceBundle(locale);
    }

    @Reference(
            target = "(&(bundle.symbolic.name=com.liferay.login.web)(!(component.name=in.drifted.liferay.overrides.login.keys.LoginResourceBundleLoader)))"
    )
    public void setResourceBundleLoader(ResourceBundleLoader resourceBundleLoader) {
        _resourceBundleLoader = new AggregateResourceBundleLoader(new CacheResourceBundleLoader(new ClassResourceBundleLoader("content.Language", LoginResourceBundleLoader.class.getClassLoader())), resourceBundleLoader);
    }

    private AggregateResourceBundleLoader _resourceBundleLoader;
}

However, there is a recursion in loadResourceBundle. In the log I can see over 1800 identical messages:
[LoginResourceBundleLoader:28] loadResourceBundle: en_US
which are followed by
[status_jsp:927] com.liferay.portal.kernel.portlet.PortletContainerException: javax.servlet.ServletException: java.lang.StackOverflowError

Any idea how to fix this?

LR 7.1 ga-1, tomcat 8.5
Michał Janusz, modified 6 Years ago. New Member Posts: 14 Join Date: 3/8/16 Recent Posts

Hello,

I encountered the same problem. Were you able to find a solution or workaround? If so could you please post it?

 

Thanks in advance,

Michał

Jan Tošovský, modified 6 Years ago. Liferay Master Posts: 576 Join Date: 7/22/10 Recent Posts

It is not resolved yet. Are you customizing login portlet or something else?

 

In meantime I've seen various ways how resource bundles are overridden, in some portlets there are additional entries in bnd.bnd file, in other aggregating is done slightly differently. In sum, I think there are various approaches.

 

But I still believe in documentation and I think this error is rather some bug in the login portlet, not in our approach (as it works in other portlet I tested).

 

 

thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
I noticed you referenced GA1 in yiour original post. 7.1 GA2 is out now... do you still have the issue with the latest version?
Jan Tošovský, modified 6 Years ago. Liferay Master Posts: 576 Join Date: 7/22/10 Recent Posts

I've just tested my customization in 7.1.1 and I am getting the same error.

 

Btw, for this newer version the kernel dependency in the pom.xml file must be updated to:

<dependency>
    <groupId>com.liferay.portal</groupId>
    <artifactId>com.liferay.portal.kernel</artifactId>
    <version>3.39.2</version>
    <scope>provided</scope>
</dependency>
Jan Tošovský, modified 6 Years ago. Liferay Master Posts: 576 Join Date: 7/22/10 Recent Posts

This issue has already been reported in https://issues.liferay.com/browse/LPS-86878

That pom.xml comment was related to the test project https://github.com/jan-tosovsky-cz/liferay-overrides-login-test which I created for that Jira ticket.

 

Michał Janusz, modified 6 Years ago. New Member Posts: 14 Join Date: 3/8/16 Recent Posts
Jan Tošovský:

It is not resolved yet. Are you customizing login portlet or something else?

Yes, I try to customize login portlet.

 

I've tested it on sample project:

https://github.com/liferay/liferay-blade-samples/tree/7.1/maven/overrides/resource-bundle-override

 

It seems that the problem is only with login module. When I change other module like blog or journal it works fine.