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

java.lang.NoClassDefFoundError when java.io.tmpdir is not writable #1332

Closed
apurvam opened this issue May 22, 2018 · 5 comments
Closed

java.lang.NoClassDefFoundError when java.io.tmpdir is not writable #1332

apurvam opened this issue May 22, 2018 · 5 comments

Comments

@apurvam
Copy link
Contributor

apurvam commented May 22, 2018

KSQL leverages RocksDB which includes a C library. As part of the startup process of RocksDB, it has to extract the C library before it can be used. The location to extract the C library is determined by the java.io.tmpdir system property or ROCKSDB_SHAREDLIB_DIR environment variable.

If this directory is not writable, then the user will see an error like Could not initialize class org.rocksdb.Options when running a query which needs a state store.

Here is an example failure mode:

$ ls | grep javatmp
drwxr-xr-x    2 apurva  staff     64 May 22 12:12 javatmp
$ KSQL_OPTS="-Djava.io.tmpdir=/Users/apurva/javatmp/" ./bin/ksql-server-start etc/ksql/ksql-server.properties
$ ./bin/ksql
... Welcome message ...
ksql> CREATE TABLE users_original (registertime BIGINT, gender VARCHAR, regionid VARCHAR, userid VARCHAR) WITH (kafka_topic='users', value_format='JSON', key = 'userid');

 Message
---------------
 Table created
---------------
ksql> select * from users_original;
Could not initialize class org.rocksdb.Options
Query terminated
ksql>
$ less ksql-server.log
[2018-05-22 12:15:32,702] ERROR Exception occurred while writing to connection stream:  (io.confluent.ksql.rest.server.resources.streaming.QueryStreamWriter:105)
java.lang.NoClassDefFoundError: Could not initialize class org.rocksdb.Options
        at org.apache.kafka.streams.state.internals.RocksDBStore.openDB(RocksDBStore.java:116)
        at org.apache.kafka.streams.state.internals.RocksDBStore.init(RocksDBStore.java:167)
        at 

If the user runs into this, the best solution is to set java.io.tmpdir to a directory which is writable by all users.

In the above example executing chmod +w javatmp fixes the issue.

@surajkb74
Copy link

surajkb74 commented May 23, 2018

After following the instruction it worked...

@parth22594
Copy link

After follow this step. Got following error.

java.lang.UnsatisfiedLinkError: /tmp/tmpjava/librocksdbjni1513379826889322410.so: libstdc++.so.6: cannot open shared object file: No such file or directory
Caused by: /tmp/tmpjava/librocksdbjni1513379826889322410.so: libstdc++.so.6: cannot open shared object file: No such file or directory
Query terminated

@agavra
Copy link
Contributor

agavra commented Oct 16, 2019

I think we should provide a more actionable error message by checking the permissions on the directory eagerly. Adding the fix-it-week label to this to make sure it gets tracked.

@ntsh999
Copy link

ntsh999 commented Jul 13, 2020

I also received the same error message as mentioned in the org post. After applying the suggested fix chmod +w tmp and chmod +w /var/tmp on my temp directories I get the following error message. I am using confluent platform v 5.4.1 and OS is Ubuntu 18 with CIS hardened image from Azure.

 java.lang.NoClassDefFoundError: Could not initialize class org.rocksdb.DBOptions
        at org.apache.kafka.streams.state.internals.RocksDBStore.openDB(RocksDBStore.java:133)
        at org.apache.kafka.streams.state.internals.KeyValueSegment.openDB(KeyValueSegment.java:49)
        at org.apache.kafka.streams.state.internals.KeyValueSegments.getOrCreateSegment(KeyValueSegments.java:50)
        at org.apache.kafka.streams.state.internals.KeyValueSegments.getOrCreateSegment(KeyValueSegments.java:25)
        at org.apache.kafka.streams.state.internals.AbstractSegments.getOrCreateSegmentIfLive(AbstractSegments.java:84)
        at org.apache.kafka.streams.state.internals.AbstractRocksDBSegmentedBytesStore.put(AbstractRocksDBSegmentedBytesStore.java:148)
        at org.apache.kafka.streams.state.internals.RocksDBWindowStore.put(RocksDBWindowStore.java:61)
        at org.apache.kafka.streams.state.internals.RocksDBWindowStore.put(RocksDBWindowStore.java:27)
        at org.apache.kafka.streams.state.internals.ChangeLoggingWindowBytesStore.put(ChangeLoggingWindowBytesStore.java:111)
        at org.apache.kafka.streams.state.internals.ChangeLoggingWindowBytesStore.put(ChangeLoggingWindowBytesStore.java:34)
        at org.apache.kafka.streams.state.internals.MeteredWindowStore.put(MeteredWindowStore.java:186)
        at org.apache.kafka.streams.processor.internals.ProcessorContextImpl$WindowStoreReadWriteDecorator.put(ProcessorContextImpl.java:535)
        at org.apache.kafka.streams.kstream.internals.KStreamJoinWindow$KStreamJoinWindowProcessor.process(KStreamJoinWindow.java:57)
        at org.apache.kafka.streams.processor.internals.ProcessorNode.process(ProcessorNode.java:118)
        at org.apache.kafka.streams.processor.internals.ProcessorContextImpl.forward(ProcessorContextImpl.java:201)
        at org.apache.kafka.streams.processor.internals.ProcessorContextImpl.forward(ProcessorContextImpl.java:180)
        at org.apache.kafka.streams.processor.internals.ProcessorContextImpl.forward(ProcessorContextImpl.java:133)
        at org.apache.kafka.streams.processor.internals.SourceNode.process(SourceNode.java:87)
        at org.apache.kafka.streams.processor.internals.StreamTask.process(StreamTask.java:432)
        at org.apache.kafka.streams.processor.internals.AssignedStreamsTasks.process(AssignedStreamsTasks.java:474)
        at org.apache.kafka.streams.processor.internals.TaskManager.process(TaskManager.java:536)
        at org.apache.kafka.streams.processor.internals.StreamThread.runOnce(StreamThread.java:792)
        at org.apache.kafka.streams.processor.internals.StreamThread.runLoop(StreamThread.java:698)
        at org.apache.kafka.streams.processor.internals.StreamThread.run(StreamThread.java:671)

mcascallares added a commit to mcascallares/ksql that referenced this issue Jan 26, 2021
Added scenario for java.lang.NoClassDefFoundError when java.io.tmpdir is not writable. 
For more information: confluentinc#1332
@JimGalasyn JimGalasyn self-assigned this Jan 26, 2021
agavra pushed a commit that referenced this issue Jan 26, 2021
Added scenario for java.lang.NoClassDefFoundError when java.io.tmpdir is not writable. 
For more information: #1332

Co-authored-by: Jim Galasyn <jim.galasyn@confluent.io>
@JimGalasyn
Copy link
Member

Fixed in #6897.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants