ClassNotFoundException: org.springframework.data.elasticsearch.core.query.RescorerQuery - spring-data-elasticsearch

I'm using spring-data-elasticsearch:4.3.2 and spring-boot-starter:2.6.4, I can navigate to the RescorerQuery class in Intellij but upon bootstrapping, it logs this error:
Caused by: java.lang.NoClassDefFoundError: org/springframework/data/elasticsearch/core/query/RescorerQuery
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166)
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2309)
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463)
... 35 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.data.elasticsearch.core.query.RescorerQuery
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 39 common frames omitted
Update: Turns out it is due to version compatibility. If I change spring-boot-starter to version 2.5.5 it works perfectly. However RescorerQuery is not recommended since it will make the query time a lot longer.

Related

Spring Boot - java.lang.ClassNotFoundException: javax.servlet.ServletContext and Unable to start EmbeddedWebApplicationContext

I have a Spring Boot application (Grails 3.1.8), but when I run the application in IntelliJ IDEA I get the following error:
Caused by: java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:163)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:292)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:232)
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:510)
... 26 common frames omitted
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContext
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:152)
... 29 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 33 common frames omitted
I tried adding javax-servlet-api dependency as suggested in an answer to Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: javax/servlet/ServletContext
But then I started getting:
ERROR org.springframework.boot.SpringApplication - Application startup failed
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at grails.boot.GrailsApp.run(GrailsApp.groovy:55)
at grails.boot.GrailsApp.run(GrailsApp.groovy:374)
at grails.boot.GrailsApp.run(GrailsApp.groovy:363)
at grails.boot.GrailsApp$run.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
at closemytab.Application.main(Application.groovy:13)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:185)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:158)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
... 18 common frames omitted
This post then suggests to remove the javax-servlet-api: Spring boot -- Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean
But then I face the original issue.
Any thoughts?
The issue was with the build.gradle file:
provided "org.springframework.boot:spring-boot-starter-tomcat"
IntelliJ IDEA wasn't happy with the provided.
As soon as I switched to
compile "org.springframework.boot:spring-boot-starter-tomcat"
the application worked.
Run with a Maven Spring Boot goal:
spring-boot:run
Steps to set up Maven configuration in IntelliJ IDEA:
Menu Debug/Run Configuration → Click on the + button visible at the top left → Select Maven → Set command line to spring-boot:run.
If you are using IntelliJ IDEA, you need to enable ' Include dependencies with "Provider" scope in menu Run → Edit Configurations → Application → 'your main class' (by default it's disabled)
Adding the dependency below fixed my issue:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Remember to have a parent dependency as well!
For me, it's because of the Tomcat version. I changed Tomcat version from 7.5 to 8.5, and the problem's solved.
Exception is java.lang.NoClassDefFoundError: javax/servlet/ServletContext only means you are not providing the Tomcat dependency to your application. In case you are using IntelliJ IDEA, it’s really simple to do that as shown below.
Select your project → open the Maven panel (it mostly resides on the top right side of the panel) → select embedded.

Problems using Contiki Cooja motes on motes creation

I have developed a working Cooja simulatation that uses 1 sky mote (for RPL border router, that did not work with a cooja mote) and 30 Cooja motes.
I run cooja using ant big_mem.
The simulation was working correctly, and then I have saved it.
After quitting cooja I have tried to reuse it, but I always get the following error:
se.sics.cooja.GUI$SimulationCreationException: Mote type creation error: Error when creating corecomm instance: Lib4
at se.sics.cooja.GUI.loadSimulationConfig(GUI.java:3428)
at se.sics.cooja.GUI.loadSimulationConfig(GUI.java:3340)
at se.sics.cooja.GUI.doLoadConfig(GUI.java:2397)
at se.sics.cooja.GUI$4.run(GUI.java:636)
at java.lang.Thread.run(Thread.java:745)
Caused by: se.sics.cooja.MoteType$MoteTypeCreationException: Error when creating corecomm instance: Lib4
at se.sics.cooja.CoreComm.createCoreComm(CoreComm.java:343)
at se.sics.cooja.contikimote.ContikiMoteType.doInit(ContikiMoteType.java:385)
at se.sics.cooja.contikimote.ContikiMoteType.configureAndInit(ContikiMoteType.java:348)
at se.sics.cooja.contikimote.ContikiMoteType.setConfigXML(ContikiMoteType.java:1389)
at se.sics.cooja.Simulation.setConfigXML(Simulation.java:681)
at se.sics.cooja.GUI.loadSimulationConfig(GUI.java:3410)
... 4 more
Caused by: java.lang.reflect.InvocationTargetException
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 se.sics.cooja.CoreComm.createCoreComm(CoreComm.java:334)
... 9 more
Caused by: java.lang.UnsatisfiedLinkError: se.sics.cooja.corecomm.Lib4.init()V
at se.sics.cooja.corecomm.Lib4.init(Native Method)
at se.sics.cooja.corecomm.Lib4.<init>(Lib4.java:50)
... 14 more
How can I solve it?
Thank you,
Daniel
I have discovered the problem. It it necessary to delete the obj_cooja folder that the simulation creates to solve the problem

How To Run Grails 2.4.1 With Servlet 2.5

Grails version 2.4.1 was recently released. One of the bugs fixed was restoring the ability to use servlet version 2.5. See https://jira.grails.org/browse/GRAILS-11466
I created a new grails app. Without changing anything, I was able to compile it and run it. When I changed the grails.servlet.version to "2.5", I was able to compile but when I ran it I got the the following stack trace error.
Does anyone know if there are other settings I need to change to get Grails 2.4.1 to run on a servlet 2.5 container? Specifically, tomcat 6.
Error loading plugin manager: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.RuntimeException: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:684)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
Caused by: java.lang.reflect.InvocationTargetException
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrConstructorNewInstance(ReflectiveInterceptor.java:1002)
... 19 more
Caused by: java.lang.NoClassDefFoundError: Lorg/codehaus/groovy/grails/plugins/web/async/api/ControllersAsyncApi;
at org.springsource.loaded.ri.ReflectiveInterceptor.jlClassGetDeclaredFields(ReflectiveInterceptor.java:1593)
... 20 more
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.grails.plugins.web.async.api.ControllersAsyncApi
... 21 more
Error |
Error loading plugin manager: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass
Error |
Forked Grails VM exited with error
Process finished with exit code 1
This error would happen if you didn't do a grails clean prior to running Grails after changing the version to 2.5
What happens is that when the version is 3.0 Grails adds extra dependencies to the classpath that result in new behaviour being added to the compiled classes.
If you then change the version to 2.5 and just do run-app the extra dependencies are gone, but the new behaviour is still compiled into the classes. Doing a clean resolve this.

ClassNotFoundException: SimpleKeyGenerator upgrading to Grails 2.4.0.RC1

Trying to get our application up and running with 2.4.0.RC1 and I keep running into this error:
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [grails.plugin.cache.CustomCacheKeyGenerator]: Constructor threw exception; nested exception is java.lang.RuntimeException: java.lang.ClassNotFoundException: org.springframework.cache.interceptor.SimpleKeyGenerator
... 4 more
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.springframework.cache.interceptor.SimpleKeyGenerator
at grails.plugin.cache.CustomCacheKeyGenerator.<init>(CustomCacheKeyGenerator.java:46)
... 4 more
Caused by: java.lang.ClassNotFoundException: org.springframework.cache.interceptor.SimpleKeyGenerator
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName(Class.java:190)
at grails.plugin.cache.CustomCacheKeyGenerator.<init>(CustomCacheKeyGenerator.java:43)
... 4 more
I've upgraded to the latest version of cache (1.1.6). It seems like some kind of version conflict with the spring cache stuff, but I checked the dependency report and didn't see anything unusual being pulled in.
Anyone else run into this problem and have a solution?
It turns out that spring-integration-core version 3.0.3 was including an older version of spring-context that I missed.
Upgrading to spring-integration-core version 4.0.0 uses the same version of Spring 4 as Grails.

jenkins critical error after plugin update

I attempted to update a couple of my jenkins plugins (don't remember which) but got hung. After about 15 mins, I decided to restart the jenkins server. This is what I get on the jenkins UI:
org.jvnet.hudson.reactor.ReactorException: java.lang.Error: java.lang.reflect.InvocationTargetException
at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:246)
at jenkins.InitReactorRunner.run(InitReactorRunner.java:43)
at jenkins.model.Jenkins.executeReactor(Jenkins.java:894)
at jenkins.model.Jenkins.<init>(Jenkins.java:796)
at hudson.model.Hudson.<init>(Hudson.java:81)
at hudson.model.Hudson.<init>(Hudson.java:77)
at hudson.WebAppMain$2.run(WebAppMain.java:214)
Caused by: java.lang.Error: java.lang.reflect.InvocationTargetException
at hudson.init.InitializerFinder.invoke(InitializerFinder.java:124)
at hudson.init.InitializerFinder$TaskImpl.run(InitializerFinder.java:184)
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:259)
at jenkins.model.Jenkins$7.runTask(Jenkins.java:883)
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:187)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:94)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.reflect.InvocationTargetException
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 hudson.init.InitializerFinder.invoke(InitializerFinder.java:120)
... 8 more
Caused by: java.lang.NoClassDefFoundError: hudson/PluginManager$PluginUpdateMonitor
at hudson.maven.PluginImpl.init(PluginImpl.java:54)
... 13 more
Caused by: java.lang.ClassNotFoundException: hudson.PluginManager$PluginUpdateMonitor
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 14 more
I attempted to update the war from 1.486 to 1.502 but no change in behavior. What can I do to get Jenkins operational again?
It's a known bug.
Copy/pasted for reference:
Start 1.490 on a clean home dir, then ask to upgrade the Maven plugin to version 1.491, and restart. After the restart, there are linkage errors from the Maven plugin, predictably enough (since it is using 1.491+ core APIs); but all of Jenkins fails to start, making it impossible to use the GUI to back out the update. (Workaround: delete $JENKINS_HOME/plugins/maven-plugin.jpi.pinned.)
Didn't work for me, so I just deleted every $JENKINS_HOME/plugins/maven-plugin* file.
Done.
I got the Same Error When Trying to Update the Plugins & Delete \Unpin some Plugins at the Same time.
Finally was able to Solve the issue by, Deleting all the "DISABLED" files in Plugins folder, restored back all the Maven files (if deleted on suggestion by previous Solutions), restarted the Jenkins Instance.
Understood this is because of Conflict with Plugins loading.
None of the above mentioned method is working for me.
Workaround: delete $JENKINS_HOME/plugins/maven-plugin.jpi.pinned
Deleting all the "DISABLED" files in Plugins folder, restored back all the Maven files
As per https://issues.jenkins-ci.org/browse/JENKINS-43446 :
I downgraded my maven to version 3.3.9 and It worked for me.

Resources