NoClassDefFoundError for zookeeper by replacing the log4j with relaod4j - java

Due to the recent exposure of log4j vulnerabilities our client has serious concerns about it. They asked us to remove or replace all the log4j ver.1 with ver.2 but unfortunately this is not possible for us to make such a big change.We did a workaround and replaced the log4j ver.1 with reload4j and majority of components are working fine this with change.
Unfortunately we have some binaries in our product like (elastic-search/logstash/zookeeper) which are using either the older version of log4j ver.2 (log4j-core-2.11.x < 2.17.1) or still using the log4j ver.1 (log4j-1.2.16).
For these we made the direct change in /lib/ directory and replaced the old jars with latests, this works fine for elastic-search/logstash. But when we did the same with zookeeper by replacing log4j with reload4j we're now facing the following exception when starting the component.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/jmx/HierarchyDynamicMBean
at org.apache.zookeeper.jmx.ManagedUtil.registerLog4jMBeans(ManagedUtil.java:50)
at org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeperServerMain.java:74)
at org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.java:52)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:116)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:78)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.jmx.HierarchyDynamicMBean
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 5 mor
zookeeper current version : 2.4.6
latest stable release : 3.7.0
Latest stable release is still using log4j-1.2.17.
Can someone please guide the workaround. Thanks in advance

Asked the same question to the owner of this library. Here is the further detail and answer of this problem. Thanks

Setting the system property zookeeper.jmx.log4j.disable=true will fix the issue. See also the documentation.

Related

Tomcat 9.x DBCP basicdatasource methods returning java.time.* cannot be mapped to JMX OpenType

I am trying to upgrade tomcat web container used by our application from version 8.5 to 9.x. We have JDBC resources defined on the context xml file which have JMX enabled. When the application starts up, exceptions are thrown while registering beans with MBeanServer due to java.time.Duration not having a corresponding OpenType.
This happens for org.apache.tomcat.dbcp.dbcp2.BasicDataSource which have methods that return values of type java.time.Duration
Exception:
Caused by: java.lang.IllegalArgumentException: Method org.apache.tomcat.dbcp.dbcp2.DataSourceMXBean.getMaxConnDuration has parameter or return type that cannot be translated into an OpenType
...
...
Caused by: javax.management.openmbean.OpenDataException: Cannot convert type: java.time.Duration
...
...
Caused by: javax.management.openmbean.OpenDataException: Cannot convert type: java.time.temporal.TemporalUnit
...
...
Caused by: javax.management.openmbean.OpenDataException: Recursive data structure, including java.time.Duration
https://docs.oracle.com/en/java/javase/12/docs/api/java.management/javax/management/openmbean/OpenType.html
https://tomcat.apache.org/tomcat-9.0-doc/api/org/apache/tomcat/dbcp/dbcp2/BasicDataSource.html
Is there a workaround for this?
Thanks!
We also struggled with this issue. Stumbled upon another question that was similar and someone mentioned a PR that lead us down the path of looking at commits in the tomcat project and the changelogs. If you look at the changelog for Tomcat 9.x you can find that for a dev/nightly release (at the time of this writing) of 9.0.59:
Revert the cherry-pick of JavaDoc fix from DBCP applied in 9.0.57 that broke the DataSourceMXBean by using a type that isn't supported by MXBeans. (markt)
If you are still struggling with this you could either try the latest dev/nightly build (not yet published in maven central) or use version 9.0.56, which is what we used, and it should resolve this issue.

ClassNotFoundException: com.azure.storage.common.policy.RequestRetryOptions

I am trying to run a java program that sends and receives messages to and from Azure Storage Queues; however, I keep getting the following ClassNotFoundException at runtime. I am having a hard time finding the jars necessary to fix it. Nothing I have found so far actually solves the problem.
Exception in thread "main" java.lang.NoClassDefFoundError: com/azure/storage/common/policy/RequestRetryOptions
at com.azure.storage.queue.QueueServiceClientBuilder.<init>(QueueServiceClientBuilder.java:83)
at com.cloudproject.azure.Connector.initiateConnection(Connector.java:58)
at com.cloudproject.server.ConnectionServer.main(ConnectionServer.java:30)
Caused by: java.lang.ClassNotFoundException: com.azure.storage.common.policy.RequestRetryOptions
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 3 more
I am not using maven in the build process, though I have pulled several jars from the maven repository - none of which have helped.
This seems to have been fixed by including the azure-storage-common jar, which I pulled from here. Not sure how I overlooked this one earlier.

Spring+quartz giving java.lang.NoClassDefFoundError: weblogic/logging/LogEntryFormatter

Im following http://www.mkyong.com/spring/spring-quartz-scheduler-example/ to develop a job for my spring app... Im getting the following exception when im trying to run it.
Can anyone tell whats the resolution for this?
Exception in thread "Main Thread" java.lang.NoClassDefFoundError: weblogic/logging/LogEntryFormatter >
at java.lang.ClassLoader.findBootstrapClass(Native Method)
at java.lang.ClassLoader.findBootstrapClass0(ClassLoader.java:891)
at java.lang.ClassLoader.loadClass(ClassLoader.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at weblogic.logging.commons.LogImpl.<init>(LogImpl.java:14)
at weblogic.logging.commons.LogFactoryImpl.getInstance(LogFactoryImpl.java:21)
at weblogic.logging.commons.LogFactoryImpl.getInstance(LogFactoryImpl.java:18)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:145)
at org.springframework.context.support.AbstractRefreshableApplicationContext.<init>(AbstractRefreshableApplicationContext.java:70)
at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.<init>(AbstractRefreshableConfigApplicationContext.java:45)
at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:59)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:136)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:84)
at com.jobs.RunMeJob.main(RunMeJob.java:10)
Seems like you are using the weblogic common logging mechanism in your app...and missing some jars/classes in your WL classpath. Can you post your classpath?
Also, you might want to try SLF4J for logging (http://www.slf4j.org) which I find so much easier to use (as well as versatile, allowing you to use any underlying logging mechanism, such as popular log4j for example)
If you deployed quartz to your Weblogic domain's lib directory you need to ensure that all of quartz dependencies are also deployed to the same directory.
I solved a similar problem by deploying jcl-over-slf4j and slf4j-api.

Akka tutorial code does not run

The tutorial code from
http://doc.akka.io/docs/akka/2.0.2/intro/getting-started-first-java.html
Will not run. I have imported the required libraries but get the error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/typesafe/config/ConfigFactory
at akka.actor.ActorSystem$.apply(ActorSystem.scala:93)
at akka.actor.ActorSystem$.create(ActorSystem.scala:56)
at akka.actor.ActorSystem.create(ActorSystem.scala)
at Pi.calculate(Pi.java:152)
at Pi.main(Pi.java:15)
Caused by: java.lang.ClassNotFoundException: com.typesafe.config.ConfigFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
... 5 more
Anyone know how to get this working? I'm trying to run it in Eclipse.
Note: I'm running akka 2.1.2
The problem is that you are not actually using Akka 2.0.2: the Config library only became an external dependency in 2.0.3. Since you are getting started with Akka, may I suggest you look at the latest stable version 2.1.2 instead?
Concerning the problem at hand: you will need to add the artifact "com.typesafe"/"config" to your classpath (the exact version depends on which Akka version you are using, I suggest using a dependency management tool like Maven or SBT).
Here's a link to the documentation (including required Scala versions etc) for each major version of Akka: http://akka.io/docs/

GAE , Some Exception after upgrade datanucleus jar packages

When I changed the sdk orm jar to v2 (default including by sdk),I got some excepion info.It's about the datanucleus-core-3.0.6.jar has ben registed bla bla....
After search,I knew it was a bug in 3.0.6. So, I relpace it by datanucleus-core-3.0.10.jar.
But it not success when compile the pojo Enhancer
java.lang.RuntimeException: Unexpected exception
at com.google.appengine.tools.enhancer.Enhancer.execute(Enhancer.java:76)
at com.google.appengine.tools.enhancer.Enhance.<init>(Enhance.java:71)
at com.google.appengine.tools.enhancer.Enhance.main(Enhance.java:51)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.appengine.tools.enhancer.Enhancer.execute(Enhancer.java:74)
... 2 more
Caused by: java.lang.NoSuchMethodError: org.datanucleus.plugin.PluginManager.<init>(Lorg/datanucleus/PersistenceConfiguration;Lorg/datanucleus/ClassLoaderResolver;)V
at org.datanucleus.OMFContext.<init>(OMFContext.java:159)
at org.datanucleus.enhancer.DataNucleusEnhancer.<init>(DataNucleusEnhancer.java:172)
at org.datanucleus.enhancer.DataNucleusEnhancer.<init>(DataNucleusEnhancer.java:150)
at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1157)
... 7 more
this is my jar file in the \lib\user\orm
asm-3.3.1.jar
datanucleus-api-jdo-3.0.5.jar
datanucleus-api-jpa-3.0.6.jar
datanucleus-appengine-2.0.0-final.jar
datanucleus-core-3.0.10.jar
geronimo-jpa_2.0_spec-1.0.jar
jdo-api-3.0.jar
transaction-api-1.1.jar
I has been looking for all day. Does any know what problem with it?
You have old versions of datanucleus-core and datanucleus-enhancer in the CLASSPATH somewhere. "OMFContext" from that stack trace hasn't existed in DataNucleus for a very long time.
I think I know, why it does not work to upgrade the appengine with a new datanucleus. It is not a classpath entry! I discovered that in the ant-macro.xml, which triggers the enhancing-step, there is a link to the appengine-tools-api.jar and there is the class EnhancerTask. This is probably a link to the old version since the new datanucleus-enhancer-3.0.1.jar has it's own EnhancerTask class. So the only way to use the new versions of datanucleus with the old appengine sdk (in contrary to http://code.google.com/p/datanucleus-appengine/wiki/HowToUpdateTheSDKWithANewPluginVersion) is to do the enhancement-step by either ant (https://developers.google.com/web-toolkit/doc/1.6/tutorial/appengine) or probably the eclipse-datanucleus-plugin. Unfortunately this plugin does not work properly in my Eclipse. After install/configure the plugin there is still no project-context menu "datanucleus", where I am supposed to add the support. So I'll try the ant version.

Categories

Resources