Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for com.lmax:disruptor:4 #1829

Closed
ashr123 opened this issue Sep 30, 2023 · 14 comments · Fixed by #2112
Closed

Support for com.lmax:disruptor:4 #1829

ashr123 opened this issue Sep 30, 2023 · 14 comments · Fixed by #2112
Assignees
Labels
async Affects asynchronous loggers or appenders bug Incorrect, unexpected, or unintended behavior of existing code dependencies Related to third party dependency updates or migrations
Milestone

Comments

@ashr123
Copy link

ashr123 commented Sep 30, 2023

Description

When I run with async logger and com.lmax:disruptor:4, I get the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: com/lmax/disruptor/SequenceReportingEventHandler
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
	at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
	at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
	at org.apache.logging.log4j.core.async.AsyncLoggerConfigDisruptor.start(AsyncLoggerConfigDisruptor.java:226)
	at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:312)
	at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:621)
	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:694)
	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:711)
	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:253)
	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:155)
	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47)
	at org.apache.logging.log4j.LogManager.getContext(LogManager.java:196)
	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:599)
	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:585)
	... 1 more
Caused by: java.lang.ClassNotFoundException: com.lmax.disruptor.SequenceReportingEventHandler
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
	... 21 more

Configuration

{
  "Configuration": {
    "Appenders": {
      "Console": {
        "name": "Console-Appender",
        "target": "SYSTEM_ERR",
        "PatternLayout": {
          "pattern": "%d{DEFAULT} [%level] - %msg%n"
        }
      },
      "Async": {
        "name": "Async-Console-Appender",
        "AppenderRef": {
          "ref": "Console-Appender"
        },
        "LinkedTransferQueue": {}
      }
    },
    "Loggers": {
      "AsyncRoot": {
        "level": "INFO",
        "AppenderRef": {
          "ref": "Async-Console-Appender"
        }
      }
    }
  }
}

Version: 2.20.0
Operating system: MacOS 13.6
JDK: OpenJDK 21

Reproduction

Just run an Java class with the following static field:

private static final Logger LOGGER = LogManager.getLogger();
@vy vy added the bug Incorrect, unexpected, or unintended behavior of existing code label Oct 2, 2023
@vy
Copy link
Member

vy commented Oct 2, 2023

@ashr123, yes, it is sadly a known problem. See LOG4J2-3595 that was reported earlier. We would appreciate it if you can submit a PR fixing the issue.

@vy vy added the duplicate Pull requests or issues with another instance elsewhere label Oct 2, 2023
@vy vy closed this as completed Oct 2, 2023
@jvz
Copy link
Member

jvz commented Oct 9, 2023

@vy I think it's harder to notice old Jira issues since we've migrated to GitHub Issues

@vy
Copy link
Member

vy commented Oct 9, 2023

@jvz, feel free to mark the JIRA one as duplicate and re-open this one.

@ppkarwasz ppkarwasz reopened this Oct 11, 2023
@ppkarwasz ppkarwasz removed the duplicate Pull requests or issues with another instance elsewhere label Oct 11, 2023
@jvz jvz added the dependencies Related to third party dependency updates or migrations label Oct 15, 2023
@jvz jvz added this to the 3.0.0 milestone Oct 15, 2023
@jvz jvz added the async Affects asynchronous loggers or appenders label Oct 15, 2023
tomerarazy added a commit to tomerarazy/logging-log4j2 that referenced this issue Nov 1, 2023
pacphi added a commit to cf-toolsuite/cf-butler that referenced this issue Nov 8, 2023
* Revert lmax disruptor; @see apache/logging-log4j2#1829
* Upgrade java-cfenv-boot dependency
* Switch Dockerfile base image to bellsoft/liberica-openjdk-alpine:17
pacphi added a commit to cf-toolsuite/cf-hoover-ui that referenced this issue Nov 8, 2023
* revert lmax disruptor; @see apache/logging-log4j2#1829
* upgrade java-cfenv-boot
@jvz
Copy link
Member

jvz commented Nov 11, 2023

Looks like this should be pretty simple to update. The main breaking change to handle here is updating some EventHandler implementations to directly implement that interface rather than using some mixin interfaces for the same. Nice simplification in the API actually!

@jvz jvz self-assigned this Nov 11, 2023
@ppkarwasz ppkarwasz modified the milestones: 3.0.0, 2.23.0 Dec 19, 2023
@ppkarwasz
Copy link
Contributor

@tcmot,

We support JPMS, which prevents two different modules from having the same classes.

However the differences between Disruptor 3.x and 4.x reduce themselves to having some optional classes in 3.x and we have a lot of experience dealing with optional dependencies. This issue is on my TODO list for 2.23.0 (January/February), but you can provide a PR following the guideline I provided in #1856.

@tcmot
Copy link

tcmot commented Dec 19, 2023

Hi @ppkarwasz

3.44 to 4.0.0

1,public class RingBufferLogEventHandler implements SequenceReportingEventHandler<RingBufferLogEvent>, LifecycleAware {

2,public class RingBufferLogEventHandler implements EventHandler<RingBufferLogEvent> {

Change 1 to 2, will complete the upgrade.

@tcmot
Copy link

tcmot commented Dec 19, 2023

Log4j2 version: 2.22.0

@ppkarwasz
Copy link
Contributor

@tcmot,

If you do that log4j-core stops working with version 3.x of Disruptor.

In the 2.x branch of Log4j the baseline is JRE 8 and will be for a long time. Therefore the baseline for LMAX Disruptor must be 3.x (Disruptor 4.x requires JRE 11). Since it is fairly easy to support both Disruptor 3.x and Disruptor 4.x, I will vote against any PR that does not work with Disruptor 3.x.

@ashr123
Copy link
Author

ashr123 commented Dec 19, 2023

What about moving to JDK 17 or 21?

@ppkarwasz
Copy link
Contributor

@ashr123,

The baseline for Log4j 3.x is JRE 17.

@ashr123
Copy link
Author

ashr123 commented Dec 19, 2023

is there a chance to move Log4J 4 to JDK 21? of not, what are the considerations?

@ppkarwasz
Copy link
Contributor

@ashr123,

Every version of Log4j (both 2.x and 3.x) runs on the newest Java available.

By baseline I only mean the oldest supported JRE. This is a restriction only for maintainers: in the 2.x branch we can not use language constructs or library methods from JDK 11+. Users don't feel this restriction, since we can use multiple techniques (e.g. Multi-Release JARs, reflection, etc.) to guarantee the log4j-core works in the same way on all the JDKs.

@ashr123
Copy link
Author

ashr123 commented Dec 19, 2023

I've asked only because it will allow you to use the newest features of the language and maybe make it more efficient (for example by using virtual threads, switch patterns etc)

ppkarwasz pushed a commit to tomerarazy/logging-log4j2 that referenced this issue Dec 19, 2023
ppkarwasz added a commit to tomerarazy/logging-log4j2 that referenced this issue Dec 19, 2023
@ppkarwasz
Copy link
Contributor

@ashr123,

We already compile our versions with JDK 17 (targeted at JRE 8 code), so many improvements in the compiler are already present.
Regarding virtual threads check LOG4J2-3622

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
async Affects asynchronous loggers or appenders bug Incorrect, unexpected, or unintended behavior of existing code dependencies Related to third party dependency updates or migrations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants