We upgraded the logging in our application from log4j 1.x to the newest 2.17.1 version and now we get errors with OpenWebstart.
Exception is below - log4j-core-2.17.1.jar and log4j-api-2.17.1.jar are in the jnlp and they are loaded. PluginAliases is part of the core-jar. Is this a known problem with OpenWebstart or AdoptOpenJDK? Old webstart is working fine?
Exiting Boot.mainWithReturnCode() with 0
... 27 more
at net.sourceforge.jnlp.runtime.classloader.JNLPClassLoader.loadClass(JNLPClassLoader.java:1446)
at java.util.Optional.orElseThrow(Optional.java:290)
at net.sourceforge.jnlp.runtime.classloader.JNLPClassLoader.lambda$loadClass$9(JNLPClassLoader.java:1446)
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.core.config.plugins.PluginAliases
at net.sourceforge.jnlp.Launcher$TgThread.run(Launcher.java:659)
at net.sourceforge.jnlp.Launcher.access$200(Launcher.java:71)
at net.sourceforge.jnlp.Launcher.launchApplication(Launcher.java:406)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at dataplan.client.journaldesigner.jd.<clinit>(jd.java:73)
at dataplan.common.utilities.dpLogfile.<clinit>(dpLogfile.java:84)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:666)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:176)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:270)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:716)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:695)
at org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:323)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:481)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:557)
at org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConfiguration(XmlConfigurationFactory.java:46)
at org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlConfiguration.java:138)
at org.apache.logging.log4j.core.config.AbstractConfiguration.initializeWatchers(AbstractConfiguration.java:264)
at org.apache.logging.log4j.core.config.AbstractConfiguration.monitorSource(AbstractConfiguration.java:276)
at org.apache.logging.log4j.core.util.WatcherFactory.getInstance(WatcherFactory.java:55)
at org.apache.logging.log4j.core.util.WatcherFactory.<init>(WatcherFactory.java:47)
at org.apache.logging.log4j.core.config.plugins.util.PluginManager.collectPlugins(PluginManager.java:152)
at org.apache.logging.log4j.core.config.plugins.util.PluginRegistry.loadFromPackage(PluginRegistry.java:246)
Caused by: java.lang.NoClassDefFoundError: org/apache/logging/log4j/core/config/plugins/PluginAliases
at net.sourceforge.jnlp.Launcher$TgThread.run(Launcher.java:679)
We have heard of others with similar problems.
It would be really great if you could create a minimal reproducer application such that we can debug this issue and fix it.
public class LogForJExample {
private static final Logger LOG = LogManager.getLogger(LogForJExample.class);
public static void main(String[] args) {
LOG.debug("This Will Be Printed On Debug");
LOG.info("This Will Be Printed On Info");
LOG.warn("This Will Be Printed On Warn");
LOG.error("This Will Be Printed On Error");
LOG.fatal("This Will Be Printed On Fatal");
LOG.info("Appending string: {}.", "Hello, World");
}
}
Could it be that you have old and new versions of Log4J classes in the jars that you are specifying in your Jnlp file?
Exception is below - log4j-core-2.17.1.jar and log4j-api-2.17.1.jar are in the jnlp and they are loaded. PluginAliases is part of the core-jar. Is this a known problem with OpenWebstart or AdoptOpenJDK? Old webstart is working fine?
Can you please provide your Log4j2 config file or better still take the sample above and tweak it to reproduce your issue?
Here is how my config looks for the working sample above:
Janak Mulani wrote: ↑27 Jan 2022, 17:03
.....
Could it be that you have old and new versions of Log4J classes in the jars that you are specifying in your Jnlp file?
Don't think so - I had a look in all the cached jar files and I found only the new log4j version in the jars
Janak Mulani wrote: ↑28 Jan 2022, 06:29
...
Can you please provide your Log4j2 config file or better still take the sample above and tweak it to reproduce your issue?
...
We have the similar problems after updating the log4j to 2.17.2.
OWS: 1.5.2
JDK: Oracle 1.8.0_301
I got PluginAliases error.
If I try running with:
JDK: IBM Semeru Runtime Open Edition 11.0.12.0 or AdoptOpenJDK 11.0.1
I got an "IllegalStateException: zip file closed" error.
But if I switch to OWS3.0.0-alpha2 none of these problems occur and works very well. But as mentioned in another thread, alpha2 in not maintained and will not be released. So how can we solve these problems in 1.5.2?
During our investigations we found out that using log4j 2.17.3-snapshot version solves the problem for now. We have some appender implementations which use PatternLayout class from log4j. And during initialization some lookup classes are searched (SpringLookup, DockerLookup...etc.) via Interpolator by log4j and fails as we don't have a dependency to those. And whenever log4j fails OWS side also can not handle that and fails too. So anyone who have the same problem might try using snapshot version of log4j as a workaround. But as a final solution OWS side should also be able to handle this too imho.
Thanks very much for sharing the solution. Would it be possible to provide a small snippet of your application which is using "some appender implementations which use PatternLayout class from log4"? We can then debug why OWS was not able to find classes with Log4J 2.17.1 and why it is working with 2.17.3-snapshot.Thanks.
log4j 2.18 is released and the problem is solved.
Thanks to hilalkale who found that this problem didn't appear in a 2.17.3 snapshot, finally we just waited for the 2.18 release