23

What does this error mean .. It runs fine in Eclipse but not in intellij idea

Exception in thread "main" java.lang.VerifyError: Cannot inherit from final class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at com.couchbase.client.ViewConnection.createConnections(ViewConnection.java:120)
at com.couchbase.client.ViewConnection.<init>(ViewConnection.java:100)
at com.couchbase.client.CouchbaseConnectionFactory.createViewConnection(CouchbaseConnectionFactory.java:179)
at com.couchbase.client.CouchbaseClient.<init>(CouchbaseClient.java:243)
at com.couchbase.client.CouchbaseClient.<init>(CouchbaseClient.java:175)
at com.couchbase.App.putincbase(App.java:122)
at examplesCons.TestCons.run(TestCons.java:89)
at examplesCons.TestCons.main(TestCons.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

I get this error when I try to run couchbase using couchbase-client-1.1.6.jar from Intellij IDea.

fvu
  • 32,488
  • 6
  • 61
  • 79
TommyT
  • 1,707
  • 3
  • 17
  • 26

4 Answers4

70

if you're using kotlin, add open to your class (extends RealmObject) declaration

open class Foo() {

}
Estevanbs
  • 140
  • 2
  • 13
itzhar
  • 12,743
  • 6
  • 56
  • 63
13

The message means what it says.

Somewhere, somehow you have managed to create a class that extends a superclass, where the superclass has been declared as final.

The most likely cause is that you have a conflict between your build classpath and your launch classpath. In other words, you are compiling your subclass against a version of the superclass that is not final, and then running against a version that is final. The verifier is saying (correctly) that this is wrong.


If it is not your build / one of your classes that is causing this, then it is some internal conflict within the CouchDB client classes that you are using. Indeed the fact that this is a VerifyError rather than an IncompatibleClassChangeError suggests that this maybe a problem with some dynamically generated bytecodes.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • So is there some class in the API that is final .. as I am not extending anything in any of my custom classes. – TommyT Aug 09 '13 at 00:16
  • You're downloading a class at runtime from somewhere, and that class is attempting to subclass a class that's declared `final` in your runtime environment. – chrylis -cautiouslyoptimistic- Aug 09 '13 at 02:03
  • I got this warning when I made new Android project with wizard of fresh installed Android Studio 0.4.2 :S – Ewoks Jan 15 '14 at 09:11
1

I also faced this with IntelliJ Idea: 2018.3 Community Edition, However running following fixed it for me:

mvn -U idea:idea clean compile install -DskipTests
Saurabh
  • 71,488
  • 40
  • 181
  • 244
0

maybe you would be extend a java class which is marked as final keyword but as you know, inheritance is not possible with final class.