ChronicleMap issue in JavaEE app

405 views Asked by At

I successfully upgraded a JavaSE8 app to the ChronicleMap 3.14.1. I have a JavaEE7 app that is just a facade to the JavaSE8 app.

When calling a method from JavaEE7 for creating a chronicleMap, a bug is raised. It looks like "net.openhft.chronicle.hash.impl.util.jna.PosixMsync" is not loaded!

This bug is not raised in JavaSE8 app.

Any fix or suggestion is welcome.

Thanks in advance.

java.lang.NoSuchFieldError: C_LIBRARY_NAME at net.openhft.chronicle.hash.impl.util.jna.PosixMsync.(PosixMsync.java:39) at net.openhft.chronicle.hash.impl.VanillaChronicleHash.msync(VanillaChronicleHash.java:878) at net.openhft.chronicle.hash.impl.VanillaChronicleHash.msync(VanillaChronicleHash.java:864) at net.openhft.chronicle.map.ChronicleMapBuilder.commitChronicleMapReady(ChronicleMapBuilder.java:417) at net.openhft.chronicle.map.ChronicleMapBuilder.createWithNewFile(ChronicleMapBuilder.java:1732) at net.openhft.chronicle.map.ChronicleMapBuilder.createWithFile(ChronicleMapBuilder.java:1589) at net.openhft.chronicle.map.ChronicleMapBuilder.recoverPersistedTo(ChronicleMapBuilder.java:1532) at net.openhft.chronicle.map.ChronicleMapBuilder.createOrRecoverPersistedTo(ChronicleMapBuilder.java:1515) at net.openhft.chronicle.map.ChronicleMapBuilder.createOrRecoverPersistedTo(ChronicleMapBuilder.java:1506) at net.openhft.chronicle.map.ChronicleMapBuilder.createOrRecoverPersistedTo(ChronicleMapBuilder.java:1500) at com.kem.ae.util.Utilities.mapBuilder(Utilities.java:125)

Exception is raised at : builder.createOrRecoverPersistedTo(mapFile);

 public static <K, V> Map<K, V> mapBuilder(Class<K> key, Class<V> value, Param param, File mapFile) {

            ChronicleMapBuilder<K, V> builder = ChronicleMapBuilder.of(key, value)
                    .entries(param.getTotalSeq());

            if (key != Integer.class) {
                builder = builder.averageKeySize(param.getEntrySize()
                        * (Exception.class.isAssignableFrom(value) ? 4 : 2));
            }

            if (value != Double.class) {
                builder = builder.averageValueSize(param.getEntrySize()
                        * (Exception.class.isAssignableFrom(value) ? 4 : 2));
            }

            if (mapFile == null) {
//                log.info("create in-memory off-heap map");
                return builder.create();
            } else {
                try {
//                    log.info("create persisted off-heap map");
                    return builder.createOrRecoverPersistedTo(mapFile);
                } catch (IOException ex) {
                    log.error(ex.getMessage(), ex);
                    return new ConcurrentHashMap<>();
                }
            }
        }
1

There are 1 answers

2
Mark Price On BEST ANSWER

Can you check whether there is another version of jna on your classpath when running in the javaEE container?

Chronicle-Map is built against version 4.4.0 of jna; if your container has a different version on the classpath, that could be a reason for the exception you can see.