Java jersey 2 json support - java

I am trying to create a rest web service which consumes JSON as input. Up to now I have not been able to do so as I get several exceptions. As I am not a maven user, it is so hard to handle dependencies and the documentation is not very helpful. The example that I use as reference is from mkyong website
Please is there anyone who has managed to enable json support in jersey 2 ? Any advice would be extremely helpful as I've reached a dead end. Bellow are my jars and my exception.
avax.validation.ValidationException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:271)
at org.glassfish.jersey.server.validation.internal.ValidationBinder$DefaultConfigurationProvider.provide(ValidationBinder.java:122)
at org.glassfish.jersey.server.validation.internal.ValidationBinder$DefaultConfigurationProvider.provide(ValidationBinder.java:110)
at org.jvnet.hk2.internal.FactoryCreator.create(FactoryCreator.java:153)
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:471)
at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:83)
at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:71)
at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture$1.call(Cache.java:97)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
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:122)
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2072)
at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:114)
at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:698)
at org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(ThreeThirtyResolver.java:78)
at org.jvnet.hk2.internal.ClazzCreator.resolve(ClazzCreator.java:211)
at org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:234)
at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:357)
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:471)
at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:83)
at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:71)
at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture$1.call(Cache.java:97)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
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:122)
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2072)
at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:114)
at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:88)
at org.jvnet.hk2.internal.FactoryCreator.create(FactoryCreator.java:135)
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:471)
at org.jvnet.hk2.internal.PerLookupContext.findOrCreate(PerLookupContext.java:70)
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2072)
at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:767)
at org.jvnet.hk2.internal.ServiceLocatorImpl.getUnqualifiedService(ServiceLocatorImpl.java:774)
at org.jvnet.hk2.internal.IterableProviderImpl.get(IterableProviderImpl.java:111)
at org.glassfish.jersey.server.model.ResourceMethodInvoker$Builder.build(ResourceMethodInvoker.java:153)
at org.glassfish.jersey.server.internal.routing.RuntimeModelBuilder.createInflector(RuntimeModelBuilder.java:128)
at org.glassfish.jersey.server.internal.routing.RuntimeModelBuilder.createMethodRouter(RuntimeModelBuilder.java:115)
at org.glassfish.jersey.server.internal.routing.RuntimeModelBuilder.createResourceMethodRouters(RuntimeModelBuilder.java:309)
at org.glassfish.jersey.server.internal.routing.RuntimeModelBuilder.buildModel(RuntimeModelBuilder.java:173)
at org.glassfish.jersey.server.internal.routing.Routing$Builder.buildStage(Routing.java:196)
at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:587)
at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:184)
at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:350)
at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:347)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:347)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:390)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:172)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:364)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1231)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1031)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4914)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5201)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

I had a hard time figuring out how to get the dependencies for Jersey 2 configured. I use Maven (recommended) and I know you said you weren't using it but I can show you how my pom.xml is set up and what mvn dependency:list says are my dependencies (only relevant part of pom.xml shown):
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
</dependency>
</dependencies>
<!--============================= properties =============================-->
<properties>
<jersey.version>2.12</jersey.version>
</properties>
And here's what Maven says are my Jersey/Jackson dependencies:
com.fasterxml.jackson.core:jackson-annotations:jar:2.3.2:compile
com.fasterxml.jackson.core:jackson-core:jar:2.3.2:compile
com.fasterxml.jackson.core:jackson-databind:jar:2.3.2:compile
com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.3.2:compile
com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.3.2:compile
com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.3.2:compile
javax.servlet:javax.servlet-api:jar:3.1.0:compile
javax.validation:validation-api:jar:1.1.0.Final:compile
javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile
org.glassfish.hk2:hk2-api:jar:2.3.0-b10:compile
org.glassfish.hk2:hk2-locator:jar:2.3.0-b10:compile
org.glassfish.hk2:hk2-utils:jar:2.3.0-b10:compile
org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:compile
org.glassfish.hk2.external:aopalliance-repackaged:jar:2.3.0-b10:compile
org.glassfish.hk2.external:javax.inject:jar:2.3.0-b10:compile
org.glassfish.jersey.bundles.repackaged:jersey-guava:jar:2.12:compile
org.glassfish.jersey.containers:jersey-container-servlet-core:jar:2.12:compile
org.glassfish.jersey.core:jersey-client:jar:2.12:compile
org.glassfish.jersey.core:jersey-common:jar:2.12:compile
org.glassfish.jersey.core:jersey-server:jar:2.12:compile
org.glassfish.jersey.media:jersey-media-json-jackson:jar:2.12:compile

Related

Getting NoClassDefFoundError while running my Cucumber Automation

I am facing the following issue while running my automation. This is what I am getting on the console.
io.cucumber.core.exception.CucumberException: java.lang.NoClassDefFoundError: io/cucumber/messages/internal/com/google/protobuf/GeneratedMessageV3
at io.cucumber.core.plugin.PluginFactory.newInstance(PluginFactory.java:120)
at io.cucumber.core.plugin.PluginFactory.instantiate(PluginFactory.java:99)
at io.cucumber.core.plugin.PluginFactory.create(PluginFactory.java:63)
at io.cucumber.core.plugin.Plugins.createPlugins(Plugins.java:32)
at io.cucumber.core.plugin.Plugins.<init>(Plugins.java:25)
at io.cucumber.testng.TestNGCucumberRunner.<init>(TestNGCucumberRunner.java:108)
at io.cucumber.testng.AbstractTestNGCucumberTests.setUpClass(AbstractTestNGCucumberTests.java:27)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62)
at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:385)
at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:321)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:176)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:122)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.testng.TestRunner.privateRun(TestRunner.java:794)
at org.testng.TestRunner.run(TestRunner.java:596)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:377)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:371)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:332)
at org.testng.SuiteRunner.run(SuiteRunner.java:276)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1212)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1134)
at org.testng.TestNG.runSuites(TestNG.java:1063)
at org.testng.TestNG.run(TestNG.java:1031)
at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109)
Caused by: java.lang.NoClassDefFoundError: io/cucumber/messages/internal/com/google/protobuf/GeneratedMessageV3
at com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter.(ExtentCucumberAdapter.java:91)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at io.cucumber.core.plugin.PluginFactory.newInstance(PluginFactory.java:116)
... 31 more
Caused by: java.lang.ClassNotFoundException: io.cucumber.messages.internal.com.google.protobuf.GeneratedMessageV3
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)
... 37 more
Hi I had the same problem when cucumber 7 came out, and just today I was able to solve it, basically what I did was to update the versions of some other frameworks that might be affected by the cucumber version as well (on my pom.xml file). These are the frameworks that I use in the stable version:
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.0.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>7.0.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.0.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.4.0</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>5.0.8</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>klov-reporter</artifactId>
<version>5.0.8</version>
</dependency>
<dependency>
<groupId>tech.grasshopper</groupId>
<artifactId>extent-pdf-report</artifactId>
<version>1.7.3</version>
</dependency>
<dependency>
<groupId>tech.grasshopper</groupId>
<artifactId>extentreports-cucumber7-adapter</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-cucumber7-jvm</artifactId>
<version>2.17.2</version>
</dependency>
I hope this helps to solve your problem, best regards!
Ahh, this is a tricky one. From the 'PluginFactory' stacktrace, I guess its caused by this:
You have a class which contains step bindings ("Given I login" for example).
To create that class you require specflow to Inject some class into the constructor (dependancy injection). If THAT class is in another project, but the StepAssembly (see specflow.json or app.config) or project reference is not correct this can happen.
See code example (C# unfortunatly, but the point should be clear)
[Binding]
public class Test{
public Test(ThisClassNotInAssembly getMe){
getMe.SomeFunction();
}
}
Other option is that a step requires a transform (from string to MyNotDependancy class). Where again, the class is in another project and at runtime the dependancy fails.
To find out which class was loaded (and which was not, respectively), run Java in verbose mode but limited to classloading like so:
java -verbose:class ...
From that output you should be able to decide which exact class was missing. If again you are looking at GeneratedMessageV3, try to look at the source code of that class. It may be that some static initializer is throwing an exception that simply told the JVM that this class could not be loaded successfully.

configuration Elasticsearch to java SpringBoot Application

I am trying to configure Elastic to SpringBoot Application with Jdk 1.8 and elastic search Versi7.6.61
and Current spring version 2.2.5.RELEASE
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.5.RELEASE</version>
<relativePath/>
//these are pom for elastic search
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>${org.elasticsearch}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>${org.elasticsearch}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client-sniffer</artifactId>
<version>${org.elasticsearch}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>${org.elasticsearch}</version>
</dependency>
currently, I am using the latest release of Elasticsearch version 7.6.1
I got the following the Java JDK version is 1.8 Exception
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elasticsearchRestHighLevelClient' defined in class path resource \[org/springframework/boot/autoconfigure/elasticsearch/rest/RestClientConfigurations$RestHighLevelClientConfiguration.class\]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class \[org.elasticsearch.client.RestHighLevelClient\] from ClassLoader \[sun.misc.Launcher$AppClassLoader#18b4aac2\]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:572) ~\[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE\]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~\[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE\]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~\[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE\]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~\[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE\]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~\[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE\]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~\[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE\]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879) ~\[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE\]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~\[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE\]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~\[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE\]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~\[spring-boot-2.2.3.RELEASE.jar:2.2.3.RELEASE\]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) \[spring-boot-2.2.3.RELEASE.jar:2.2.3.RELEASE\]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) \[spring-boot-2.2.3.RELEASE.jar:2.2.3.RELEASE\]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) \[spring-boot-2.2.3.RELEASE.jar:2.2.3.RELEASE\]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) \[spring-boot-2.2.3.RELEASE.jar:2.2.3.RELEASE\]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) \[spring-boot-2.2.3.RELEASE.jar:2.2.3.RELEASE\]
at io.dz.ReIndexing.main(ReIndexing.java:13) \[classes/:na\]
Caused by: java.lang.IllegalStateException: Failed to introspect Class \[org.elasticsearch.client.RestHighLevelClient\] from ClassLoader \[sun.misc.Launcher$AppClassLoader#18b4aac2\]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481) ~\[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE\]
at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:321) ~\[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE\]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.buildLifecycleMetadata(InitDestroyAnnotationBeanPostProcessor.java:232) ~\[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE\]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.findLifecycleMetadata(InitDestroyAnnotationBeanPostProcessor.java:210) ~\[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE\]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(InitDestroyAnnotationBeanPostProcessor.java:149) ~\[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE\]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:310) ~\[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE\]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:1094) ~\[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE\]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:569) ~\[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE\]
... 15 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/elasticsearch/client/Cancellable
at java.lang.Class.getDeclaredMethods0(Native Method) ~\[na:1.8.0_161\]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~\[na:1.8.0_161\]
at java.lang.Class.getDeclaredMethods(Class.java:1975) ~\[na:1.8.0_161\]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463) ~\[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE\]
... 22 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.elasticsearch.client.Cancellable
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~\[na:1.8.0_161\]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~\[na:1.8.0_161\]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) ~\[na:1.8.0_161\]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~\[na:1.8.0_161\]
... 26 common frames omitted
//when I am trying to configure Elastic search I got the Exception class not Found
thanks in Advance to reply][1]][1]
The high-level REST client which you have added internally calls low-level REST client
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>${org.elasticsearch}</version>
</dependency>
This , low level client is loaded by core dependency itself, but it seems it does not correspond to version 7.x (You can check the same in your external libraries list).
In my system elastcsearch-rest-client that got added was of version 6.4.2 while I was using elastcisearch of version 7.5.0
So, in this case you can add dependency related to elasticsearch-rest-client manually in pom.xml by adding :
<dependency>
  <groupId> org.elasticsearch.client </ groupId>
  <artifactId> elasticsearch-rest-client </ artifactId>
  <version>${org.elasticsearch}</ version>
</ dependency>
So, your complete pom.xml related to elastic search dependencies should look like :
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>${org.elasticsearch}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>${org.elasticsearch}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client-sniffer</artifactId>
<version>${org.elasticsearch}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>${org.elasticsearch}</version>
</dependency>
<dependency>
  <groupId> org.elasticsearch.client </ groupId>
  <artifactId> elasticsearch-rest-client </ artifactId>
  <version>${org.elasticsearch}</ version>
</ dependency>
When using springboot with elasticsearch, you need to be explicit with some transitive dependencies as SpringBoot declares a version 6.4...
Basically you can put this in your pom.xml:
<properties>
<elasticsearch.version>7.6.1<elasticsearch.version>
</properties>
See documentation here: https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-customize-dependency-versions

War not getting deployed in weblogic on changing camel version

I have spring project that is using apache camel version 2.13.2 and when i try to update the version to 2.18.1. My war fails to start and throws the following error -
Target state: deploy failed on Server Common
java.lang.ClassNotFoundException: org.springframework.util.backoff.BackOff
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:981)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:942)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:83)
at weblogic.utils.classloaders.GenericClassLoader.doFindClass(GenericClassLoader.java:564)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:500)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:464)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:441)
at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:53)
at org.apache.camel.component.jms.JmsConfiguration.chooseMessageListenerContainerImplementation(JmsConfiguration.java:691)
at org.apache.camel.component.jms.JmsConfiguration.createMessageListenerContainer(JmsConfiguration.java:681)
at org.apache.camel.component.jms.JmsEndpoint.createMessageListenerContainer(JmsEndpoint.java:183)
at org.apache.camel.component.jms.JmsEndpoint.createConsumer(JmsEndpoint.java:178)
at org.apache.camel.component.jms.JmsEndpoint.createConsumer(JmsEndpoint.java:71)
at org.apache.camel.impl.EventDrivenConsumerRoute.addServices(EventDrivenConsumerRoute.java:69)
at org.apache.camel.impl.DefaultRoute.onStartingServices(DefaultRoute.java:103)
at org.apache.camel.impl.RouteService.doWarmUp(RouteService.java:167)
at org.apache.camel.impl.RouteService.warmUp(RouteService.java:141)
at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:3615)
at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3522)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3308)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3162)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:182)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2957)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2953)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2976)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2953)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2920)
at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:275)
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:136)
at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:353)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:98)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:333)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:776)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:485)
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 weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:725)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:326)
at weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:196)
at weblogic.servlet.provider.WlsSecurityProvider.runAsForUserCode(WlsSecurityProvider.java:203)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:71)
at weblogic.servlet.internal.EventsManager.executeContextListener(EventsManager.java:251)
at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:204)
at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:189)
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1910)
at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3063)
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1830)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:875)
at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:360)
at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:356)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:138)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:237)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:232)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:82)
at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:52)
at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:753)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:263)
at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:53)
at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:165)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:601)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:171)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:121)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:343)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:895)
at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1422)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:454)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:181)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:643)
at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348)
at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333)
at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54)
at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:617)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:397)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:346)
Is there any specific reason why this is happening or what and where i should look as i am really clueless as to why change in camel results in spring's class not being found?
And apart from this, all my routes made in java configuration are not working and throw exceptions like consumer not found for endpoint for all the routes that consume message from given endpoint but same seems to work in when writen in xml. Is there any reason for this? I am using camel 2.13.2 and java configuration for routes is done by extending RouteBuilder, also i have other routes that are already written in xml and the xml has been added in contextConfigLocation. Is it somehow related to adding xml in contextConfig?
camel-jms:2.18.1 component uses spring-jms with version 4.3.4.RELEASE. You need to upgrade to spring 4.3.4.RELEASE or migrate camel-jms component to camel-sjms, which does not use spring. You can find all relevant dependencies in camel-parent-2.18.1.pom
If you are using Maven, the best way to keep your dependencies consistent is using BOM:
<dependencyManagement>
<dependnecies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-parent</artifactId>
<version>2.18.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependnecies>
</dependencyManagement>
and then exclude version for all camel and spring related dependencies, which you are using in application.
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>
...
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>

Jersey2, Hk2 dependency injection (automatically) gives AbstractMethodError: org.jvnet.hk2.internal.DynamicConfigurationImpl.addIdempotentFilter

Stuck on this problem for a while. I'm trying to integrate
Tomcat 9, JDK 10, Jersey 2.23, HK2 (for DI) along with Automatic dependency injection. I've followed this tutorial, but getting below error, I've searched a lot but couldn't find anything on that.
I've used dependency to generate "META-INF/hk2-locator/default" which is getting generate properly.
Dependency
<dependency>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-metadata-generator</artifactId>
<version>2.4.0</version>
</dependency>
Error stack
SEVERE: Servlet [MyApplication] in web application [/javaeeLearning] threw load() exception
java.lang.AbstractMethodError: org.jvnet.hk2.internal.DynamicConfigurationImpl.addIdempotentFilter([Lorg/glassfish/hk2/api/Filter;)V
at org.glassfish.hk2.utilities.ServiceLocatorUtilities.addClasses(ServiceLocatorUtilities.java:451)
at org.glassfish.hk2.utilities.ServiceLocatorUtilities.enablePerThreadScope(ServiceLocatorUtilities.java:107)
at org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:141)
at org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:123)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:330)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:392)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1124)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1079)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:971)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4829)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5143)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1429)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:944)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1429)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:944)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:261)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:682)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)
Code for automatic DI
import java.io.IOException;
import javax.ws.rs.core.Feature;
import javax.ws.rs.core.FeatureContext;
import org.glassfish.hk2.api.DynamicConfigurationService;
import org.glassfish.hk2.api.MultiException;
import org.glassfish.hk2.api.Populator;
import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.hk2.utilities.ClasspathDescriptorFileFinder;
import org.glassfish.hk2.utilities.DuplicatePostProcessor;
import org.glassfish.jersey.ServiceLocatorProvider;
//This class will cause the HK2 framework to scan your classpath for inhabitants files that are created using the hk2-inhabitant-generator.
public class MyDiscoverableFeature implements Feature {
#Override
public boolean configure(FeatureContext context) {
ServiceLocator locator = ServiceLocatorProvider.getServiceLocator(context);
DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);
Populator populator = dcs.getPopulator();
try {
populator.populate(new ClasspathDescriptorFileFinder(this.getClass().getClassLoader()),
new DuplicatePostProcessor());
} catch (IOException | MultiException ex) {
System.out.println("exception occurred " + ex);
}
return true;
}
}
public class ResourceConfiguration extends ResourceConfig {
public ResourceConfiguration() {
// register(ControllerTest.class);
// register(new MyBinder());
this.packages(true, "com.walmart.services.*");
// for auto scan
register(MyDiscoverableFeature.class);
}
}
I've one interface "IUserService" annotated with org.jvnet.hk2.annotations.Contract (#Contract) with implmentation "UserServiceImpl" annotated with org.jvnet.hk2.annotations.Service (#Service)
And i've one controller class:
#Path("/sayHello")
public class ControllerTest {
#Inject
private IUserService service;
#Inject
private ServicesTest service2;
#GET
#Path("/{name}")
#Produces(MediaType.TEXT_PLAIN)
public String method(#PathParam("name") String msg) {
return service.method() + msg;
}
#GET
#Path("/v2/{name}")
#Produces(MediaType.TEXT_PLAIN)
public String method2(#PathParam("name") String msg) {
return service.method() + msg;
}
}
Along with below dependencies
<dependencies>
<!-- https://mvnrepository.com/artifact/javax/javaee-api -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs-api -->
<!-- Jersey2.x Dependencies -->
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-server -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey2.version}</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-utils</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>javax.inject</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-common -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>${jersey2.version}</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-utils</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>javax.inject</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${jersey2.version}</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>javax.inject</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Jersey2.x Dependency injection -->
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.inject/jersey-hk2 -->
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>2.27</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.media/jersey-media-json-jackson -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey2.version}</version>
</dependency>
<!-- generate hk2 metadata (called inhabitant files) t -->
<!-- https://mvnrepository.com/artifact/org.glassfish.hk2/hk2-metadata-generator -->
<dependency>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-metadata-generator</artifactId>
<version>2.4.0</version>
</dependency>
</dependencies>
Update
The above issue is got fixed as soon i remove dependency conflict.
But now, my rest resources are not getting detect at all so i'm getting 404 error on my rest resource.
Though, if i uncomment this line in "ResourceConfiguration"
// register(ControllerTest.class);
Then it start showing up.
But i don't want to do this for every singel rest resource (not practical )
Please help to solve this problem
#PaulSamsotha; As mention by you to change from ;
this.packages(true, "com.walmart.services.*");
to
this.packages(true, "com.walmart.services");
Gives me below error on server start;
here is the full error;
Don't know the cause of it but as soon as i remove ".*", on server start i get below error.
Sep 27, 2018 2:42:49 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet [MyApplication] in web application [/javaeeLearning] threw load() exception
java.lang.IllegalArgumentException
at jersey.repackaged.org.objectweb.asm.ClassReader.<init>(ClassReader.java:170)
at jersey.repackaged.org.objectweb.asm.ClassReader.<init>(ClassReader.java:153)
at jersey.repackaged.org.objectweb.asm.ClassReader.<init>(ClassReader.java:424)
at org.glassfish.jersey.server.internal.scanning.AnnotationAcceptingListener.process(AnnotationAcceptingListener.java:170)
at org.glassfish.jersey.server.ResourceConfig.scanClasses(ResourceConfig.java:915)
at org.glassfish.jersey.server.ResourceConfig._getClasses(ResourceConfig.java:869)
at org.glassfish.jersey.server.ResourceConfig.getClasses(ResourceConfig.java:775)
at org.glassfish.jersey.server.ResourceConfig$WrappingResourceConfig._getClasses(ResourceConfig.java:1147)
at org.glassfish.jersey.server.ResourceConfig.getClasses(ResourceConfig.java:775)
at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1206)
at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1178)
at org.glassfish.jersey.server.ResourceConfig.createRuntimeConfig(ResourceConfig.java:1174)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:345)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:392)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1124)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1079)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:971)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4829)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5143)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1429)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:944)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1429)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:944)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:261)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:682)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)
Moreover i found the above line does not makking any sense, even i remove it completly with register of controller everything works fine.

java.lang.NoSuchMethodError: ognl.SimpleNode.isSequence(Lognl/OgnlContext;)Z

I am trying to upgrade my struts version from 2.3.3 to 2.3.33.post running the apache tomcat 7 I am getting the below error.
SEVERE: Exception starting filter struts2
java.lang.NoSuchMethodError: ognl.SimpleNode.isSequence(Lognl/OgnlContext;)Z
at com.opensymphony.xwork2.ognl.OgnlUtil.isEvalExpression(OgnlUtil.java:320)
at com.opensymphony.xwork2.ognl.OgnlUtil.checkEnableEvalExpression(OgnlUtil.java:431)
at com.opensymphony.xwork2.ognl.OgnlUtil.compileAndExecute(OgnlUtil.java:386)
at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:298)
at com.opensymphony.xwork2.ognl.OgnlUtil.internalSetProperty(OgnlUtil.java:627)
at com.opensymphony.xwork2.ognl.OgnlUtil.setProperties(OgnlUtil.java:190)
at com.opensymphony.xwork2.ognl.OgnlUtil.setProperties(OgnlUtil.java:217)
at com.opensymphony.xwork2.ognl.OgnlUtil.setProperties(OgnlUtil.java:204)
at com.opensymphony.xwork2.ognl.OgnlReflectionProvider.setProperties(OgnlReflectionProvider.java:58)
at com.opensymphony.xwork2.factory.DefaultInterceptorFactory.buildInterceptor(DefaultInterceptorFactory.java:43)
at com.opensymphony.xwork2.ObjectFactory.buildInterceptor(ObjectFactory.java:209)
at com.opensymphony.xwork2.config.providers.InterceptorBuilder.constructInterceptorReference(InterceptorBuilder.java:70)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.lookupInterceptorReference(XmlConfigurationProvider.java:1114)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadInterceptorStack(XmlConfigurationProvider.java:932)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadInterceptorStacks(XmlConfigurationProvider.java:945)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadInterceptors(XmlConfigurationProvider.java:968)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:537)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:295)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:264)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:978)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:446)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:490)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5633)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1260)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:2002)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
I am using ognl-3.0.4 jar
For googlers, the problem in my case (when I got a similar exception) was a mismatch between thymeleaf and ognl versions.
The versions I used later that worked fine together:
<dependency>
<groupId>ognl</groupId>
<artifactId>ognl</artifactId>
<version>3.0.12</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
<version>3.0.12.RELEASE</version>
</dependency>
The problem has been resolved now,it is the jar issue after upgrading the struts version step by step 2.3.3 to 2.3.15 then 2.3.28 and then 2.3.33, i have not faced this problem.

Categories

Resources