[
https://issues.apache.org/jira/browse/LOG4J2-1421?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16086785#comment-16086785
]
Paul Burrowes commented on LOG4J2-1421:
---------------------------------------
I have run into this too. The problem is in how {{URLClassPath.findResource()}}
works (called by {{ResolverUtil}} via
{{URLClassLoader.getResources(packageName)}}).
Because a Jar file (any zip file) does not need to contain a directory
structure the package directory is not necessarily available as a resource. The
jar attached by Anthony Maire illustrates this, containing two files but no
directories. {{URLClassPath.findResource("test")}} returns null for this jar.
This can be worked around by parsing the manifest of the jars referenced by the
classloader and/or falling back to reading the jar index.
{code}
unzip -l log4j-plugin-load-issue/defaultFilter.jar
Archive: log4j-plugin-load-issue/defaultFilter.jar
Length Date Time Name
--------- ---------- ----- ----
25 06-09-2016 19:38 META-INF/MANIFEST.MF
1012 06-09-2016 19:33 test/DefaultFilter.class
--------- -------
1037 2 files
{code}
It's surprisingly hard to create a jar that doesn't have this problem unless
you're building modules with Maven compatible structures. Ant's jar task, for
example, doesn't include directories if you pass it a fileset.
> Custom plugins packaged in jar files are not loaded by "packages" property
> mecanism
> -----------------------------------------------------------------------------------
>
> Key: LOG4J2-1421
> URL: https://issues.apache.org/jira/browse/LOG4J2-1421
> Project: Log4j 2
> Issue Type: Bug
> Components: Plugins
> Affects Versions: 2.6
> Reporter: Anthony Maire
> Attachments: log4j-plugin-load-issue.zip
>
>
> the "packages" attribute in configuration file works properly to load custom
> plugins from Eclipse. However, if the plugin class is packaged alone in a jar
> file (without the Log4j2Plugins.dat file in it), the "packages" property load
> mecanism is not working.
> 2016-06-09 19:40:44,823 main DEBUG Took 0,001222 seconds to load 0 plugins
> from package test
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)