2

I've encountered the following exception in an application that is being built with Gradle and uses AspectJ. The app works fine when started from within Eclipse but fails to start once built with Gradle:

Caused by: java.lang.AssertionError: java.lang.ClassNotFoundException: net.openhft.chronicle.hash.VanillaGlobalMutableState$$Native
at net.openhft.chronicle.values.ValueModel.createClass(ValueModel.java:313) ~[chronicle-values-1.0.3-alpha.jar!/:na]
at net.openhft.chronicle.values.ValueModel.createNativeClass(ValueModel.java:286) ~[chronicle-values-1.0.3-alpha.jar!/:na]
at net.openhft.chronicle.values.ValueModel.nativeClass(ValueModel.java:268) ~[chronicle-values-1.0.3-alpha.jar!/:na]
at net.openhft.chronicle.values.Values.nativeClassFor(Values.java:51) ~[chronicle-values-1.0.3-alpha.jar!/:na]
at net.openhft.chronicle.values.Values.newNativeReference(Values.java:38) ~[chronicle-values-1.0.3-alpha.jar!/:na]
at net.openhft.chronicle.hash.impl.VanillaChronicleHash.createGlobalMutableState(VanillaChronicleHash.java:324) ~[chronicle-map-3.5.0-rc.jar!/:3.5.0-rc]
at net.openhft.chronicle.hash.impl.VanillaChronicleHash.initOwnTransients(VanillaChronicleHash.java:373) ~[chronicle-map-3.5.0-rc.jar!/:3.5.0-rc]
at net.openhft.chronicle.hash.impl.VanillaChronicleHash.initTransients(VanillaChronicleHash.java:369) ~[chronicle-map-3.5.0-rc.jar!/:3.5.0-rc]
at net.openhft.chronicle.map.VanillaChronicleMap.initTransients(VanillaChronicleMap.java:146) ~[chronicle-map-3.5.0-rc.jar!/:3.5.0-rc]
at net.openhft.chronicle.map.VanillaChronicleMap.<init>(VanillaChronicleMap.java:102) ~[chronicle-map-3.5.0-rc.jar!/:3.5.0-rc]
at net.openhft.chronicle.map.ChronicleMapBuilder.newMap(ChronicleMapBuilder.java:1703) ~[chronicle-map-3.5.0-rc.jar!/:3.5.0-rc]
at net.openhft.chronicle.map.ChronicleMapBuilder.lambda$createWithFile$93(ChronicleMapBuilder.java:1449) ~[chronicle-map-3.5.0-rc.jar!/:3.5.0-rc]
at net.openhft.chronicle.map.ChronicleMapBuilder$$Lambda$7/78866071.fileIOAction(Unknown Source) ~[na:na]
at net.openhft.chronicle.map.ChronicleMapBuilder.lambda$fileLockedIO$92(ChronicleMapBuilder.java:182) ~[chronicle-map-3.5.0-rc.jar!/:3.5.0-rc]
at net.openhft.chronicle.map.ChronicleMapBuilder$$Lambda$8/862681096.apply(Unknown Source) ~[na:na]
at java.util.concurrent.ConcurrentHashMap.compute(Unknown Source) ~[na:1.8.0_45]
at net.openhft.chronicle.map.ChronicleMapBuilder.fileLockedIO(ChronicleMapBuilder.java:179) ~[chronicle-map-3.5.0-rc.jar!/:3.5.0-rc]
at net.openhft.chronicle.map.ChronicleMapBuilder.createWithFile(ChronicleMapBuilder.java:1447) ~[chronicle-map-3.5.0-rc.jar!/:3.5.0-rc]
at net.openhft.chronicle.map.ChronicleMapBuilder.createPersistedTo(ChronicleMapBuilder.java:1400) ~[chronicle-map-3.5.0-rc.jar!/:3.5.0-rc]

In my build.gradle I have:

    compile "net.openhft:chronicle-map:3.5.0-rc"

I've also tried this with earlier versions, without success.

One thing I have noticed when starting from Eclipse is that this new warning shows up when Chronicle is fist accessed:

warning: Supported source version 'RELEASE_7' from annotation processor  'org.neo4j.kernel.impl.annotations.ServiceProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_7' from annotation processor 'org.neo4j.kernel.impl.annotations.DocumentationProcessor' less than -source '1.8'

but I am not sure if that is related. Am I missing some other dependency?

Edit: I should also mentioned that I use Spring and that my Chronicle map is instantiated as part of a Spring bean.

Edit 2: Debug logging didn't yield anything useful. I'll try to downgrade to an older version of chronicle map next.

Edit 3: It works when building with

compile "net.openhft:chronicle-map:2.4.12"

Edit 4: Same error with new 3.6.0-rc

Edit 5: I have

compile files(org.gradle.internal.jvm.Jvm.current().getToolsJar())

in my build.gradle in order to add the tools.jar (Gradle doesn't have provide afaik). It is also part of the resulting (fat) jar file that I start.

leventov
  • 14,760
  • 11
  • 69
  • 98
geld0r
  • 800
  • 10
  • 22
  • I've seen similar issue, when `net.openhft:compiler:2.2.2` dependency is used, no issue with `net.openhft:compiler:2.2.1`. I don't know the reason for this issue, but I suspect it could be related to OSGi and class loading. Also if you try to start with `-ea` (assertions enabled), Slf4j configured to max verbosity level, and paste additional outputs, it would be helpful. – leventov Mar 05 '16 at 15:49
  • 1
    `-Dorg.slf4j.simpleLogger.defaultLogLevel=debug` – leventov Mar 05 '16 at 15:53
  • About edit 3: no surprise, because Chronicle Map 2.x doesn't use dynamic class loading. – leventov Mar 05 '16 at 17:28
  • Is there any downside to using 2.x? Still seems to be maintained? I noticed though that my (simple) tests for it are not working anymore. Is there any API change (except for ChronicleMapBuilder) which are not obvious? – geld0r Mar 05 '16 at 17:30
  • About the issue: better to continue here: https://github.com/OpenHFT/Chronicle-Values/issues/5 and delete this question (because it doesn't fit SO format). About the last question: if Chronicle Map 2.x is OK for you it is OK, beware there are many limitations in 2.x that are absent in 3.x. Also more features. – leventov Mar 05 '16 at 17:34
  • See https://github.com/OpenHFT/Chronicle-Map#difference-between-chronicle-map-2-and-3 – leventov Mar 05 '16 at 17:35
  • please check Chronicle Map version 3.6.0-rc, it is aimed to resolved this issue. – leventov Mar 08 '16 at 16:12
  • Please ensure that you have tools.jar in the classpath – leventov Mar 08 '16 at 19:58
  • Adent, I cannot investigate this issue without additional help from you, for example minimum reproducible example, because the current info is not sufficient. – leventov Mar 09 '16 at 09:26
  • BTW note that on Stackoverflow it's better to answer in comments than by question edits, because 1) it looks more like conversation, future readers shouldn't jump and understand which edit follows which comment; 2) people are not notified about question edits, but they are notified about the comments where they are mentioned. – leventov Mar 09 '16 at 09:28
  • Ok @leventov. I have created an example which you can find here: https://github.com/geld0r/ChronicleMapExample Note that this is probably not a minimal build configuration (yet). Let me know when you need additional information. – geld0r Mar 09 '16 at 19:08
  • Thank you very much. Will investigate this – leventov Mar 09 '16 at 19:27
  • It works for me both from Intellij and command line, via `gradle bootRun`, on both WIndows and Linux. – leventov Mar 10 '16 at 08:01
  • Interesting. For me it also works with 'gradle bootRun'. If I start the resulting jar with 'java -jar' though it fails. Can you try that, too? – geld0r Mar 10 '16 at 18:17
  • @leventov can you check that, too? I don't know what could cause this difference... – geld0r Mar 12 '16 at 09:17
  • I believe I know the reason for the problem and I'm in the process of fixing it – leventov Mar 12 '16 at 09:18
  • Awesome! Let me know once you have a solution. I am happy to try that out. – geld0r Mar 12 '16 at 09:22
  • Try `3.7.0-rc`, should fix the issue now. – leventov Mar 12 '16 at 15:49
  • Thank you, I've tried it. Application now starts and also seems to work (from first glance) but I receive following warnings repeatedly on startup: `/net/openhft/chronicle/hash/VanillaGlobalMutableState.class: warning: Cannot find annotation method 'value()' in type 'net.openhft.chronicle.values.Group': class file for net.openhft.chronicle.values.Group not found`. Same for methods "min()" and "max()". Can that be ignored? – geld0r Mar 12 '16 at 16:26

1 Answers1

1

Chronicle Map version 3.7.0-rc doesn't have this issue. It emits some no-harm warnings, which will go away with the next released version.

leventov
  • 14,760
  • 11
  • 69
  • 98
  • 1
    @jdoe workaround: http://blog.siteos.de/java/javaee/chroniclemap/2016/05/16/How-To-Use-ChronicleMap-With-JavaEE.html Going away from dynamic compilation completely is on the project roadmap, too, which should eliminate such problems completely. – leventov Nov 03 '16 at 18:51
  • Thanks for confirming! Googled it before, but didn't know if the generated output can be used with no additional precautions. – jdoe Nov 03 '16 at 19:24