Hi there,

Thanks guys. Jacques was correct. Setting a breakpoint in the static 
initializer of the MemoryUtil class, it appears that the actual underlying 
exception actually thrown was - java.lang.reflect.InaccessibleObjectException: 
Unable to make field long java.nio.Buffer.address accessible: module java.base 
does not "opens java.nio" to unnamed module

I traced it down to the VM parameters - I inadvertently put them in the wrong 
field in the IDE's debugger hence --add-opens=java.base/java.nio=ALL-UNNAMED 
wasn't being passed as VM arguments.

Thats now been added correctly and the NoClassDefFoundError and 
InaccessibleObjectException have gone away.

Thanks alot guys.

Regards,

Olo

________________________________
From: Jacques Nadeau <[email protected]>
Sent: 18 July 2022 22:52
To: [email protected] <[email protected]>
Subject: Re: [JAVA] java.lang.NoClassDefFoundError: Could not initialize class 
org.apache.arrow.memory.util.MemoryUtil

Thanks David!

On Mon, Jul 18, 2022 at 2:42 PM David Li 
<[email protected]<mailto:[email protected]>> wrote:
I filed 
https://issues.apache.org/jira/browse/ARROW-17113<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fissues.apache.org%2Fjira%2Fbrowse%2FARROW-17113&data=05%7C01%7C%7Cd76993cb5bcf49efdea308da6907ca14%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637937779413058634%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=m7%2BrICj2Sl8Ql9veBosmyWCk%2Fu7UFBtwAbnBBXiPfms%3D&reserved=0>.

On Mon, Jul 18, 2022, at 17:22, Jacques Nadeau wrote:
For general reference I believe NoClassDefFoundError also occurs when the 
static initialization block of the required class fails to initialize. In 
general, it's best to wrap any static initialization block with a failure catch 
that prints/logs the issues before throwing so you aren't struggling like this. 
We should open a ticket to make this change if we a place where that isn't 
happening. It looks like MemoryUtil's initialization block doesn't handle this. 
(It tries to throw.) I believe that in some cases (all cases?) those throws are 
swallowed and the NoClassDefFoundError is thrown instead.

On Mon, Jul 18, 2022 at 1:22 PM David Dali Susanibar Arce 
<[email protected]<mailto:[email protected]>> wrote:
Hi Olo,

Please if you could try to execute your project by command line (main class 
name example: TestMyFlightConsumer)

$ cd <wks>
$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home
$ java --version
openjdk 17.0.3 2022-04-19 LTS
OpenJDK Runtime Environment Zulu17.34+19-CA (build 17.0.3+7-LTS)
OpenJDK 64-Bit Server VM Zulu17.34+19-CA (build 17.0.3+7-LTS, mixed mode, 
sharing)
$ mvn -q dependency:build-classpath -DincludeTypes=jar 
-Dmdep.outputFile=localtest.cp.tmp
$ javac --add-opens=java.base/java.nio=ALL-UNNAMED 
src/main/java/TestMyFlightConsumer.java --class-path `cat 
localtest.cp.tmp`:target/classes
$ java --add-opens=java.base/java.nio=ALL-UNNAMED --class-path `cat 
localtest.cp.tmp`:target/classes TestMyFlightConsumer

Please let us know what errors you see now.

David

El lun, 18 jul 2022 a las 12:41, Olo Sawyerr 
(<[email protected]<mailto:[email protected]>>) escribió:
Hi,

I'm using Java 17. But compiled to target JDK 11 binary.

/Users/olo/Library/Java/JavaVirtualMachines/azul-17.0.3/

Strange thing is that the org.apache.arrow.memory.util.MemoryUtil class appears 
in the debugger. But when it calls MemoryUtil.directBuffer(address, length) it 
gives the java.lang.NoClassDefFoundError

Yes I'm also passing the flags -

--add-opens=java.base/java.nio=ALL-UNNAMED

Regards,

Olo


________________________________

From: David Li <[email protected]<mailto:[email protected]>>
Sent: 18 July 2022 18:01
To: dl <[email protected]<mailto:[email protected]>>
Subject: Re: [JAVA] java.lang.NoClassDefFoundError: Could not initialize class 
org.apache.arrow.memory.util.MemoryUtil

Hi,

It's specifically "could not initialize class", is there other output?

Most likely I'd guess you're on Java 9+, are all the necessary flags passed to 
java to enable unsafe memory on this version? 
https://arrow.apache.org/docs/dev/java/install.html#java-compatibility<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Farrow.apache.org%2Fdocs%2Fdev%2Fjava%2Finstall.html%23java-compatibility&data=05%7C01%7C%7Cd76993cb5bcf49efdea308da6907ca14%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637937779413058634%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=zRLyl5i4k7iPSghdn8P812gxvi1nDcoDfLb%2B9AP7Gmw%3D&reserved=0>

-David

On Mon, Jul 18, 2022, at 12:56, Olo Sawyerr wrote:
Hi,

I'm trying to use arrow flight and keep getting this exception below when 
calling flightClient.getStream() - java.lang.NoClassDefFoundError: Could not 
initialize class org.apache.arrow.memory.util.MemoryUtil

It's quite odd because I have arrow-memory-core defined in my pom. I'm using 
v8.0.0. Any ideas what this could be? I'm running this in IntelliJ.

Code:


try (var allocator = new RootAllocator(); var flightClient = 
FlightClient.builder(allocator, location).build()) {
    var flightStream = flightClient.getStream(ticket);
    if (flightStream.next()) {
        retval = flightStream.getRoot();
    }
}

StackTrace:

2022-07-18T17:29:58.075+0100  INFO  grpc-default-executor-11      stderr      
java.lang.NoClassDefFoundError: Could not initialize class 
org.apache.arrow.memory.util.MemoryUtil

2022-07-18T17:29:58.076+0100  INFO  grpc-default-executor-11      stderr        
    at org.apache.arrow.memory.ArrowBuf.getDirectBuffer(ArrowBuf.java:228)

2022-07-18T17:29:58.077+0100  INFO  grpc-default-executor-11      stderr        
    at org.apache.arrow.memory.ArrowBuf.nioBuffer(ArrowBuf.java:223)

2022-07-18T17:29:58.077+0100  INFO  grpc-default-executor-11      stderr        
    at 
org.apache.arrow.flight.grpc.GetReadableBuffer.readIntoBuffer(GetReadableBuffer.java:91)

2022-07-18T17:29:58.078+0100  INFO  grpc-default-executor-11      stderr        
    at org.apache.arrow.flight.ArrowMessage.frame(ArrowMessage.java:319)

2022-07-18T17:29:58.079+0100  INFO  grpc-default-executor-11      stderr        
    at org.apache.arrow.flight.ArrowMessage.access$100(ArrowMessage.java:68)

2022-07-18T17:29:58.079+0100  INFO  grpc-default-executor-11      stderr        
    at 
org.apache.arrow.flight.ArrowMessage$ArrowMessageHolderMarshaller.parse(ArrowMessage.java:551)

2022-07-18T17:29:58.079+0100  INFO  grpc-default-executor-11      stderr        
    at 
org.apache.arrow.flight.ArrowMessage$ArrowMessageHolderMarshaller.parse(ArrowMessage.java:536)

2022-07-18T17:29:58.079+0100  INFO  grpc-default-executor-11      stderr        
    at io.grpc.MethodDescriptor.parseResponse(MethodDescriptor.java:284)

2022-07-18T17:29:58.080+0100  INFO  grpc-default-executor-11      stderr        
    at 
io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInternal(ClientCallImpl.java:661)

2022-07-18T17:29:58.080+0100  INFO  grpc-default-executor-11      stderr        
    at 
io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInContext(ClientCallImpl.java:646)

2022-07-18T17:29:58.080+0100  INFO  grpc-default-executor-11      stderr        
    at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)

2022-07-18T17:29:58.081+0100  INFO  grpc-default-executor-11      stderr        
    at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)

2022-07-18T17:29:58.081+0100  INFO  grpc-default-executor-11      stderr        
    at 
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)

2022-07-18T17:29:58.081+0100  INFO  grpc-default-executor-11      stderr        
    at 
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)


Reply via email to