sangkeon / java-opa-wasm

Apache License 2.0
15 stars 2 forks source link

compilation error with java-opa-wasm:0.2.2 #9

Closed rai-prashanna closed 1 year ago

rai-prashanna commented 1 year ago

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.0:compile (default-compile) on project performanceTesting: Compilation failure

cannot access io.github.kawamuray.wasmtime.Disposable [ERROR] class file for io.github.kawamuray.wasmtime.Disposable not found

I would appreciate your help. Thanks!

rai-prashanna commented 1 year ago

I don't get compilation error after adding following dependency in pom.xml

io.github.kawamuray.wasmtime wasmtime-java 0.14.0

however, the following lines of code never get executed.
om.loadEntrypoints(); String decision=om.evaluate(inputJson,"authz/policy/allow");

sangkeon commented 1 year ago

call om.loadEntrypoints() before evaluate() no more required.

If you want to check multiple entrypoints correctly loaded, check returned value of om.getEntrypoints().

Code: System.out.println(om.getEntrypoints()); Result: {opa/wasm/test/allowed=0}

Check "authz/policy/allow" exists.

sangkeon commented 1 year ago

I tested multiple entrypoints, there's no problem.

rai-prashanna commented 1 year ago

@sangkeon This is the compilation error I get in my environment. Tested on OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode), OPA 0.52.0 version error I created a repo that does interaction with wasm binary using opa-java-wasm library in Java. link to the GitHub repo is https://github.com/rai-prashanna/test-opa-java-wasm

sangkeon commented 1 year ago

It's maven dependency scope issue.

Fixed in 0.2.3.

rai-prashanna commented 1 year ago

@sangkeon Now, i don't get any compilation error but executions skip from the initialization of OPAModule without executing evaluate method. When I added breakpoints, I could see that execution is happening till line 77 of OPAModule.class but after that execution exits from there as can be seen in this pictures also. So execution happens never to this line om.evaluate(inputJson,"authz/policy/allow"); image second picture of execution is as follows image

My wasm binary is in this bundle

bundle.tar.gz

sangkeon commented 1 year ago

result In my pc, your bundle works and returns result=[{"result":false}]

change your input string to "" and evaluate() called.

If it called and return result, it's input format issue.

sangkeon commented 1 year ago

Try to change JDK, json library and etc.

rai-prashanna commented 1 year ago

Thanks for your prompt response. I wrote code like you did in picture. I experiment with JDK 8 and JDK 11. None of them work.
Now, I get a different error. image My glibc version is image

My os version is VERSION= ubuntu "20.04.6 LTS (Focal Fossa)"

sangkeon commented 1 year ago

Use java-opa-wasm 0.2.3_glibc2.31 version. (just downgraded wasmtime-java 0.14.0 to 0.13.0)

https://central.sonatype.com/artifact/io.github.sangkeon/java-opa-wasm/0.2.3_glibc2.31/versions

rai-prashanna commented 1 year ago

Thanks! Now, it works!