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.
Related
Embarked on my Infinispan journey today (we are moving from Apache JCS to Infinispan) and ran into the following (base) exception:
Caused by: org.infinispan.commons.CacheConfigurationException: ISPN000327: Cannot find a parser for element 'string-keyed-jdbc-store' in namespace 'urn:infinispan:config:store:jdbc:13.0'. Check that your configuration is up-to date for Infinispan '13.0.11.Final' and if you have the proper dependency in the classpath
at org.infinispan.configuration.parsing.ParserRegistry.findNamespaceParser(ParserRegistry.java:233)
at org.infinispan.configuration.parsing.ParserRegistry.parseElement(ParserRegistry.java:206)
at org.infinispan.configuration.parsing.ConfigurationBuilderHolder.handleAnyElement(ConfigurationBuilderHolder.java:139)
at org.infinispan.commons.configuration.io.AbstractConfigurationReader.handleAny(AbstractConfigurationReader.java:57)
at org.infinispan.configuration.parsing.CacheParser.parsePersistence(CacheParser.java:1397)
at org.infinispan.configuration.parsing.CacheParser.parseCacheElement(CacheParser.java:488)
at org.infinispan.configuration.parsing.CacheParser.parseSharedStateCacheElement(CacheParser.java:220)
at org.infinispan.configuration.parsing.CacheParser.parseReplicatedCache(CacheParser.java:1154)
at org.infinispan.configuration.parsing.Parser.parseCaches(Parser.java:849)
at org.infinispan.configuration.parsing.Parser.parseContainer(Parser.java:735)
at org.infinispan.configuration.parsing.Parser.readElement(Parser.java:85)
at org.infinispan.configuration.parsing.ParserRegistry.parseElement(ParserRegistry.java:209)
at org.infinispan.configuration.parsing.ParserRegistry.parse(ParserRegistry.java:187)
at org.infinispan.configuration.parsing.ParserRegistry.parse(ParserRegistry.java:175)
at org.infinispan.configuration.parsing.ParserRegistry.parse(ParserRegistry.java:157)
at org.infinispan.configuration.parsing.ParserRegistry.parse(ParserRegistry.java:141)
at org.infinispan.globalstate.impl.GlobalConfigurationManagerImpl.buildConfiguration(GlobalConfigurationManagerImpl.java:302)
at org.infinispan.globalstate.impl.GlobalConfigurationManagerImpl.createCacheLocally(GlobalConfigurationManagerImpl.java:277)
at org.infinispan.globalstate.impl.GlobalConfigurationStateListener.handleCreate(GlobalConfigurationStateListener.java:46)
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.infinispan.notifications.impl.AbstractListenerImpl$ListenerInvocationImpl.lambda$invoke$1(AbstractListenerImpl.java:424)
... 62 more
The code is as follows and exception is generated from getOrCreateCache.
GlobalConfigurationBuilder gcb = GlobalConfigurationBuilder.defaultClusteredBuilder();
EmbeddedCacheManager ecm = new DefaultCacheManager(gcb.build());
//now per cache configuration.
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.clustering().cacheMode(CacheMode.REPL_SYNC);
cb.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class)
.shared(true)
.dialect(DatabaseType.POSTGRES)
.table()
.dropOnExit(false)
.createOnStart(true)
.tableNamePrefix("INFINISPAN_TEST")
.idColumnName("ID_COLUMN").idColumnType("VARCHAR(255)")
.dataColumnName("DATA_COLUMN").dataColumnType("bytea")
.timestampColumnName("TIMESTAMP_COLUMN").timestampColumnType("BIGINT")
.segmentColumnName("SEGMENT_COLUMN").segmentColumnType("INT")
.connectionPool()
.connectionUrl("jdbc:postgresql://localhost:5432/testinfini")
.username("user")
.password("password")
.driverClass("org.postgresql.Driver");
Cache<String, String> cache = ecm.administration().withFlags(CacheContainerAdmin.AdminFlag.VOLATILE).getOrCreateCache("myCache", cb.build());
The dependencies have been collected post modifying the Embedded WeatherApp Sample pom.xml.
Here is a snippet of that too.
<properties>
<version.infinispan>13.0.11.Final</version.infinispan>
<version.javax.annotation.javax.annotation-api>1.3.1</version.javax.annotation.javax.annotation-api>
<version.protostream>4.4.4.Final</version.protostream>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-bom</artifactId>
<version>${version.infinispan}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-core</artifactId>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-cachestore-jdbc</artifactId>
<version>${version.infinispan}</version>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-cachestore-jdbc-common</artifactId>
<version>${version.infinispan}</version>
</dependency>
<dependency>
<groupId>org.infinispan.protostream</groupId>
<artifactId>protostream-processor</artifactId>
<version>${version.protostream}</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>${version.javax.annotation.javax.annotation-api}</version>
</dependency>
</dependencies>
Would be much grateful for any pointers as to what I am doing wrong here?
Alright, it was a dependency issue, this set below works.
agroal-api-1.12.jar
agroal-pool-1.12.jar
caffeine-2.8.4.jar
infinispan-cachestore-jdbc-13.0.11.Final.jar
infinispan-cachestore-jdbc-common-13.0.11.Final.jar
infinispan-commons-13.0.11.Final.jar
infinispan-core-13.0.11.Final.jar
jakarta.transaction-api-1.3.3.jar
jboss-logging-3.4.1.Final.jar
jboss-threads-2.3.3.Final.jar
jgroups-4.2.18.Final.jar
postgresql-42.4.1.jar
protostream-4.4.3.Final.jar
protostream-types-4.4.3.Final.jar
reactive-streams-1.0.3.jar
rxjava-3.0.4.jar
wildfly-common-1.3.0.Final.jar
Thanks for looking :) ...
I'm trying to implement a Camel to supply microservices applications, I want to call a HTTP route with my own headers with token, alias & etc. firstly I want to call an external endpoint like "http://outside.endpoint.com" and recive the JSON Response to treat the object internally.
My error:
2021-10-24 18:52:08,519 INFO [org.jbo.threads] (main) JBoss Threads version 3.4.2.Final
2021-10-24 18:52:08,981 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step org.apache.camel.quarkus.component.servlet.deployment.ServletProcessor#build threw an exception: java.lang.IllegalStateException: Map at least one servlet to a path using quarkus.camel.servlet.url-patterns or quarkus.camel.servlet.[your-servlet-name].url-patterns
at org.apache.camel.quarkus.component.servlet.deployment.ServletProcessor.build(ServletProcessor.java:62)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
at java.base/java.lang.Thread.run(Thread.java:833)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)
at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:418)
at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:276)
at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:67)
at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:92)
at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:441)
at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:65)
at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:137)
at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:93)
at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:145)
at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:63)
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step org.apache.camel.quarkus.component.servlet.deployment.ServletProcessor#build threw an exception: java.lang.IllegalStateException: Map at least one servlet to a path using quarkus.camel.servlet.url-patterns or quarkus.camel.servlet.[your-servlet-name].url-patterns
at org.apache.camel.quarkus.component.servlet.deployment.ServletProcessor.build(ServletProcessor.java:62)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
at java.base/java.lang.Thread.run(Thread.java:833)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)
at io.quarkus.builder.Execution.run(Execution.java:116)
at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:160)
at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:416)
... 9 more
Caused by: java.lang.IllegalStateException: Map at least one servlet to a path using quarkus.camel.servlet.url-patterns or quarkus.camel.servlet.[your-servlet-name].url-patterns
at org.apache.camel.quarkus.component.servlet.deployment.ServletProcessor.build(ServletProcessor.java:62)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
at java.base/java.lang.Thread.run(Thread.java:833)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)
2021-10-24 18:52:08,981 INFO [io.qua.dep.dev.IsolatedDevModeMain] (main) Attempting to start live reload endpoint to recover from previous Quarkus startup failure
2021-10-24 18:52:09,257 INFO [org.jbo.threads] (main) JBoss Threads version 3.4.2.Final
My application.properties:
quarkus.http.port= 8056
camel.component.servlet.mapping.context-path=/services/*
quarkus.camel.servlet.servlet-name=CamelServlet
My dependecies of pom.xml:
<dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- CAMEL -->
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-servlet</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-rest</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-core</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<artifactId>lombok</artifactId>
<groupId>org.projectlombok</groupId>
<version>1.18.20</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
My route that there are the camel-rest call to execute the getCompanies bean:
package com.example.control;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.rest.RestBindingMode;
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.core.Response;
#ApplicationScoped
public class CompanyRouter extends RouteBuilder {
#Override
public void configure() {
restConfiguration().component("restlet")
.host("localhost").port("8056")
.bindingMode(RestBindingMode.auto);;
rest("/api/people")
// HTTP: GET /api
.get()
.outType(Response.class)
.to("bean:getCompaniesBean"); // This will invoke the bean
}
}
my bean to call the method listCompanies:
package com.example.control;
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.core.Response;
#ApplicationScoped
public class GetCompaniesBean {
public Response listCompanies() {
return Response.ok("Joinha!").build();
}
}
If you are going to use the default CamelHttpTransportServlet, then you can supply a minimal configuration and just set quarkus.camel.servlet.url-patterns. For example:
quarkus.camel.servlet.url-patterns = /services/*
There's more information in the documenation here:
https://camel.apache.org/camel-quarkus/latest/reference/extensions/servlet.html#_additional_camel_quarkus_configuration
Unless you really need use servlets, it's probably better & simpler to use the platform-http component as your HTTP consumer:
https://camel.apache.org/camel-quarkus/latest/reference/extensions/platform-http.html
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 know this has been discussed a lot, but somehow none of the previously asked questions is applicable to my case.
When loading my application I get the following stacktrace:
Exception in thread "JavaFX Application Thread" java.lang.NoClassDefFoundError: org/springframework/dao/DataAccessException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2663)
at java.lang.Class.getConstructor0(Class.java:3067)
at java.lang.Class.newInstance(Class.java:408)
at sun.reflect.misc.ReflectUtil.newInstance(ReflectUtil.java:51)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:923)
at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:967)
at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:216)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:740)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2701)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2521)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2435)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2403)
at de.festo.rs.windows.FXApplStarter$1.run(FXApplStarter.java:29)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
at com.sun.javafx.application.PlatformImpl$$Lambda$55/29905907.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
at com.sun.javafx.application.PlatformImpl$$Lambda$54/20965065.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$46/6575340.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.springframework.dao.DataAccessException
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 24 more
In most of the threads I read concerning similar errors people were indeed missing the spring-tx jar which I definately don´t.
It is declared in my maven dependencies along with the other spring jars neededd like this:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
When investigating my deployed output the jars are there as well.
Nevertheless the mentioned error is thrown. I am really desperate with this.
Please note, that the application is not a WebApp but kind of a standalone application loaded from another program.
Funny thing is that my colleague can´t reproduce the error. For that reason I guess it´s some kind of race condition between my JavaFX loader loading the result of the spring-jdbc query into its datamodel. I don´t have any proof for this, it´s just kind of a gut instinct.
Any help or tipp would be really appreciated.
If further information is needed please let me know.
Class : org.springframework.dao.DataAccessException is defined in Spring-DAO. Check if have below dependency.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-dao</artifactId>
<version>2.0.8</version>
</dependency>
to fix this issue i have just moved the application.java under the base package like i have created groupid demo.test.activemq and created the same package name in src folder and then restarted. it works for me.
Another posibility is, that you hide some dependencies through a scope like test:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<scope>test</scope>
</dependency>
Just remove the scope (or set the default: compile)
I'm having some trouble with the PrepareForTest annotation and creating a new instance of an AmazonSQSClient.
I'm writing a Jenkins plugin and unfortunately need to mock the FormValidation static class in order to ensure that warning and error messages are produced on field validation of my plugin. However when creating an instance of AmazonSQSClient I get an org.apache.http.conn.ssl.SSLInitializationException
I've abstracted it down to a very simple example, here's my test file:
package com.test;
import com.amazonaws.services.sqs.AmazonSQS;
import com.amazonaws.services.sqs.AmazonSQSClient;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
#RunWith(PowerMockRunner.class)
public class SQSTest {
// This is for mimicking the mocking of FormValidation
private static class Foo {}
#Test
#PrepareForTest(Foo.class)
public void buildTest()
{
AmazonSQS sqs = new AmazonSQSClient();
}
}
On running this code I get the following error:
org.apache.http.conn.ssl.SSLInitializationException: Failure initializing default SSL context
at org.apache.http.conn.ssl.SSLSocketFactory.createDefaultSSLContext(SSLSocketFactory.java:360)
at org.apache.http.conn.ssl.SSLSocketFactory.getSocketFactory(SSLSocketFactory.java:175)
at org.apache.http.impl.conn.SchemeRegistryFactory.createDefault(SchemeRegistryFactory.java:49)
at org.apache.http.impl.conn.PoolingClientConnectionManager.<init>(PoolingClientConnectionManager.java:93)
at com.amazonaws.http.ConnectionManagerFactory.createPoolingClientConnManager(ConnectionManagerFactory.java:26)
at com.amazonaws.http.HttpClientFactory.createHttpClient(HttpClientFactory.java:87)
at com.amazonaws.http.AmazonHttpClient.<init>(AmazonHttpClient.java:121)
at com.amazonaws.AmazonWebServiceClient.<init>(AmazonWebServiceClient.java:66)
at com.amazonaws.services.sqs.AmazonSQSClient.<init>(AmazonSQSClient.java:189)
at com.amazonaws.services.sqs.AmazonSQSClient.<init>(AmazonSQSClient.java:93)
at com.test.SQSTest.buildTest(SQSTest.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:68)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:310)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:88)
at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:96)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:294)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:127)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:82)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:282)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:86)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:207)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:146)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:120)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:33)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:45)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:118)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:101)
at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:53)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:77)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.security.NoSuchAlgorithmException: class configured for KeyManagerFactory: sun.security.ssl.KeyManagerFactoryImpl$SunX509 not a KeyManagerFactory
at sun.security.jca.GetInstance.checkSuperClass(GetInstance.java:258)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:237)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:164)
at javax.net.ssl.KeyManagerFactory.getInstance(KeyManagerFactory.java:138)
at org.apache.http.conn.ssl.SSLSocketFactory.createSSLContext(SSLSocketFactory.java:223)
at org.apache.http.conn.ssl.SSLSocketFactory.createDefaultSSLContext(SSLSocketFactory.java:358)
... 42 more
In order to help anyone wanting to build and run this quickly here is my pom.xml file:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>test.sqs</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>hpi</packaging>
<properties>
<!--
explicitly specifying the latest version here because one we get from the parent POM
tends to lag behind a bit
-->
<maven-hpi-plugin.version>1.96</maven-hpi-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.5.1</version>
</dependency>
</dependencies>
</project>
When the annotation #PrepareForTest(Foo.class) is removed from the method the test runs fine.
I was wondering if someone could explain why this is happening and if there is a work around for it or a way to avoid mocking the FormValidation class?
Thanks.
Try to add #PowerMockIgnore("org.apache.http.conn.ssl.*") annotation to your class
As #Natalie already mentioned, you can work with the #PowerMockIgnore() annotation. Maybe you need to ignore the packages javax.net.ssl.* and / or javax.crypto.*:
#PowerMockIgnore({"org.apache.http.conn.ssl.*", "javax.net.ssl.*" , "javax.crypto.*"})
You can get here some background information:
https://groups.google.com/forum/#!topic/powermock/v4nreP2AnOQ
This is most likely because SSLContext is loaded by the bootstrap classloader and PowerMock cannot byte-code manipulate these classes. You have to use this approach to mock that method.
/Johan Haleby