Cannot instantiate interface - java

When I tried to run my project(no build errors)there was an exception:
Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationListener : org.springframework.boot.autoconfigure.BackgroundPreinitializer
at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:438)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:420)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:413)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:270)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:250)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1214)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1203)
at com.inmobi.fuse.FuseServiceAppliaction.main(FuseServiceAppliaction.java:47)
Caused by: java.lang.NoClassDefFoundError: org/springframework/core/NativeDetector
at org.springframework.boot.autoconfigure.BackgroundPreinitializer.<clinit>(BackgroundPreinitializer.java:71)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:208)
at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:434)
... 7 more
Caused by: java.lang.ClassNotFoundException: org.springframework.core.NativeDetector
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 14 more
I tried to resolve it, I updated my spring and jdk versions thinking it might be the reason but they all resulted in the same above exception.

Please see https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/. It says
Spring Native 0.10.2 only supports Spring Boot 2.5.3, so change the version if necessary.
If you are running an older version of spring boot than 2.5.3, please try to upgrade and see if that helps.
See https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent for a list of available versions of spring boot.

Related

While running a spark-java program in eclipse, I am getting this error - java.lang.NoClassDefFoundError

I am using Spark 3.1.2 prebuilt with hadoop 3.2.0. I am using winutils instead of hadoop installation.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/spark/util/HadoopFSUtils$
at org.apache.spark.sql.execution.datasources.DataSource$.$anonfun$checkAndGlobPathIfNecessary$5(DataSource.scala:814)
at org.apache.spark.sql.execution.datasources.DataSource$.$anonfun$checkAndGlobPathIfNecessary$5$adapted(DataSource.scala:813)
at scala.collection.TraversableLike.$anonfun$partition$1(TraversableLike.scala:402)
at scala.collection.immutable.List.foreach(List.scala:392)
at scala.collection.TraversableLike.partition(TraversableLike.scala:402)
at scala.collection.TraversableLike.partition$(TraversableLike.scala:400)
at scala.collection.AbstractTraversable.partition(Traversable.scala:108)
at org.apache.spark.sql.execution.datasources.DataSource$.checkAndGlobPathIfNecessary(DataSource.scala:813)
at org.apache.spark.sql.execution.datasources.DataSource.checkAndGlobPathIfNecessary(DataSource.scala:590)
at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:415)
at org.apache.spark.sql.DataFrameReader.loadV1Source(DataFrameReader.scala:326)
at org.apache.spark.sql.DataFrameReader.$anonfun$load$3(DataFrameReader.scala:308)
at scala.Option.getOrElse(Option.scala:189)
at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:308)
at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:240)
at Main.main(Main.java:26)
Caused by: java.lang.ClassNotFoundException: org.apache.spark.util.HadoopFSUtils$
at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 16 more

KeyCloak Server Caused by: java.lang.ClassNotFoundException: java.security.acl.Group with java 11

I am trying to secure my spring application with keycloak and when I invoke the REST API I get the following error:
Caused by: java.lang.ClassNotFoundException: java.security.acl.Group
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
... 19 common frames omitted
I found another post with the same problem (KeyCloak Server Caused by: java.lang.ClassNotFoundException: java.security.acl.Group) and it was solved using Java 11, but I already used it and I'm still getting the same error.
Any idea about how to solve it?
I am using the KC 12.0.4, the config is exported here:
https://github.com/aleon91/keycloak/blob/main/realm-export.json
The Spring Security config is here:
https://github.com/aleon91/keycloak/blob/main/src/main/java/com/leonlyon/auth/config/KeycloakSecurityConfig.java
And the pom.xml here:
https://github.com/aleon91/keycloak/blob/main/pom.xml

ObjectBox Java sometimes throws error java.lang.ClassNotFoundException: kotlin.text.Charsets

Sometimes when i run the application that using ObjectBox java with no kotlin coding, java throws this error. java.lang.ClassNotFoundException: kotlin.text.Charsets
dependencies {
// Optional: include all native libraries for distribution
implementation "io.objectbox:objectbox-linux:$objectboxVersion"
implementation "io.objectbox:objectbox-macos:$objectboxVersion"
implementation "io.objectbox:objectbox-windows:$objectboxVersion"
}
apply plugin: 'io.objectbox'
But run again the error gone and the application started normally... anything wrong? do i need to include kotlin lib in my gradle build manually? or its caused by the ide is building the project so get error on the first run its confusing here. I am using IntelliJ, Gradle,ObjectBox 2.8.1,Java 1.8
Stacktrace:
Exception in thread "Thread-109" java.lang.NoClassDefFoundError: kotlin/text/Charsets
at io.objectbox.reporting.BasicBuildTracker.sendEvent(BasicBuildTracker.kt:166)
at io.objectbox.reporting.BasicBuildTracker$sendEventAsync$1.run(BasicBuildTracker.kt:143)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: kotlin.text.Charsets
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
Caused by: java.lang.ClassNotFoundException: kotlin.text.Charsets
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 3 more
java.lang.ClassNotFoundException: kotlin.text.Charsets
Caused by: java.lang.ClassNotFoundException: kotlin.text.Charsets

RabbitMq and Spring Boot 1.5.8 error java.lang.ClassNotFoundException: reactor.io.codec.Codec

Currently I use spring boot 1.5.8 and I want to use rabbitmq with my websocket.
The following code is my configuration of websocket
#Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config
.enableStompBrokerRelay("/topic", "/queue", "/exchange")
.setRelayHost("localhost")
.setRelayPort(5672)
.setClientLogin("guest")
.setClientPasscode("guest")
.setSystemHeartbeatSendInterval(5000);
}
I add to my gradle config the following dependencies
compile "org.springframework.boot:spring-boot-starter-websocket"
compile("io.projectreactor:reactor-net:2.0.5.RELEASE")
compile("io.projectreactor:reactor-core:2.0.5.RELEASE")
compile("io.netty:netty-all:4.0.33.Final")
Spring boot generate the following stack error
Caused by: java.lang.NoClassDefFoundError: reactor/io/codec/Codec
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler.startInternal(StompBrokerRelayMessageHandler.java:388)
at org.springframework.messaging.simp.broker.AbstractBrokerMessageHandler.start(AbstractBrokerMessageHandler.java:164)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:175)
... 17 common frames omitted
Caused by: java.lang.ClassNotFoundException: reactor.io.codec.Codec
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 32 common frames omitted
I don't know what I'm doing wrong. Any ideas?
I follow the ideas given by http://djeison.me/2017/11/04/spring-websocket-rabbitmq/
And also have the same problem as Spring security 4.0.1 and Spring 4.2.0.RC1 stompBrokerRelayMessageHandler bean error with RabbitMQ
Similar issue resolved on GitHub: https://github.com/zyro23/grails-spring-websocket/issues/26
I have a very rare situation. I will explain it.
I use IntelliJ as my principal IDE for java development. When I configure the gradle plugin with the right panel, I always use the button for refresh dependencies. The strange situation here was that when I run spring boot with bootRun inside IntelliJ, it always generate the same error as the question said. I tried the last resource that was to bootRepackage the jar. Incredible, that was the solution. After the bootRepackage, IntelliJ recognize the new class reactor.io.codec.Codec.
So if you use IntelliJ as your main IDE, try to repackage and after that maybe the error was gone.

use endorsed standard override mechanism for xerces in GlassFish 4.0

How do I use the endorsed standard mechanism to use xerces in a GlassFish 4.0 WAR application? According to the documentation*, you should put it into domain-dir/lib/endorsed. However, when I put xercesImpl, xml-apis as well as xml-resolver there, the classes are not available from my classes in the WAR. This is most proabably due to an inconsistency between the docs and the default config: the domain.xml does not list domain-dir/lib/endorsed.
When I include it or put the files into glassfish-install-dir/lib/endorsed, the startup fails with the following exception:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)
at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:54)
Caused by: A MultiException has 5 exceptions. They are:
1. javax.xml.stream.FactoryConfigurationError: Provider com.ctc.wstx.stax.WstxOutputFactory not found
2. java.lang.IllegalStateException: Unable to perform operation: create on com.sun.enterprise.v3.server.DomainXmlPersistence
3. javax.xml.stream.FactoryConfigurationError: Provider com.ctc.wstx.stax.WstxInputFactory not found
4. java.lang.IllegalArgumentException: While attempting to resolve the dependencies of com.sun.enterprise.v3.server.GFDomainXml errors were found
5. java.lang.IllegalStateException: Unable to perform operation: resolve on com.sun.enterprise.v3.server.GFDomainXml
at org.jvnet.hk2.internal.Collector.throwIfErrors(Collector.java:88)
at org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:252)
at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:360)
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:461)
at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:114)
at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:102)
at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture$1.call(Cache.java:97)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture.run(Cache.java:154)
at org.glassfish.hk2.utilities.cache.Cache.compute(Cache.java:199)
at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:153)
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2258)
at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetAllServiceHandles(ServiceLocatorImpl.java:1372)
at org.jvnet.hk2.internal.ServiceLocatorImpl.getAllServices(ServiceLocatorImpl.java:726)
at org.jvnet.hk2.internal.ServiceLocatorImpl.getAllServices(ServiceLocatorImpl.java:714)
at org.jvnet.hk2.config.ConfigurationPopulator.populateConfig(ConfigurationPopulator.java:56)
at org.glassfish.hk2.bootstrap.HK2Populator.populateConfig(HK2Populator.java:106)
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.populateConfig(AbstractModulesRegistryImpl.java:211)
at com.sun.enterprise.module.bootstrap.Main.createServiceLocator(Main.java:273)
at org.jvnet.hk2.osgiadapter.HK2Main.createServiceLocator(HK2Main.java:120)
at com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishRuntime.newGlassFish(EmbeddedOSGiGlassFishRuntime.java:95)
at com.sun.enterprise.glassfish.bootstrap.GlassFishRuntimeDecorator.newGlassFish(GlassFishRuntimeDecorator.java:68)
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishRuntime.newGlassFish(OSGiGlassFishRuntime.java:91)
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(GlassFishMain.java:113)
... 6 more
Caused by: javax.xml.stream.FactoryConfigurationError: Provider com.ctc.wstx.stax.WstxOutputFactory not found
at javax.xml.stream.XMLOutputFactory.newInstance(Unknown Source)
at com.sun.enterprise.v3.server.DomainXmlPersistence.<init>(DomainXmlPersistence.java:85)
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.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1107)
at org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:274)
at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:368)
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:461)
at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:114)
at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:102)
at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture$1.call(Cache.java:97)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture.run(Cache.java:154)
at org.glassfish.hk2.utilities.cache.Cache.compute(Cache.java:199)
at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:153)
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2258)
at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:638)
at org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(ThreeThirtyResolver.java:77)
at org.jvnet.hk2.internal.ClazzCreator.resolve(ClazzCreator.java:214)
at org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:237)
... 28 more
How do I fix this? downloading the Woodstox StAX parser into lib/endorsed as suggested in this answer did not work.
--
* That's the documentation for GlassFish 3, but it's exactly the same in the documentation for GlassFish 4, which I only found as PDF

Categories