Cannot load native library libLiteCore.dylib on M1 - kotlin

I'm trying to build a JVM application (mostly Kotlin) on my M1 MacBook that uses CouchbaseLite.
I have this in my build.gradle file:
implementation "com.couchbase.lite:couchbase-lite-java:3.0.0-beta02"
(also tried it with a non-beta version 2.8.4)
Gradle sync + build is fine but everytime I run the up and try to create a database
db = Database(LOCAL_DB_NAME, config)
I get the following error:
java.lang.IllegalStateException: Cannot load native library libLiteCore.dylib #/Users/ale/Projects/server/CouchbaseLiteTemp/5e3b1711cace9de693b3e1e0bea0f2f8/libLiteCore.dylib for Mac OS X/aarch64
at com.couchbase.lite.internal.NativeLibrary.load(NativeLibrary.java:113)
at com.couchbase.lite.internal.CouchbaseLiteInternal.init(CouchbaseLiteInternal.java:80)
at com.couchbase.lite.CouchbaseLite.init(CouchbaseLite.java:54)
at com.couchbase.lite.CouchbaseLite.init(CouchbaseLite.java:42)
at com.couchbase.lite.CouchbaseLite.init(CouchbaseLite.java:33)
at de.ihaus.Main.Database.CouchbaseManager.initContext(CouchbaseManager.kt:34)
at de.ihaus.Main.Dingo$main$1.invoke(Dingo.kt:15)
at de.ihaus.Main.Dingo$main$1.invoke(Dingo.kt:14)
at de.ihaus.Main.Login.LoginManager.onLoginSuccess(LoginManager.kt:64)
at de.ihaus.Main.Login.LoginManager$LoginWorker.run(LoginManager.kt:53)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.UnsatisfiedLinkError: /Users/ale/Projects/server/CouchbaseLiteTemp/5e3b1711cace9de693b3e1e0bea0f2f8/libLiteCore.dylib: dlopen(/Users/ale/Projects/server/CouchbaseLiteTemp/5e3b1711cace9de693b3e1e0bea0f2f8/libLiteCore.dylib, 0x0001): tried: '/Users/ale/Projects/server/CouchbaseLiteTemp/5e3b1711cace9de693b3e1e0bea0f2f8/libLiteCore.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libLiteCore.dylib' (no such file)
at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442)
at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2498)
at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694)
I've looked around but CouchbaseLite is supposed to work on an M1.
What am I doing wrong?

Turns out the problem was the Apple Silicon version of the JDK.
If I run the project with an x86_64 version of the JDK, Rosetta kicks in and it works. Will have to live with the performance hit for now, but at least I'm not blocked anymore.

Unfortunately, CBL-Java doesn't support Native Mac M1 yet.

Related

Problems in IntelliJ since version 2022.1 / java.lang.NoClassDefFoundError

As of today, when I try to run some of my programs in IntelliJ today, this message was shown:
Executing pre-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Running 'before' tasks
Checking sources
Finished, saving caches…
Module 'Listen' production: java.lang.NoClassDefFoundError: com/intellij/DynamicBundle
Executing post-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Synchronizing output directories...
13.04.22, 14:54 - Build completed with 1 error and 0 warnings in 4 sec, 39 ms
This line is printed in red: Module 'Listen' production: java.lang.NoClassDefFoundError: com/intellij/DynamicBundle
I don't really have too much of an idea where I should look for the problem.
It seems to not have anything to do with the project itself. I already created a new Project and created a Hello World-program, which resulted in the same error.
Remarkably, yesterday my IntelliJ IDEA version was updated to version 2022.1.
Runtime version: 11.0.14.1+1-b2043.25 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
I have no idea either whether it has anything to do with the new version either.
I maintain another Project, which uses Scala language. That one is messed up even more:
Cannot process toolwindow sbt
java.lang.AbstractMethodError: Missing implementation of resolved method 'abstract com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings getSettings(com.intellij.openapi.project.Project)' of abstract class com.intellij.openapi.externalSystem.service.task.ui.AbstractExternalSystemToolWindowFactory.
at com.intellij.openapi.externalSystem.service.task.ui.AbstractExternalSystemToolWindowFactory.shouldBeAvailable(AbstractExternalSystemToolWindowFactory.java:35)
at com.intellij.toolWindow.ToolWindowSetInitializerKt.beanToTask(ToolWindowSetInitializer.kt:262)
at com.intellij.toolWindow.ToolWindowSetInitializerKt.beanToTask(ToolWindowSetInitializer.kt:248)
at com.intellij.toolWindow.ToolWindowSetInitializerKt.access$beanToTask(ToolWindowSetInitializer.kt:1)
at com.intellij.toolWindow.ToolWindowSetInitializerKt$computeToolWindowBeans$1.accept(ToolWindowSetInitializer.kt:278)
at com.intellij.toolWindow.ToolWindowSetInitializerKt$computeToolWindowBeans$1.accept(ToolWindowSetInitializer.kt)
at com.intellij.openapi.extensions.impl.ExtensionPointImpl.processWithPluginDescriptor(ExtensionPointImpl.java:301)
at com.intellij.toolWindow.ToolWindowSetInitializerKt.computeToolWindowBeans(ToolWindowSetInitializer.kt:274)
at com.intellij.toolWindow.ToolWindowSetInitializer$1.get(ToolWindowSetInitializer.kt:101)
at com.intellij.toolWindow.ToolWindowSetInitializer$1.get(ToolWindowSetInitializer.kt:83)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
at java.base/java.lang.Thread.run(Thread.java:829)
Any advice?
Best
Stapelüberläufer
I had the same problem after upgrading to Intellij 2022.1
For me, the fix came from Gen's answer. I also had an old Scala plugin, and just removed it as I'm not using it anymore.
If you are looking to upgrade it, go to File -> Settings -> Plugins. From there just hit Upgrade for the plugins you want. After that restart the IDE.
I found that Scala plugin was not updated and updating it to at least version 2022.1.13 fixed it for me.
I upgraded to Intellij 2022.1 and encountered this issue when trying to sync the old gradles projects that used to work for me :
Caused by: java.lang.NoClassDefFoundError: org/gradle/internal/impldep/com/google/common/collect/Lists
Cleaning the caches folder's content (Gradle_HOME/caches) resolved this issue for me
Make sure to also check that the SDK is correctly configured for your project (Java 17 by default) and the Gradle home is well specified in the Settings>Gradle section.
For info, I'm using Java 8 and Gradle 5.5.1 (yes I know :))
Just upgrade the Scala Plugin and its done!
visiting
scala plugin's page
and install it from there worked for me on ultimate version 2022.2.3

IntelliJ debugger doesn't recognize Java version upgrade

I upgraded to Java 8 from Java 6.
As per these instructions, in /Applications/IntelliJ IDEA 13 CE.app/Contents/Info.plist I changed
<key>JVMVersion</key>
<string>1.6*</string>
to
<key>JVMVersion</key>
<string>1.8*</string>
My environment variable JAVA_HOME is set to:
/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home
However, when I run the debugger in IntelliJ, it still wants to use Java 6:
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java ...
Connected to the target VM, address: '127.0.0.1:60490', transport: 'socket'
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/my/MainClass : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
What other settings do I need to change in order for IntelliJ to use the Java 8 JRE?
You changed the IDE's setting. Project setting can be changed here: File->ProjectStructure->Project SDK

While using Play Framework v1 and IntelliJ 13 CE and running jUnit tests, I receive an UnExpectedException during startup

I have been using IntelliJ CE for the past two weeks when suddenly I ran into problems running my unit tests within IntelliJ. My team uses Play Framework v1.2.5 and if I run the project from the command line, it compiles and runs fine. If I run the tests for the project in Eclipse Kepler, they work fine. Only when I run the tests in IntelliJ, I receive this Exception during startup:
play.exceptions.UnexpectedException: While applying play.CorePlugin#5d0a70af on models.PortfolioHoldingItem$Field$8
at play.plugins.PluginCollection.enhance(PluginCollection.java:556)
at play.classloading.ApplicationClasses$ApplicationClass.enhance(ApplicationClasses.java:235)
at play.classloading.ApplicationClassloader.loadApplicationClass(ApplicationClassloader.java:163)
at play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:427)
at play.Play.start(Play.java:515)
at play.test.PlayJUnitRunner.<init>(PlayJUnitRunner.java:34)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
Caused by: play.exceptions.UnexpectedException: While applying class play.classloading.enhancers.PropertiesEnhancer on models.PortfolioHoldingItem$Field$8
at play.CorePlugin.enhance(CorePlugin.java:306)
at play.plugins.PluginCollection.enhance(PluginCollection.java:551)
... 18 more
Caused by: play.exceptions.UnexpectedException: Error in PropertiesEnhancer
at play.classloading.enhancers.PropertiesEnhancer$1.edit(PropertiesEnhancer.java:177)
at javassist.expr.ExprEditor.loopBody(ExprEditor.java:198)
at javassist.expr.ExprEditor.doit(ExprEditor.java:91)
at javassist.CtBehavior.instrument(CtBehavior.java:664)
at play.classloading.enhancers.PropertiesEnhancer.enhanceThisClass(PropertiesEnhancer.java:135)
at play.CorePlugin.enhance(CorePlugin.java:301)
... 19 more
Caused by: javassist.NotFoundException: field: $assertionsDisabled in models.PortfolioHoldingItem$Field
at javassist.CtClassType.checkGetField(CtClassType.java:907)
at javassist.CtClassType.getField(CtClassType.java:896)
at javassist.CtClass.getField(CtClass.java:699)
at javassist.expr.FieldAccess.getField(FieldAccess.java:114)
at play.classloading.enhancers.PropertiesEnhancer$1.edit(PropertiesEnhancer.java:142)
... 24 more
That class is in the project, but not being tested. I've tried to:
play clean (delete the play cache)
play idealize (regenerate the IntelliJ project, re-import)
play eclipsify (regenerate the eclipse project, then import into IntelliJ)
From within IntelliJ, File | Invalidate Caches and Restart
Upgrade my JDK from 1.7.0_45 to 1.7.0_51
Upgrade to IntelliJ CE 13.1
Clone a new copy of the repo, re-import
I am on a mac, if that makes any difference. Anyone else experience this? Any suggestions for something to try?
EDIT: Same problem on my Linux dev machine.
I believe I found the solution. PlayFramework v1 has some issues with Java 7's verifier.
Adding -XX:-UseSplitVerifier to the jUnit Run/Debug configuration solved this issue.

Unable to Load LeJOS NXT Comm Driver

I have been trying to generate an interface with my NXT robot, using the LeJOS libraries. When I run the code I get the following error printed to the console:
lejos.pc.comm.NXTCommException: Cannot load NXTComm driver
at lejos.pc.comm.NXTCommFactory.newNXTCommInstance(NXTCommFactory.java:110)
at lejos.pc.comm.NXTCommFactory.createNXTComm(NXTCommFactory.java:91)
at com.thirteenbit.prasController.PrasController.initConnection(PrasController.java:24)
at com.thirteenbit.prasController.PrasController.<init>(PrasController.java:17)
at com.thirteenbit.prasController.PrasController$1.run(PrasController.java:42)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:708)
at java.awt.EventQueue.access$400(EventQueue.java:82)
at java.awt.EventQueue$2.run(EventQueue.java:669)
at java.awt.EventQueue$2.run(EventQueue.java:667)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:678)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: lejos.internal.jni.JNIException: cannot load library /Users/Andrew/Desktop/Dropbox/Eclipse Files/leJOS_NXJ_0.9.1beta-3/lib/pc/native/macosx/libjfantom.jnilib, architecture macosx/x86_64
at lejos.internal.jni.JNILoader.loadLibrary(JNILoader.java:121)
at lejos.pc.comm.NXTCommFantom.initialize0(NXTCommFantom.java:96)
at lejos.pc.comm.NXTCommFantom.initialize(NXTCommFantom.java:103)
at lejos.pc.comm.NXTCommFactory.newNXTCommInstance(NXTCommFactory.java:103)
... 18 more
Caused by: java.lang.UnsatisfiedLinkError: /Users/Andrew/Desktop/Dropbox/Eclipse Files/leJOS_NXJ_0.9.1beta-3/lib/pc/native/macosx/libjfantom.jnilib: no suitable image found. Did find: /Users/Andrew/Desktop/Dropbox/Eclipse Files/leJOS_NXJ_0.9.1beta-3/lib/pc/native/macosx/libjfantom.jnilib: no matching architecture in universal wrapper
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1827)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1703)
at java.lang.Runtime.load0(Runtime.java:770)
at java.lang.System.load(System.java:1020)
at lejos.internal.jni.JNILoader.loadLibrary(JNILoader.java:111)
... 21 more
I believe that this is identical to the problem found in java eclipse: failed to load nxt usb comm driver, and I installed eclipse 32-Bit version and I still am getting the same error, the one above. How would I go about fixing this?
Because I can't post comments due to my reputation (I'm new), an answer:
You should make sure you have:
- x86 JDK (Java Development Kit), click: jdk-7u21-windows-i586.exe
- Lego fantom drivers , click: Fantom Driver 1.1.3
and as you already mentioned a 32-Bit version of Eclipse

java.lang.UnsupportedClassVersionError: bad major version at offset=6

I have deployed a WAR file in the webapps folder in my tomcat. And when I am starting my tomcat, like below
C:\apache-tomcat-6.0.35\bin>startup.bat
Using CATALINA_BASE: "C:\apache-tomcat-6.0.35"
Using CATALINA_HOME: "C:\apache-tomcat-6.0.35"
Using CATALINA_TMPDIR: "C:\apache-tomcat-6.0.35\temp"
Using JRE_HOME: "C:\Program Files (x86)\IBM\RationalSDLC\Common\Java5.0\jre"
Using CLASSPATH: "C:\apache-tomcat-6.0.35\bin\bootstrap.jar"
I am getting this below exception-
SEVERE: Error deploying web application archive DirectoryServer.war
java.lang.UnsupportedClassVersionError: (com/services/rest/Listener) bad major version at offset=6 (unable to load class com.services.rest.Listener)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2822)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.apache.catalina.startup.WebAnnotationSet.loadClassAnnotation(WebAnnotationSet.java:145)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationListenerAnnotations(WebAnnotationSet.java:73)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:56)
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:297)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1078)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:261)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4612)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
And this is my JAVA version-
C:\apache-tomcat-6.0.35\bin>java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
Can anyone provide any suggestion why is it happening?
You have essentially compiled your code with JDK 1.6 but running it with Java 5 - Just ensure a Java 6 runtime.
Even I faced same problem. The problem is inappropriate class version, for ex. compiling with different jre.
Solution: IF you are using Eclipse or RAD, set change compiler setting as per your requirement and also change same setting to project configuration by clicking on "Configure Project specific setting". Windows->Preferences->Compiler-> click on link "Configure Project specific setting".
For me the fix was to set the JAVA_Home system variable to the correct path.
It is a compiler issue. Make sure all your modules are configured with java 1.5 as a compiler. Window-->preference--> Java --> Compiler. Make sure 1.5 is selected.