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

Update make and pom for java directory reorganization #2

Open
pshareghi opened this issue Mar 24, 2015 · 2 comments
Open

Update make and pom for java directory reorganization #2

pshareghi opened this issue Mar 24, 2015 · 2 comments

Comments

@pshareghi
Copy link

RocksJava directory structure was changed recently. Please make the following modifications to your code.

Makefile

diff --git a/Makefile b/Makefile
index 53d0cb8..fad2a52 100644
--- a/Makefile
+++ b/Makefile
@@ -11,12 +11,12 @@ endif
 NATIVE_JAVA_CLASSES = org.rocksdbprotobuf.ProtobufMergeOperator

 JAR = java/rocksdbprotobuf.jar
-CLASSPATH =  java/protobuf-java-2.5.0.jar:${ROCKSDB_BASE}/java
+CLASSPATH =  java/protobuf-java-2.5.0.jar:${ROCKSDB_BASE}/java/target/classes

 SOURCES = src/main/cpp/protobuf_merge.cc \
              src/main/cpp/protobuf_logger.cc \
              proto/message_base.pb.cc \
-                 proto/prototest.pb.cc \
+             proto/prototest.pb.cc \
              proto/merge.pb.cc

 JNI_SOURCES = src/main/cpp/jni/org_rocksdbprotobuf_protobuf_merge_operator.cc
@@ -26,7 +26,7 @@ TEST_DATABASE_SOURCES = src/test/cpp/test_database.cc

 INCLUDE = -I$(ROCKSDB_BASE) -I$(ROCKSDB_BASE)/include -I$(PROTOBUF_BASE)/include \
        -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux -I./include \
-       -I$(ROCKSDB_BASE)/java  -I./proto
+       -I$(ROCKSDB_BASE)/java/target  -I./proto

 OPT = -std=c++11 -pthread

@@ -99,7 +99,7 @@ $(JNILIBRARY): $(JNILIBOBJECTS)
        mvn     compile
        javah -classpath target/classes -d ./include/rocksdb_protobuf -jni $(NATIVE_JAVA_CLASSES)
        rm -f $@
-       $(CXX) -shared -fPIC -static-libstdc++ -static-libgcc -o $@ -L$(ROCKSDB_BASE)/java/ -lrocksdbjni-linux64 $(JNILIBOBJECTS) $(LDFLAGS)
+       $(CXX) -shared -fPIC -static-libstdc++ -static-libgcc -o $@ -L$(ROCKSDB_BASE)/java/target -lrocksdbjni-linux64 $(JNILIBOBJECTS) $(LDFLAGS)

 library-java: $(JNILIBRARY)

pom.xml

diff --git a/pom.xml b/pom.xml
index 3da4571..efa918e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -47,7 +47,7 @@
     </plugins>
     <resources>
       <resource>
-        <directory>rocksdb/java</directory>
+        <directory>rocksdb/java/target/classes</directory>
       </resource>
       <resource>
         <filtering>false</filtering>
@pshareghi
Copy link
Author

After making these modifications in the Docker container, I was able to compile and generate the jar file. However, because of the directory re-organization I get the following error

Exception in thread "main" java.lang.ExceptionInInitializerError
    at Test.<clinit>(Test.java:17)
Caused by: java.lang.RuntimeException: librocksdbjni-linux64.so was not found inside JAR.

I looked in th jar file, and the lib is in fact there, but notice it is under target because of the re-organization above. Please fix it in your Makefile or your pom.xml

target/librocksdbjni-linux64.so

@pshareghi
Copy link
Author

You can use my github branch since it is more up-to-date. pshareghi/rocksdb,

See my email for more info

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

No branches or pull requests

1 participant