Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

java.lang.NoSuchFieldError: EMPTY_BYTE_ARRAY #1506

Closed
haksunlinm opened this issue Jun 8, 2023 · 2 comments
Closed

java.lang.NoSuchFieldError: EMPTY_BYTE_ARRAY #1506

haksunlinm opened this issue Jun 8, 2023 · 2 comments
Labels
question Tickets that are not bug reports, but questions

Comments

@haksunlinm
Copy link

haksunlinm commented Jun 8, 2023

Description

I googled this problem and it seems that this field causes a lot of issues in deployment. I wonder why and why this field is so special and causes the error.

Configuration

Version: 2.17.0

Operating system: in use with Kotlin and Jupyter

JDK: open JDK 11

Logs

EMPTY_BYTE_ARRAY
java.lang.NoSuchFieldError: EMPTY_BYTE_ARRAY
at org.apache.logging.log4j.core.config.ConfigurationSource.(ConfigurationSource.java:56)
at org.apache.logging.log4j.core.config.NullConfiguration.(NullConfiguration.java:32)
at org.apache.logging.log4j.core.LoggerContext.(LoggerContext.java:85)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.createContext(ClassLoaderContextSelector.java:254)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:136)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:123)
at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:117)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:150)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581)
at org.jzy3d.chart.factories.ChartFactory.(ChartFactory.java:37)
at Line_23.chart(Line_23.jupyter-kts:14)
at Line_23.(Line_23.jupyter-kts:45)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.evalWithConfigAndOtherScriptsResults(BasicJvmScriptEvaluator.kt:105)
at kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke$suspendImpl(BasicJvmScriptEvaluator.kt:47)
at kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke(BasicJvmScriptEvaluator.kt)
at kotlin.script.experimental.jvm.BasicJvmReplEvaluator.eval(BasicJvmReplEvaluator.kt:49)
at org.jetbrains.kotlinx.jupyter.repl.impl.InternalEvaluatorImpl$eval$resultWithDiagnostics$1.invokeSuspend(InternalEvaluatorImpl.kt:103)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
at org.jetbrains.kotlinx.jupyter.repl.impl.InternalEvaluatorImpl.eval(InternalEvaluatorImpl.kt:103)
at org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl$execute$1$result$1.invoke(CellExecutorImpl.kt:71)
at org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl$execute$1$result$1.invoke(CellExecutorImpl.kt:69)
at org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl.withHost(repl.kt:635)
at org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl.execute(CellExecutorImpl.kt:69)
at org.jetbrains.kotlinx.jupyter.repl.CellExecutor$DefaultImpls.execute$default(CellExecutor.kt:15)
at org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl$evalEx$1.invoke(repl.kt:444)
at org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl$evalEx$1.invoke(repl.kt:433)
at org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl.withEvalContext(repl.kt:397)
at org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl.evalEx(repl.kt:433)
at org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl.eval(repl.kt:485)
at org.jetbrains.kotlinx.jupyter.messaging.ProtocolKt$shellMessagesHandler$2$res$1.invoke(protocol.kt:321)
at org.jetbrains.kotlinx.jupyter.messaging.ProtocolKt$shellMessagesHandler$2$res$1.invoke(protocol.kt:320)
at org.jetbrains.kotlinx.jupyter.JupyterExecutorImpl$runExecution$execThread$1.invoke(execution.kt:33)
at org.jetbrains.kotlinx.jupyter.JupyterExecutorImpl$runExecution$execThread$1.invoke(execution.kt:31)
at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)

Reproduction

Initially, I thought it might be a problem with the kotlin-jupyter kernel. So, I submitted an issue in their github/issue.
Kotlin/kotlin-jupyter#417

After more research, I found this problem appearing in other deployment as well. This field is just sometimes not accessible.

The code to reproduce it is:

@file:Repository("https://repo1.maven.org/maven2")
@file:DependsOn("org.apache.logging.log4j:log4j-api:2.20.0")
var c1 = org.apache.logging.log4j.util.Constants.JAVA_MAJOR_VERSION // always OK
c1

var c2 = org.apache.logging.log4j.util.Constants.EMPTY_BYTE_ARRAY // often can't be found
c2

All it does is to load the jar, and try to access the field: var c2 = org.apache.logging.log4j.util.Constants.EMPTY_BYTE_ARRAY

And it is missing.

You will need a jupyter-kotlin server to run this code. I prepare an instance here:
http://35.223.178.227:8888/tree?token=5d6c7622a457c14fcad438dbe89ff57be4a564021d23e07e

@haksunlinm
Copy link
Author

I googled the same issue and it seems to happen in other situations as well. But I don't see a solution.

https://www.google.com/search?q=empty_byte_array+log4j&oq=EMPTY_BYTE_ARRAY&aqs=chrome.1.69i57j0i512j0i30l3j69i61l3.1733j0j7&sourceid=chrome&ie=UTF-8

@ppkarwasz
Copy link
Contributor

@haksunlinm,

Constants.EMPTY_BYTE_ARRAY appeared in version 2.15.0 of the API. Any chance the jupyter-kotlin server includes a copy of an older log4j-api?

@apache apache locked and limited conversation to collaborators Jan 4, 2024
@ppkarwasz ppkarwasz converted this issue into discussion #2165 Jan 4, 2024
@vy vy added the question Tickets that are not bug reports, but questions label Jan 5, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question Tickets that are not bug reports, but questions
Projects
None yet
Development

No branches or pull requests

3 participants