Repository navigation
Open
Labels
feature-requestRequest for a new featureRequest for a new feature
Description
Before opening, please confirm:
- I have searched for duplicate or closed issues.
- I have read the guide for submitting bug reports.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
Bug Category
Other
Describe the bug
The attempt to execute simple Java application with cedar-java-uber dependency
<dependency>
<groupId>com.cedarpolicy</groupId>
<artifactId>cedar-java</artifactId>
<classifier>uber</classifier>
<version>4.3.0</version>
</dependency>
on Windows 10 environment fails with UnsatisfiedLinkError. Looks like the dll does not export the Java functions.
Probably the cause can be in zigbuild usage.
For the bundled dll the dumpbin shows
dumpbin /EXPORTS dlls/original/cedar_java_ffi.dll
Microsoft (R) COFF/PE Dumper Version 14.42.34436.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file dlls\original\cedar_java_ffi.dll
File Type: DLL
Section contains the following exports for cedar_java_ffi.dll
00000000 characteristics
0 time date stamp
0.00 version
1 ordinal base
33 number of functions
33 number of names
ordinal hint RVA name
1 0 002A58D0 _GCC_specific_handler
2 1 008E67C0 _Unwind_Backtrace
3 2 008FB940 _Unwind_DeleteException
4 3 008E6750 _Unwind_FindEnclosingFunction
5 4 008E6830 _Unwind_Find_FDE
6 5 002A6050 _Unwind_ForcedUnwind
7 6 008E68C0 _Unwind_GetCFA
8 7 008E66B0 _Unwind_GetDataRelBase
9 8 008FB960 _Unwind_GetGR
10 9 008FB990 _Unwind_GetIP
11 A 008E68F0 _Unwind_GetIPInfo
12 B 002A60B0 _Unwind_GetLanguageSpecificData
13 C 002A60C0 _Unwind_GetRegionStart
14 D 008E6700 _Unwind_GetTextRelBase
15 E 002A5D80 _Unwind_RaiseException
16 F 002A5DC0 _Unwind_Resume
17 10 008E6640 _Unwind_Resume_or_Rethrow
18 11 008FB980 _Unwind_SetGR
19 12 008FB9C0 _Unwind_SetIP
20 13 00904760 unw_get_fpreg
21 14 00904830 unw_get_proc_info
22 15 00904880 unw_get_proc_name
23 16 00904690 unw_get_reg
24 17 00904AD4 unw_getcontext
25 18 00904660 unw_init_local
26 19 009048B0 unw_is_fpreg
27 1A 009048E0 unw_is_signal_frame
28 1B 00DB76C0 unw_local_addr_space
29 1C 009048D0 unw_regname
30 1D 00904860 unw_resume
31 1E 009047A0 unw_set_fpreg
32 1F 009046D0 unw_set_reg
33 20 009047F0 unw_step
Summary
D000 .data
1000 .eh_fram
47000 .pdata
2A0000 .rdata
12000 .reloc
B0D000 .text
1000 .tls
The same Java code works successfully with cedar_java_ffi.dll built locally using
cargo build --features partial-eval --release --target x86_64-pc-windows-gnu
and forced using CEDAR_JAVA_FFI_LIB env variable.
The dumpbin for this dll shows the exported Java functions
dumpbin /EXPORTS dlls/cargo_build/cedar_java_ffi.dll
Microsoft (R) COFF/PE Dumper Version 14.42.34436.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file dlls\cargo_build\cedar_java_ffi.dll
File Type: DLL
Section contains the following exports for cedar_java_ffi.dll
00000000 characteristics
67C9C304 time date stamp Thu Mar 6 18:45:08 2025
0.00 version
1 ordinal base
14 number of functions
14 number of names
ordinal hint RVA name
1 0 00019870 Java_com_cedarpolicy_BasicAuthorizationEngine_callCedarJNI
2 1 0001A030 Java_com_cedarpolicy_BasicAuthorizationEngine_getCedarJNIVersion
3 2 0001E880 Java_com_cedarpolicy_formatter_PolicyFormatter_policiesStrToPretty
4 3 0001B2D0 Java_com_cedarpolicy_model_policy_PolicySet_parsePoliciesJni
5 4 0001AC80 Java_com_cedarpolicy_model_policy_Policy_parsePolicyJni
6 5 0001C370 Java_com_cedarpolicy_model_policy_Policy_parsePolicyTemplateJni
7 6 0001CA10 Java_com_cedarpolicy_model_policy_Policy_toJsonJni
8 7 0001A720 Java_com_cedarpolicy_model_schema_Schema_parseCedarSchemaJni
9 8 0001A190 Java_com_cedarpolicy_model_schema_Schema_parseJsonSchemaJni
10 9 0001D430 Java_com_cedarpolicy_value_EntityIdentifier_getEntityIdentifierRepr
11 A 0001DB00 Java_com_cedarpolicy_value_EntityTypeName_getEntityTypeNameRepr
12 B 0001D7C0 Java_com_cedarpolicy_value_EntityTypeName_parseEntityTypeName
13 C 0001E1B0 Java_com_cedarpolicy_value_EntityUID_getEUIDRepr
14 D 0001DE50 Java_com_cedarpolicy_value_EntityUID_parseEntityUID
Summary
1000 .CRT
3000 .bss
1000 .data
1000 .edata
1000 .eh_fram
2000 .idata
43000 .pdata
189000 .rdata
10000 .reloc
9E7000 .text
1000 .tls
FF000 .xdata
Expected behavior
The code works with bundled windows dll
Reproduction steps
See description
Code Snippet
package org.example;
import com.cedarpolicy.model.exception.InternalException;
import com.cedarpolicy.model.policy.PolicySet;
public class Main {
public static void main(String[] args) throws InternalException {
PolicySet.parsePolicies("");
}
}Log output
Exception in thread "main" java.lang.UnsatisfiedLinkError: 'com.cedarpolicy.model.policy.PolicySet com.cedarpolicy.model.policy.PolicySet.parsePoliciesJni(java.lang.String)'
at com.cedarpolicy.model.policy.PolicySet.parsePoliciesJni(Native Method)
at com.cedarpolicy.model.policy.PolicySet.parsePolicies(PolicySet.java:128)
at org.example.Main.main(Main.java:8)
Additional configuration
No response
Operating System
Windows 10
Additional information and screenshots
No response
Reacted by abalabolov
Metadata
Metadata
Assignees
Labels
feature-requestRequest for a new featureRequest for a new feature
Activity
[-]UnsatisfiedLinkError on Windows with bundled native cedar_java_ffi.dll[/-][+]UnsatisfiedLinkError on Windows with bundled cedar_java_ffi.dll[/+]01epa commentedon Mar 7, 2025
Got the same issue om my local windows machine
muditchaudhary commentedon Mar 25, 2025
Thank you for pointing this out. We are looking into this and will provide an update soon.
vixmemon commentedon Mar 26, 2025
Facing the same issue in Linux
java.runtime.version=17.0.14+7-LTS,
os.version=6.1.128,
java.runtime.name=OpenJDK Runtime Environment,
java.vm.vendor=Red Hat, Inc.,
sun.arch.data.model=64,
Caused by: java.lang.UnsatisfiedLinkError: Unable to cleanly find (or extract) library [cedar_java_ffi] as resource
at com.fizzed.jne.JNE.loadLibrary(JNE.java:259) ~[jne-4.1.1.jar!/:4.1.1]
at com.fizzed.jne.JNE.loadLibrary(JNE.java:225) ~[jne-4.1.1.jar!/:4.1.1]
at com.cedarpolicy.loader.LibraryLoader.loadLibrary(LibraryLoader.java:41) ~[cedar-java-4.2.3-uber.jar!/:na]
at com.cedarpolicy.value.EntityTypeName.(EntityTypeName.java:41) ~[cedar-java-4.2.3-uber.jar!/:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:258) ~[spring-core-6.1.16.jar!/:6.1.16]
org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:348) ~[spring-context-6.1.16.jar!/:6.1.16]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:146) ~[spring-beans-6.1.16.jar!/:6.1.16]
... 41 common frames omitted
muditchaudhary commentedon Mar 27, 2025
@vixmemon Your issue might be related to #279. It was resolved in release 4.3. Can you try updating your CedarJava to the latest version (4.3.1) and see if that resolves your issue.
vixmemon commentedon Mar 27, 2025
I have tried latest version. this issue is in latest version @muditchaudhary
muditchaudhary commentedon Mar 27, 2025
@vixmemon Can you create a separate issue for the problem you have been encountering with more details (E.g., CedarJava version, OS, Arch, etc.). The issue with linking in Windows is because of a different problem. Thanks!
vixmemon commentedon Mar 27, 2025
new bug created #314
vixmemon commentedon Mar 28, 2025
I tested it on both,
on windows and on linux.
Linux is the environment where our applications are deployed, while development goes on in Windows.
muditchaudhary commentedon Mar 28, 2025
@vixmemon Could you confirm if you're getting the exact same error on both Linux and Windows machines? I ask because CedarJava handles platforms differently - on Windows it looks for the DLL file for
cedar-java-ffi, while on Linux it looks for the.sofile.For Windows, you might be using this workaround (You should not use this workaround on Linux):
cargo build --features partial-eval --release --target x86_64-pc-windows-gnuCEDAR_JAVA_FFI_LIBenvironment variable to use the generated DLLAre you using this same Windows-specific approach on Linux? Could you share what steps you're taking specifically for Linux, so that I can recreate this issue? This would help us troubleshoot the issue.
vixmemon commentedon Mar 28, 2025
Facing same issue on linux with latest -uber dependency.
Also tried 'com.cedarpolicy:cedar-java:4.3.1:uber'
Issue in Linux
Caused by: java.lang.UnsatisfiedLinkError: Unable to cleanly find (or extract) library [cedar_java_ffi] as resource
at com.fizzed.jne.JNE.loadLibrary(JNE.java:259) ~[jne-4.1.1.jar!/:4.1.1]
at com.fizzed.jne.JNE.loadLibrary(JNE.java:225) ~[jne-4.1.1.jar!/:4.1.1]
at com.cedarpolicy.loader.LibraryLoader.loadLibrary(LibraryLoader.java:41) ~[cedar-java-4.2.3-uber.jar!/:na]
at com.cedarpolicy.value.EntityTypeName.(EntityTypeName.java:41) ~[cedar-java-4.2.3-uber.jar!/:na]
I tried to use the .so file by using environment variable and absolute path of the .so file.
Caused by: java.lang.UnsatisfiedLinkError: /opt/libcedar_java_ffi.so: /opt/libcedar_java_ffi.so: cannot open shared object file: No such file or directory (Possible cause: can't load AARCH64 .so on a AMD 64 platform)
A working .so file for AMD64 arch for linux would be helpful
muditchaudhary commentedon Mar 28, 2025
Got it. Let me try it on an AMD64 machine and get back to you.
muditchaudhary commentedon Mar 28, 2025
@vixmemon I tried running this cedar-java example on a Linux AMD64 machine (which is an x86_64 architecture) and I wasn't able to recreate the error you have been receiving.
I followed the steps below to check if CedarJava works on my Linux AMD64 machine:
Can you try running this exact same example on your Linux machine and let us know if you are still getting the error. If you still see the same error, can you share the output of
lscpucommand? Thanks!vixmemon commentedon Mar 28, 2025
@muditchaudhary i tested again on linux with 4.3.1 and it worked for me. So let's fix windows issue maybe.
muditchaudhary commentedon Apr 7, 2025
After investigation, we found that while native library bundling was implemented in #104, it was not tested for Windows environments and has not functioned on that platform since implementation. Rather than treating this as a bug fix, we've categorized it as a potential future enhancement. While we don't have a specific timeline for implementing Windows support, we welcome community contributions.
Temporary Workaround for Windows Users:
CEDAR_JAVA_FFI_LIBenvironment variable to point to the generated DLLWe'll keep this issue open to track progress on proper Windows support for native library bundling.
abalabolov commentedon Jul 24, 2025
Hello
Any updates?
we've categorized it as a potential future enhancementwas not a good idea.This is built CedarJavaFFI using solution above. It contains exported Java functions and works.
It is
.7zso replace.zipto.7zbefore usage because Github doesn't allow to upload.7z.cedar_java_ffi.zip
Another issue is that principal in [Role::"X", Role::"Y"] doesn't work for any OS libs. Claude says: "Cedar's Java JNI binding doesn't support the set notation [Role::"X", Role::"Y"] in the principal position. This is a limitation of the Java Cedar library (the Rust/native Cedar supports it)."
raja777m commentedon Feb 10, 2026
can we make the dll work on linux environment, because I have some tests that are failing because the Cedar native library (cedar_java_ffi) for Linux is missing. My libs folder only contains the Windows DLL which you provided, but my CI runs on Linux.
Linux: libcedar_java_ffi.so is missing.
I had to skip the tests for the time being.
muditchaudhary commentedon Feb 11, 2026
@abalabolov Unfortunately, we are unable to prioritize windows cross-platform support. We have added additional instructions for the users to build CedarJava for Windows locally. Apologies for any inconvenience.
This is not a Cedar feature. Principals and Resources do not support
inoperation with set notation.For reference, below is the Cedar policy grammar for
Principal. [Cedar policy grammar]muditchaudhary commentedon Feb 11, 2026
@raja777m
Thank you for reaching out. No, DLLs cannot be supported on Linux.
To help you further, a few questions:
CedarJavafor a Linux platform or do you only need to support it for Windows?CedarJavaas a dependency from Maven or are you buildingCedarJavafrom source in the CI process? If you are building it from the source, is there a particular reason why you want to buildCedarJavafrom source?raja777m commentedon Feb 23, 2026
May I know your setup (OS, Architecture) for CI? My PIP API is configured on lambdas. so, when the end points get hit, it spuns out a lambda.
Are you planning to serve CedarJava for a Linux platform or do you only need to support it for Windows? no windows app, my apps are linux based only.
Are you consuming CedarJava as a dependency from Maven - yes, I tried the 4.8.0 uber gradle dependency and have the same issue as this ticket.
so, I used uber jar, excluded the ffi.dll that comes with it, and included in the libs folder and calling it from the build.gradle
the thing is, I did not test the ...ffi.so that came with the 4.8.0:uber. Will test it this week and update if I have any further issues.