[ 
https://issues.apache.org/jira/browse/LOG4J2-1467?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15386355#comment-15386355
 ] 

Ralf commented on LOG4J2-1467:
------------------------------

LoaderUtils uses {{Class.forName(...)}}, so it depends in the imports 
declarated in the Manifest.

I see following possible solutions:

*Add {{DynamicImport-Package: *}}*
With this, all available bundles will be searched for the one exporting the 
needed package. This results in a performance penalty only once, as the result 
is cached (exception: the result is not cached if the class was not found).

*Handing over the ClassLoader*
The class {{org.apache.logging.log4j.core.util.Loader}} uses 
{{org.apache.logging.log4j.util.LoaderUtil}} to load classes.
{{LoaderUtil}} should provide methods, to specify the class loader to use.

Like 
{{newCheckedInstanceOf(String className, Class<T> clazz, ClassLoader loader)}}. 
It would then be called from {{Loader}}  like 
{{LoaderUtil.newCheckedInstanceOf(className, clazz, 
Loader.class.getClassLoader())}}.

Interesting read: 
http://njbartlett.name/2010/08/30/osgi-readiness-loading-classes.html

> OSGi: Missing import package
> ----------------------------
>
>                 Key: LOG4J2-1467
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1467
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: API
>    Affects Versions: 2.6.2
>         Environment: Enterprise OSGi application
>            Reporter: Ralf
>
> The Import-Package statement in log4j-api-2.6.2.jar is missing the package 
> "org.apache.logging.log4j.core.lookup". This results in the following log 
> output while starting a enterprise OSGi application:
> Blueprint Extender: 3 WARN JNDI lookup class is not available because this 
> JRE does not support JNDI. JNDI string lookups will not be available, 
> continuing configuration. java.lang.ClassNotFoundException: 
> org.apache.logging.log4j.core.lookup.JndiLookup
>         at java.lang.Class.forName(Class.java:256)
>         at 
> org.apache.logging.log4j.util.LoaderUtil.loadClass(LoaderUtil.java:122)
>         at 
> org.apache.logging.log4j.util.LoaderUtil.newInstanceOf(LoaderUtil.java:141)
>         at 
> org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOf(LoaderUtil.java:168)
>         at 
> org.apache.logging.log4j.core.util.Loader.newCheckedInstanceOf(Loader.java:301)
>         at 
> org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:95)
>         at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:116)
> and
> Blueprint Extender: 3 WARN JMX runtime input lookup class is not available 
> because this JRE does not support JMX. JMX lookups will not be available, 
> continuing configuration. java.lang.ClassNotFoundException: 
> org.apache.logging.log4j.core.lookup.JmxRuntimeInputArgumentsLookup
>    (Stacktrace like above)
> As local fix I added 'DynamicImport-Package: *' to the MANIFEST.MF. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to