[jboss-jira] [JBoss JIRA] (JGRP-2035) Util class tries to locate resource bundles using TCCL, which fails

Jason Greene (JIRA) issues at jboss.org
Tue Mar 29 10:23:00 EDT 2016


    [ https://issues.jboss.org/browse/JGRP-2035?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13183336#comment-13183336 ] 

Jason Greene commented on JGRP-2035:
------------------------------------

This commit is the problem: https://github.com/belaban/JGroups/commit/8bad26987223bda6e609127fdd39d053dee78dd0

Can we get a release with this reverted? 

As a general rule classes should always be loaded by the defining class loader (Class.forName() or OtherClass.class as the previous code before this change did).

There are a few special cases where you want to load classes from a TCCL, but those cases are where you expect classes other than your framework to be loaded (e.g. user classes defined in a different loader ), and when that approach is used it *must* be contextual. In other words, the code loading classes via TCCL needs to actually have a lifecycle. It's always wrong, for example, to load classes in the TCCL and stuff them in a static variable in a different class loader, as the life-cycles are not synchronized. Often times when TCCL support is truly required, you also have a set of local implementations, so in those cases you have to query multiple class loaders.

For more info see: https://developer.jboss.org/wiki/ModuleCompatibleClassloadingGuide



> Util class tries to locate resource bundles using TCCL, which fails
> -------------------------------------------------------------------
>
>                 Key: JGRP-2035
>                 URL: https://issues.jboss.org/browse/JGRP-2035
>             Project: JGroups
>          Issue Type: Bug
>            Reporter: Jan Martiska
>            Assignee: Bela Ban
>            Priority: Blocker
>
> {{org.jgroups.util.Util}} class tries to locate jg-messages bundle using the TCCL, not its own class loader. In a Java SE environment, this typically doesn't matter, because the class loaders are the same, but in EAP, this means that jg-messages is sought by the class loader of the application rather than the class loader of JGroups module, which is obviously wrong. This is the offending line: https://github.com/belaban/JGroups/blob/master/src/org/jgroups/util/Util.java#L93 
> The call to getBundle fails with a MissingResourceException (see http://docs.oracle.com/javase/6/docs/api/java/util/ResourceBundle.html#getBundle%28java.lang.String,%20java.util.Locale,%20java.lang.ClassLoader%29) and because this code is in a static initializer, the Util class becomes unusable.
> This causes Hibernate applications with 2LC infinispan clustering backend to not work.



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the jboss-jira mailing list