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
Related
I tried to create an application based on an Amigoscode video on YouTube (https://www.youtube.com/watch?v=p485kUNpPvE&t=2432s) but I have errors most probably due to the version that I use. I can't figure out what to fix. Could you please help me? The error that I get is the following:
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [/.../Customer$CustomerBuilder.class]; nested exception is org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [/.../Customer$CustomerBuilder.class]; nested exception is java.lang.IllegalArgumentException: Unsupported class file major version 63
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:457) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:316) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:276) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:128) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:296) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:250) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:207) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:175) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:331) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:247) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:311) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:112) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:746) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:564) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.5.7.jar:2.5.7]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:765) ~[spring-boot-2.5.7.jar:2.5.7]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:445) ~[spring-boot-2.5.7.jar:2.5.7]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[spring-boot-2.5.7.jar:2.5.7]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354) ~[spring-boot-2.5.7.jar:2.5.7]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-2.5.7.jar:2.5.7]
at com.ioannispriovolos.customer.CustomerApplication.main(CustomerApplication.java:9) ~[classes/:na]
Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [/.../Customer$CustomerBuilder.class]; nested exception is java.lang.IllegalArgumentException: Unsupported class file major version 63
at org.springframework.core.type.classreading.SimpleMetadataReader.getClassReader(SimpleMetadataReader.java:60) ~[spring-core-5.3.13.jar:5.3.13]
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:49) ~[spring-core-5.3.13.jar:5.3.13]
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103) ~[spring-core-5.3.13.jar:5.3.13]
at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:123) ~[spring-core-5.3.13.jar:5.3.13]
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:429) ~[spring-context-5.3.13.jar:5.3.13]
... 20 common frames omitted
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 63
at org.springframework.asm.ClassReader.<init>(ClassReader.java:199) ~[spring-core-5.3.13.jar:5.3.13]
at org.springframework.asm.ClassReader.<init>(ClassReader.java:180) ~[spring-core-5.3.13.jar:5.3.13]
at org.springframework.asm.ClassReader.<init>(ClassReader.java:166) ~[spring-core-5.3.13.jar:5.3.13]
at org.springframework.asm.ClassReader.<init>(ClassReader.java:287) ~[spring-core-5.3.13.jar:5.3.13]
at org.springframework.core.type.classreading.SimpleMetadataReader.getClassReader(SimpleMetadataReader.java:57) ~[spring-core-5.3.13.jar:5.3.13]
... 24 common frames omitted
Process finished with exit code 1
pom.xml
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
<spring.boot.maven.plugin.version>2.5.7</spring.boot.maven.plugin.version>
<spring.boot.dependencies.version>2.5.7</spring.boot.dependencies.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.dependencies.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<groupId>com.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.maven.plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
I was trying to create the application using the latest versions of SDK (openjdk-19), language level (17 - Sealed types, always-strict floating-point semantics) and on modules Language level (19 - No new language features). I am using the latest version of IntelliJ CE.
Spring Boot 2.5.7 does not work with JDK19 (...core.NestedIOException: ASM ClassReader failed to parse class file - probably d
furthermore your project is not even on the latest 2.5.X version. The 2.5.X lines works upto JDK18. The most recent version on 2.5.X line is 2.5.14.
Spring Boot 2.6.X will work up to JDK19
Spring Boot 2.7.X will work up to JDK19.
The 2.5.X, 2.6.X line are end of life see for details: https://spring.io/projects/spring-boot#support
You should migrate to Spring Boot 3.0.2.
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.
I have a SpringBoot application that was developed with JDK8 and was now ported to JDK11. I get the following exception at startup:
ERROR SpringApplication: Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'groovyMarkupConfigurer' defined in class path resource [org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfiguration$GroovyMarkupConfiguration.class]: Invocation of init method failed; nested exception is java.lang.reflect.InaccessibleObjectException: Unable to make jdk.internal.loader.ClassLoaders$AppClassLoader(jdk.internal.loader.ClassLoaders$PlatformClassLoader,jdk.internal.loader.URLClassPath) accessible: module java.base does not "opens jdk.internal.loader" to unnamed module #2e3967ea
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:140)
at de.ff.jf.bftag.alarmmonitor.Main.main(Main.java:38)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make jdk.internal.loader.ClassLoaders$AppClassLoader(jdk.internal.loader.ClassLoaders$PlatformClassLoader,jdk.internal.loader.URLClassPath) accessible: module java.base does not "opens jdk.internal.loader" to unnamed module #2e3967ea
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:340)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:280)
at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Constructor.java:189)
at java.base/java.lang.reflect.Constructor.setAccessible(Constructor.java:182)
at org.codehaus.groovy.reflection.CachedConstructor$1.run(CachedConstructor.java:44)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at org.codehaus.groovy.reflection.CachedConstructor.<init>(CachedConstructor.java:42)
at org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:79)
at org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:69)
at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:49)
at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:36)
at org.codehaus.groovy.reflection.CachedClass.getConstructors(CachedClass.java:268)
at groovy.lang.MetaClassImpl.<init>(MetaClassImpl.java:218)
at groovy.lang.MetaClassImpl.<init>(MetaClassImpl.java:228)
at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.createNormalMetaClass(MetaClassRegistry.java:171)
at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.createWithCustomLookup(MetaClassRegistry.java:161)
at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.create(MetaClassRegistry.java:144)
at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:253)
at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:285)
at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:295)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:261)
at org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(InvokerHelper.java:873)
at org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:906)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:898)
at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToBoolean(DefaultTypeTransformation.java:185)
at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.booleanUnbox(DefaultTypeTransformation.java:74)
at org.codehaus.groovy.control.customizers.ASTTransformationCustomizer.findASTTranformationClass(ASTTransformationCustomizer.groovy:209)
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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:151)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.callStatic(StaticMetaMethodSite.java:102)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:214)
at org.codehaus.groovy.control.customizers.ASTTransformationCustomizer.findPhase(ASTTransformationCustomizer.groovy:226)
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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:151)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.callStatic(StaticMetaMethodSite.java:102)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:214)
at org.codehaus.groovy.control.customizers.ASTTransformationCustomizer.<init>(ASTTransformationCustomizer.groovy:180)
at org.codehaus.groovy.control.customizers.ASTTransformationCustomizer.<init>(ASTTransformationCustomizer.groovy:188)
at groovy.text.markup.MarkupTemplateEngine.<init>(MarkupTemplateEngine.java:94)
at org.springframework.web.servlet.view.groovy.GroovyMarkupConfigurer.createTemplateEngine(GroovyMarkupConfigurer.java:159)
at org.springframework.web.servlet.view.groovy.GroovyMarkupConfigurer.afterPropertiesSet(GroovyMarkupConfigurer.java:152)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774)
... 15 more
Here is my pom.xml:
<dependencies>
<dependency>
<groupId>org.jxmapviewer</groupId>
<artifactId>jxmapviewer2</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.2.1.RELEASE</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
I have tried SpringWebStarter from 2.1.8 up to 2.2.1, I am always getting the same error.
I cannot use JDK8 again, since the computer has been updated from Windows 7 to Windows 10 and I am not willed to register at Oracle to download the JDK8 ;)
Has someone experienced this issue or does anyone have an idea how to solve this?
Your error is related to Java module system:
java.lang.reflect.InaccessibleObjectException: Unable to make jdk.internal.loader.ClassLoaders$AppClassLoader(jdk.internal.loader.ClassLoaders$PlatformClassLoader,jdk.internal.loader.URLClassPath) accessible: module java.base does not "opens jdk.internal.loader" to unnamed module #2e3967ea
Judging from the stack trace this is caused by Groovy so either your are using an old Groovy version that doesn't support JDK 9 or running code that imports jdk.internal.loader without declaring proper Java module access.
I'd start by checking that you have recent Groovy dependencies but a quick workaround would be to run the JVM with:
--add-opens java.base/jdk.internal.loader=ALL-UNNAMED
Exception arises in groovy autoconfiguration, so you can disable it in config:
#SpringBootApplication(exclude = {
GroovyTemplateAutoConfiguration.class})
or in property file:
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration
Also in my case next properties resolved this issue:
spring.groovy.template.enabled=false
spring.groovy.template.check-template-location=false
A project I work on is currently using Hibernate version 5.2.15.Final. When configuring the second-level cache, the project has been using org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory as the value for hibernate.cache.region.factory_class.
When I change the Hibernate version to 5.3.12.Final, SingletonEhCacheRegionFactory is no longer in that package. A class with that same name is available in the net.sf.ehcache.hibernate package, and I can use that with no compilation errors. But if I run it I get an error when it tries to build a session:
org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.cache.spi.RegionFactory]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:275)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
at org.hibernate.boot.internal.MetadataBuilderImpl$MetadataBuildingOptionsImpl.<init>(MetadataBuilderImpl.java:688)
at org.hibernate.boot.internal.MetadataBuilderImpl.<init>(MetadataBuilderImpl.java:123)
at org.hibernate.boot.internal.MetadataBuilderImpl.<init>(MetadataBuilderImpl.java:93)
If I dig deeper into the stack trace, the real error seems to be this:
Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory] as strategy [org.hibernate.cache.spi.RegionFactory]
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:133)
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveStrategy(StrategySelectorImpl.java:212)
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveStrategy(StrategySelectorImpl.java:169)
at org.hibernate.cache.internal.RegionFactoryInitiator.resolveRegionFactory(RegionFactoryInitiator.java:93)
at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:47)
at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:32)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:94)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
... 64 more
Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory]
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:137)
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:129)
... 71 more
Caused by: java.lang.NoClassDefFoundError: org/hibernate/cache/QueryResultsRegion
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:374)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:131)
... 72 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.cache.QueryResultsRegion
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 75 more
Here's what my pom.xml dependencies look like:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.3.12.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>5.3.12.Final</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.6.11</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>5.3.12.Final</version>
</dependency>
Okay, I think I figured out the problem. Previously my code had been fetching the full class name and path by doing:
SingletonEhCacheRegionFactory.class.getCanonicalName()
But in Hibernate 5.3 the class had been moved to an internal package, which is why I could no longer find it. If I used a hardcoded string with the old package name ("org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory"), I no longer get that exception.
I'm trying to deploy and start application with cxf and spring libraries in WebSphere 9.
The application has started with next errors in logs:
Caused by: org.apache.cxf.bus.extension.ExtensionException: Could not load extension class org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl.
at org.apache.cxf.bus.extension.Extension.tryClass(Extension.java:183)
at org.apache.cxf.bus.extension.Extension.getClassObject(Extension.java:199)
at org.apache.cxf.bus.extension.ExtensionManagerImpl.activateAllByType(ExtensionManagerImpl.java:139)
at org.apache.cxf.bus.extension.ExtensionManagerBus.<init>(ExtensionManagerBus.java:149)
at org.apache.cxf.bus.extension.ExtensionManagerBus.<init>(ExtensionManagerBus.java:161)
at **com.ttc.cg.audit.config.CxfAuditBusConfig.bus(CxfAuditBusConfig.java:29)
at comp.ttc.cg.audit.config.CxfAuditBusConfig$$EnhancerBySpringCGLIB$$36db2ba1.CGLIB$bus$0(<generated>)
at com.ttc.cg.audit.config.CxfAuditBusConfig$$EnhancerBySpringCGLIB$$36db2ba1$$FastClassBySpringCGLIB$$7738c735.invoke(<generated>)
at** org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
at com.ttc.cg.audit.config.CxfAuditBusConfig$$EnhancerBySpringCGLIB$$36db2ba1.bus(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:508)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 86 common frames omitted
I set "local class loading first" in server1 and application (class loader) parameters.
In POM file there are next dependencies:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
<version>3.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-simple</artifactId>
<version>3.2.1</version>
<scope>provided</scope>
</dependency>
And the class with errors contains next inmport:
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.interceptor.Interceptor;
import org.apache.cxf.message.Message;
Help me pls.