I am using Spring Boot to test a upload functionality, and getting
'Required MultipartFile parameter 'file' is not present'
error. Following are the 1) JSP, 2) Controller 3) Config Class 4) embedded tomcat log.
JSP page
----------------------------------------------------------------------------
<!DOCTYPE html>
<%# taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html lang="en">
<body>
<br>Message: ${message}
<h2>List Of Objects</h2>
<br>
<h2>Upload New File to this Bucket</h2>
<form action="uploadObject" method="post" enctype="multipart/form-data">
<table width="60%" border="1" cellspacing="0">
<tr>
<td width="35%"><strong>File to upload</strong></td>
<td width="65%"><input type="file" name="file" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Add" /></td>
</tr>
</table>
</form>
</body>
</html>
2. Controller:
#RequestMapping(value = "/uploadObject", method = RequestMethod.POST)
#Override
public String upload(#RequestParam("file") MultipartFile file,
#RequestParam("bucketName") String bucketName,
Map<String, Object> model) {
LOG.info("Object name parameter is " + file.getOriginalFilename());
LOG.info("Bucket name parameter is " + bucketName);
....
}
3) Config Class:
package com.phi.piranha.client.config;
import javax.servlet.MultipartConfigElement;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.MultiPartConfigFactory;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
#Configuration
#EnableAutoConfiguration
#ComponentScan("com.phi.piranha")
public class PiranhaStorageServiceClientApplication extends
SpringBootServletInitializer {
#Override
protected SpringApplicationBuilder configure(
final SpringApplicationBuilder application) {
return application
.sources(PiranhaStorageServiceClientApplication.class);
}
#SuppressWarnings("PMD.SignatureDeclareThrowsException")
public static void main(final String[] args) throws Exception {
SpringApplication.run(PiranhaStorageServiceClientApplication.class,
args);
}
#Bean
MultipartConfigElement multipartConfigElement() {
MultiPartConfigFactory factory = new MultiPartConfigFactory();
factory.setMaxFileSize("1024KB");
factory.setMaxRequestSize("1024KB");
return factory.createMultipartConfig();
}
#Bean
CommonsMultipartResolver multipartResolver(){
return new CommonsMultipartResolver();
}
}
4) Emedded Tomcat log:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.0.0.RC4)
2014-03-28 14:41:01.216 INFO 2852 --- [ main] c.PiranhaStorageServiceClientApplication : Starting PiranhaStorageServiceClientApplication on USDSFOSFC1NBOPY with PID 2852 (C:\a\workspace\sandbox\s3-poc-client\target\classes started by 310152252)
2014-03-28 14:41:01.220 DEBUG 2852 --- [ main] o.s.boot.SpringApplication : Loading source class com.phi.piranha.client.config.PiranhaStorageServiceClientApplication
2014-03-28 14:41:01.270 INFO 2852 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#6f434304: startup date [Fri Mar 28 14:41:01 PDT 2014]; root of context hierarchy
2014-03-28 14:41:01.273 DEBUG 2852 --- [ main] ationConfigEmbeddedWebApplicationContext : Bean factory for org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#6f434304: org.springframework.beans.factory.support.DefaultListableBeanFactory#62b08658: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,piranhaStorageServiceClientApplication]; root of factory hierarchy
2014-03-28 14:41:01.897 INFO 2852 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'multipartResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=piranhaStorageServiceClientApplication; factoryMethodName=multipartResolver; initMethodName=null; destroyMethodName=(inferred); defined in class com.phi.piranha.client.config.PiranhaStorageServiceClientApplication] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.MultipartAutoConfiguration; factoryMethodName=multipartResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/MultipartAutoConfiguration.class]]
2014-03-28 14:41:02.188 DEBUG 2852 --- [ main] ationConfigEmbeddedWebApplicationContext : Using MessageSource [org.springframework.context.support.ResourceBundleMessageSource: basenames=[messages]]
2014-03-28 14:41:02.189 DEBUG 2852 --- [ main] ationConfigEmbeddedWebApplicationContext : Using ApplicationEventMulticaster [org.springframework.context.event.SimpleApplicationEventMulticaster#58a1c2bf]
2014-03-28 14:41:02.495 DEBUG 2852 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Code archive: C:\Users\310152252\.m2\repository\org\springframework\boot\spring-boot\1.0.0.RC4\spring-boot-1.0.0.RC4.jar
2014-03-28 14:41:02.495 DEBUG 2852 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Code archive: C:\Users\310152252\.m2\repository\org\springframework\boot\spring-boot\1.0.0.RC4\spring-boot-1.0.0.RC4.jar
2014-03-28 14:41:02.496 DEBUG 2852 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Document root: C:\a\workspace\sandbox\s3-poc-client\src\main\webapp
2014-03-28 14:41:02.546 INFO 2852 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Server initialized with port: 9090
2014-03-28 14:41:02.884 INFO 2852 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2014-03-28 14:41:02.885 INFO 2852 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/7.0.52
2014-03-28 14:41:03.077 INFO 2852 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2014-03-28 14:41:03.077 INFO 2852 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1811 ms
2014-03-28 14:41:03.810 INFO 2852 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2014-03-28 14:41:03.813 INFO 2852 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2014-03-28 14:41:04.356 INFO 2852 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2014-03-28 14:41:04.483 INFO 2852 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2014-03-28 14:41:04.483 INFO 2852 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2014-03-28 14:41:04.744 INFO 2852 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2014-03-28 14:41:04.763 DEBUG 2852 --- [ main] ationConfigEmbeddedWebApplicationContext : Unable to locate LifecycleProcessor with name 'lifecycleProcessor': using default [org.springframework.context.support.DefaultLifecycleProcessor#11a91abc]
2014-03-28 14:41:04.765 DEBUG 2852 --- [ main] utoConfigurationReportLoggingInitializer :
=========================
AUTO-CONFIGURATION REPORT
=========================
Positive matches:
-----------------
MessageSourceAutoConfiguration
- #ConditionalOnMissingBean (types: org.springframework.context.MessageSource; SearchStrategy: all) found no beans (OnBeanCondition)
PropertyPlaceholderAutoConfiguration#propertySourcesPlaceholderConfigurer
- #ConditionalOnMissingBean (types: org.springframework.context.support.PropertySourcesPlaceholderConfigurer; SearchStrategy: current) found no beans (OnBeanCondition)
JmxAutoConfiguration
- #ConditionalOnClass classes found: org.springframework.jmx.export.MBeanExporter (OnClassCondition)
- SpEL expression on org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration: ${spring.jmx.enabled:true} (OnExpressionCondition)
- #ConditionalOnMissingBean (types: org.springframework.jmx.export.MBeanExporter; SearchStrategy: all) found no beans (OnBeanCondition)
DispatcherServletAutoConfiguration
- found web application StandardServletEnvironment (OnWebApplicationCondition)
- #ConditionalOnClass classes found: org.springframework.web.servlet.DispatcherServlet (OnClassCondition)
DispatcherServletAutoConfiguration.DispatcherServletConfiguration
- no DispatcherServlet found (DispatcherServletAutoConfiguration.DefaultDispatcherServletCondition)
- #ConditionalOnClass classes found: javax.servlet.ServletRegistration (OnClassCondition)
EmbeddedServletContainerAutoConfiguration
- found web application StandardServletEnvironment (OnWebApplicationCondition)
EmbeddedServletContainerAutoConfiguration.EmbeddedTomcat
- #ConditionalOnClass classes found: javax.servlet.Servlet,org.apache.catalina.startup.Tomcat (OnClassCondition)
- #ConditionalOnMissingBean (types: org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; SearchStrategy: current) found no beans (OnBeanCondition)
HttpMessageConvertersAutoConfiguration
- #ConditionalOnClass classes found: org.springframework.http.converter.HttpMessageConverter (OnClassCondition)
HttpMessageConvertersAutoConfiguration#messageConverters
- #ConditionalOnMissingBean (types: org.springframework.boot.autoconfigure.web.HttpMessageConverters; SearchStrategy: all) found no beans (OnBeanCondition)
HttpMessageConvertersAutoConfiguration.ObjectMappers
- #ConditionalOnClass classes found: com.fasterxml.jackson.databind.ObjectMapper (OnClassCondition)
HttpMessageConvertersAutoConfiguration.ObjectMappers#jacksonObjectMapper
- #ConditionalOnMissingBean (types: com.fasterxml.jackson.databind.ObjectMapper; SearchStrategy: all) found no beans (OnBeanCondition)
HttpMessageConvertersAutoConfiguration.ObjectMappers#mappingJackson2HttpMessageConverter
- #ConditionalOnMissingBean (types: org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; SearchStrategy: all) found no beans (OnBeanCondition)
MultipartAutoConfiguration
- #ConditionalOnClass classes found: javax.servlet.Servlet,org.springframework.web.multipart.support.StandardServletMultipartResolver (OnClassCondition)
- #ConditionalOnBean (types: javax.servlet.MultipartConfigElement; SearchStrategy: all) found the following [multipartConfigElement] (OnBeanCondition)
ServerPropertiesAutoConfiguration
- found web application StandardServletEnvironment (OnWebApplicationCondition)
ServerPropertiesAutoConfiguration#serverProperties
- #ConditionalOnMissingBean (types: org.springframework.boot.autoconfigure.web.ServerProperties; SearchStrategy: current) found no beans (OnBeanCondition)
WebMvcAutoConfiguration
- found web application StandardServletEnvironment (OnWebApplicationCondition)
- #ConditionalOnClass classes found: javax.servlet.Servlet,org.springframework.web.servlet.DispatcherServlet,org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter (OnClassCondition)
- #ConditionalOnMissingBean (types: org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; SearchStrategy: all) found no beans (OnBeanCondition)
WebMvcAutoConfiguration#hiddenHttpMethodFilter
- #ConditionalOnMissingBean (types: org.springframework.web.filter.HiddenHttpMethodFilter; SearchStrategy: all) found no beans (OnBeanCondition)
WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter#defaultViewResolver
- #ConditionalOnMissingBean (types: org.springframework.web.servlet.view.InternalResourceViewResolver; SearchStrategy: all) found no beans (OnBeanCondition)
WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter#requestContextListener
- #ConditionalOnMissingBean (types: org.springframework.web.context.request.RequestContextListener; SearchStrategy: all) found no beans (OnBeanCondition)
Negative matches:
-----------------
RabbitAutoConfiguration
- required #ConditionalOnClass classes not found: org.springframework.amqp.rabbit.core.RabbitTemplate,com.rabbitmq.client.Channel (OnClassCondition)
AopAutoConfiguration
- required #ConditionalOnClass classes not found: org.aspectj.lang.annotation.Aspect,org.aspectj.lang.reflect.Advice (OnClassCondition)
BatchAutoConfiguration
- required #ConditionalOnClass classes not found: org.springframework.batch.core.launch.JobLauncher,org.springframework.jdbc.core.JdbcOperations (OnClassCondition)
JpaRepositoriesAutoConfiguration
- required #ConditionalOnClass classes not found: org.springframework.data.jpa.repository.JpaRepository (OnClassCondition)
MongoRepositoriesAutoConfiguration
- required #ConditionalOnClass classes not found: com.mongodb.Mongo,org.springframework.data.mongodb.repository.MongoRepository (OnClassCondition)
MongoTemplateAutoConfiguration
- required #ConditionalOnClass classes not found: com.mongodb.Mongo,org.springframework.data.mongodb.core.MongoTemplate (OnClassCondition)
DataSourceAutoConfiguration
- required #ConditionalOnClass classes not found: org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType (OnClassCondition)
DataSourceTransactionManagerAutoConfiguration
- required #ConditionalOnClass classes not found: org.springframework.jdbc.core.JdbcTemplate,org.springframework.transaction.PlatformTransactionManager (OnClassCondition)
JmsTemplateAutoConfiguration
- required #ConditionalOnClass classes not found: org.springframework.jms.core.JmsTemplate,javax.jms.ConnectionFactory (OnClassCondition)
DeviceResolverAutoConfiguration
- required #ConditionalOnClass classes not found: org.springframework.mobile.device.DeviceResolverHandlerInterceptor,org.springframework.mobile.device.DeviceHandlerMethodArgumentResolver (OnClassCondition)
MongoAutoConfiguration
- required #ConditionalOnClass classes not found: com.mongodb.Mongo (OnClassCondition)
HibernateJpaAutoConfiguration
- did not find HibernateEntityManager class (HibernateJpaAutoConfiguration.HibernateEntityManagerCondition)
ReactorAutoConfiguration
- required #ConditionalOnClass classes not found: reactor.spring.context.config.EnableReactor (OnClassCondition)
RedisAutoConfiguration
- required #ConditionalOnClass classes not found: org.springframework.data.redis.connection.lettuce.LettuceConnection,org.springframework.data.redis.core.RedisOperations,com.lambdaworks.redis.RedisClient (OnClassCondition)
SecurityAutoConfiguration
- required #ConditionalOnClass classes not found: org.springframework.security.authentication.AuthenticationManager (OnClassCondition)
ThymeleafAutoConfiguration
- required #ConditionalOnClass classes not found: org.thymeleaf.spring4.SpringTemplateEngine (OnClassCondition)
EmbeddedServletContainerAutoConfiguration.EmbeddedJetty
- required #ConditionalOnClass classes not found: org.eclipse.jetty.server.Server,org.eclipse.jetty.util.Loader (OnClassCondition)
WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter#beanNameViewResolver
- #ConditionalOnBean (types: org.springframework.web.servlet.View; SearchStrategy: all) found no beans (OnBeanCondition)
WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter#viewResolver
- #ConditionalOnBean (types: org.springframework.web.servlet.View; SearchStrategy: all) found no beans (OnBeanCondition)
WebSocketAutoConfiguration
- required #ConditionalOnClass classes not found: org.springframework.web.socket.WebSocketHandler (OnClassCondition)
2014-03-28 14:41:04.821 INFO 2852 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port: 9090
2014-03-28 14:41:04.829 INFO 2852 --- [ main] c.PiranhaStorageServiceClientApplication : Started PiranhaStorageServiceClientApplication in 4.231 seconds (JVM running for 5.249)
I figured out that there is an issue with the MultipartAutoConfiguration within spring boot. I disabled it and added #Bean in the web config and it worked. Based on the exception I saw that the Jackson Mapper was trying to resolve the multipart content instead of the multipart resolver itself.
Here is the snippet.
#EnableAutoConfiguration(exclude={MultipartAutoConfiguration.class}
Add the following in your webconfig class
#Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
#Bean(name = "multipartResolver")
public CommonsMultipartResolver multipartResolver() {
logger.info("Loading the multipart resolver");
CommonsMultipartResolver multipartResolver
= new CommonsMultipartResolver();
return multipartResolver;
}
I think that was a bug in Spring Boot RC4. Did you try with RC5 or a snapshot?
Related
This is my console output.
I have been trying to find and fix my spring boot error for days and couldn't find a solution. This error is making my application not work as intended. I have included both my console output and pom.xml. Please let me know what I have to fix in order for my application to run properly.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.0.0)
2022-12-03T17:35:11.248-05:00 INFO 20075 --- [ main] c.rdeleon.app.rest.RestApiApplication : Starting RestApiApplication using Java 17.0.3.1 with PID 20075 (/Users/ryandeleon/Desktop/Fall 2022/cen 4025/Documents/module13/sourcecode/rest/target/classes started by ryandeleon in /Users/ryandeleon/Desktop/Fall 2022/cen 4025/Documents/module13/sourcecode/rest)
2022-12-03T17:35:11.254-05:00 INFO 20075 --- [ main] c.rdeleon.app.rest.RestApiApplication : No active profile set, falling back to 1 default profile: "default"
2022-12-03T17:35:11.948-05:00 INFO 20075 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-12-03T17:35:12.025-05:00 INFO 20075 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 64 ms. Found 1 JPA repository interfaces.
2022-12-03T17:35:12.467-05:00 INFO 20075 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2022-12-03T17:35:12.544-05:00 INFO 20075 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 6.1.5.Final
2022-12-03T17:35:12.858-05:00 WARN 20075 --- [ main] org.hibernate.orm.deprecation : HHH90000021: Encountered deprecated setting [javax.persistence.sharedCache.mode], use [jakarta.persistence.sharedCache.mode] instead
2022-12-03T17:35:13.062-05:00 INFO 20075 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2022-12-03T17:35:13.484-05:00 INFO 20075 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection com.mysql.cj.jdbc.ConnectionImpl#3d615b2e
2022-12-03T17:35:13.487-05:00 INFO 20075 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2022-12-03T17:35:13.584-05:00 INFO 20075 --- [ main] SQL dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
2022-12-03T17:35:14.042-05:00 INFO 20075 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-12-03T17:35:14.057-05:00 INFO 20075 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2022-12-03T17:35:14.292-05:00 WARN 20075 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'apiControllers': Unsatisfied dependency expressed through field 'userRepo': Error creating bean with name 'userRepo' defined in com.rdeleon.app.rest.Repo.UserRepo defined in #EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class com.rdeleon.app.rest.Models.User
2022-12-03T17:35:14.293-05:00 INFO 20075 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2022-12-03T17:35:14.297-05:00 INFO 20075 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2022-12-03T17:35:14.307-05:00 INFO 20075 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2022-12-03T17:35:14.319-05:00 INFO 20075 --- [ main] .s.b.a.l.ConditionEvaluationReportLogger :
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2022-12-03T17:35:14.352-05:00 ERROR 20075 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'apiControllers': Unsatisfied dependency expressed through field 'userRepo': Error creating bean with name 'userRepo' defined in com.rdeleon.app.rest.Repo.UserRepo defined in #EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class com.rdeleon.app.rest.Models.User
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:712) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:692) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:127) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:481) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1397) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:961) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:915) ~[spring-context-6.0.2.jar:6.0.2]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584) ~[spring-context-6.0.2.jar:6.0.2]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring-boot-3.0.0.jar:3.0.0]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432) ~[spring-boot-3.0.0.jar:3.0.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-3.0.0.jar:3.0.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[spring-boot-3.0.0.jar:3.0.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[spring-boot-3.0.0.jar:3.0.0]
at com.rdeleon.app.rest.RestApiApplication.main(RestApiApplication.java:11) ~[classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepo' defined in com.rdeleon.app.rest.Repo.UserRepo defined in #EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class com.rdeleon.app.rest.Models.User
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1751) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1405) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1325) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:709) ~[spring-beans-6.0.2.jar:6.0.2]
... 19 common frames omitted
Caused by: java.lang.IllegalArgumentException: Not a managed type: class com.rdeleon.app.rest.Models.User
at org.hibernate.metamodel.model.domain.internal.JpaMetamodelImpl.managedType(JpaMetamodelImpl.java:181) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.managedType(MappingMetamodelImpl.java:496) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.managedType(MappingMetamodelImpl.java:99) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:77) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:69) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:246) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:211) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:194) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:81) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:317) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:279) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.data.util.Lazy.getNullable(Lazy.java:229) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.data.util.Lazy.get(Lazy.java:113) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:285) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:132) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1797) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1747) ~[spring-beans-6.0.2.jar:6.0.2]
... 29 common frames omitted
This is my POM.xml
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.rdeleon.app</groupId>
<artifactId>rest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>RestAPI</name>
<description>Sample Crud Rest API</description>
<properties>
<java.version>17</java.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.30</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Api Application should open instead of throwing an error.
I face the same issue, I don't know what exact reason for this but I think this issue happen because of the "spring-boot-starter-parent" dependency version in pom.xml.
So you can try this dependency version in pom.xml that works for me.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.1</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
So I have the same issues using this build
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
This does not happen when version changed to
<version>2.6.1</version>
Another fix I found that worked for 3.0.1,
the imports need to be changed from
import javax.persitence.*
import jakarta.persistence.*
So I think in your model class you are using javax instead of jakarta.
Also your POM.xml is using javax
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
executing 'mvn clean install' on producer side i get the error message.
According to logs the connection to the stub is established.
The next step verifying the contract throws an exception.
Contract
label: user-goes-online
input:
triggeredBy: onUserIsOnline()
outputMessage:
sentTo: user-presence
body:
user: amadeus
headers:
contentType: application/json
https://github.com/nusmanov/producer/blob/master/src/test/resources/contracts/user-presence.yaml
Code
Producer: https://github.com/nusmanov/producer
Consumer: https://github.com/nusmanov/consumer
Full Log
mvn clean install nodirbekusmanov#CFC02XL862JG5H
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< com.cdt:producer >--------------------------
[INFO] Building producer 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for com.sun.xml.bind:jaxb-osgi:jar:2.2.10 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # producer ---
[INFO] Deleting /Users/nodirbekusmanov/workspace/poc-consumer/2/producer/target
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # producer ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # producer ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /Users/nodirbekusmanov/workspace/poc-consumer/2/producer/target/classes
[INFO]
[INFO] --- spring-cloud-contract-maven-plugin:2.2.2.RELEASE:generateTests (default-generateTests) # producer ---
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/Users/nodirbekusmanov/.m2/repository/org/codehaus/groovy/groovy/2.5.9/groovy-2.5.9.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Generating server tests source code for Spring Cloud Contract Verifier contract verification
[INFO] Will use contracts provided in the folder [/Users/nodirbekusmanov/workspace/poc-consumer/2/producer/src/test/resources/contracts]
[INFO] Directory with contract is present at [/Users/nodirbekusmanov/workspace/poc-consumer/2/producer/src/test/resources/contracts]
[INFO] Test Source directory: /Users/nodirbekusmanov/workspace/poc-consumer/2/producer/target/generated-test-sources/contracts added.
[INFO] Using [com.cdt.producer.TestBase] as base class for test classes, [null] as base package for tests, [null] as package with base classes, base class mappings []
[INFO] Creating new class file [/Users/nodirbekusmanov/workspace/poc-consumer/2/producer/target/generated-test-sources/contracts/com/cdt/producer/ContractVerifierTest.java]
[INFO] Generated 1 test classes.
[INFO]
[INFO] --- spring-cloud-contract-maven-plugin:2.2.2.RELEASE:convert (default-convert) # producer ---
[INFO] Will use contracts provided in the folder [/Users/nodirbekusmanov/workspace/poc-consumer/2/producer/src/test/resources/contracts]
[INFO] Copying Spring Cloud Contract Verifier contracts to [/Users/nodirbekusmanov/workspace/poc-consumer/2/producer/target/stubs/META-INF/com.cdt/producer/0.0.1-SNAPSHOT/contracts]. Only files matching [.*] pattern will end up in the final JAR with stubs.
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Converting from Spring Cloud Contract Verifier contracts to WireMock stubs mappings
[INFO] Spring Cloud Contract Verifier contracts directory: /Users/nodirbekusmanov/workspace/poc-consumer/2/producer/src/test/resources/contracts
[INFO] Stub Server stubs mappings directory: /Users/nodirbekusmanov/workspace/poc-consumer/2/producer/target/stubs/META-INF/com.cdt/producer/0.0.1-SNAPSHOT/mappings
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) # producer ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] skip non existing resourceDirectory /Users/nodirbekusmanov/workspace/poc-consumer/2/producer/target/generated-test-resources/contracts
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # producer ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /Users/nodirbekusmanov/workspace/poc-consumer/2/producer/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) # producer ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.cdt.producer.ContractVerifierTest
00:03:39.986 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
00:03:39.996 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
00:03:40.034 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.cdt.producer.ContractVerifierTest] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
00:03:40.057 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither #ContextConfiguration nor #ContextHierarchy found for test class [com.cdt.producer.ContractVerifierTest], using SpringBootContextLoader
00:03:40.063 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.cdt.producer.ContractVerifierTest]: class path resource [com/cdt/producer/ContractVerifierTest-context.xml] does not exist
00:03:40.064 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.cdt.producer.ContractVerifierTest]: class path resource [com/cdt/producer/ContractVerifierTestContext.groovy] does not exist
00:03:40.064 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.cdt.producer.ContractVerifierTest]: no resource found for suffixes {-context.xml, Context.groovy}.
00:03:40.065 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.cdt.producer.ContractVerifierTest]: ContractVerifierTest does not declare any static, non-private, non-final, nested classes annotated with #Configuration.
00:03:40.128 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.cdt.producer.ContractVerifierTest]
00:03:40.191 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [/Users/nodirbekusmanov/workspace/poc-consumer/2/producer/target/classes/com/cdt/producer/ProducerApplication.class]
00:03:40.191 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found #SpringBootConfiguration com.cdt.producer.ProducerApplication for test class com.cdt.producer.ContractVerifierTest
00:03:40.293 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - #TestExecutionListeners is not present for class [com.cdt.producer.ContractVerifierTest]: using defaults.
00:03:40.294 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
00:03:40.315 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener#77d2e85, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener#3ecd267f, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener#58ffcbd7, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener#555cf22, org.springframework.test.context.support.DirtiesContextTestExecutionListener#6bb2d00b, org.springframework.test.context.transaction.TransactionalTestExecutionListener#3c9bfddc, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener#1a9c38eb, org.springframework.test.context.event.EventPublishingTestExecutionListener#319bc845, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener#4c5474f5, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener#2f4205be, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener#54e22bdd, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener#3bd418e4, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener#544820b7]
00:03:40.320 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext#aafcffa testClass = ContractVerifierTest, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration#6955cb39 testClass = ContractVerifierTest, locations = '{}', classes = '{class com.cdt.producer.ProducerApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[[ImportsContextCustomizer#235a0c16 key = [org.springframework.cloud.contract.verifier.messaging.stream.ContractVerifierStreamAutoConfiguration, org.springframework.cloud.contract.verifier.messaging.integration.ContractVerifierIntegrationConfiguration, org.springframework.cloud.contract.verifier.messaging.amqp.ContractVerifierAmqpAutoConfiguration, org.springframework.cloud.contract.verifier.messaging.amqp.RabbitMockConnectionFactoryAutoConfiguration, org.springframework.cloud.contract.verifier.messaging.camel.ContractVerifierCamelConfiguration, org.springframework.cloud.contract.verifier.messaging.jms.ContractVerifierJmsConfiguration, org.springframework.cloud.contract.verifier.messaging.kafka.ContractVerifierKafkaConfiguration, org.springframework.cloud.contract.verifier.messaging.noop.NoOpContractVerifierAutoConfiguration]], org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer#5e21e98f, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer#72ade7e3, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer#0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer#3224a577, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer#0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer#420a85c4, org.springframework.boot.test.context.SpringBootTestArgs#1], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true]], class annotated with #DirtiesContext [false] with mode [null].
00:03:40.371 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true, server.port=-1}
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.7.RELEASE)
2020-05-23 00:03:40.739 INFO 9559 --- [ main] com.cdt.producer.ContractVerifierTest : Starting ContractVerifierTest on CFC02XL862JG5H with PID 9559 (started by nodirbekusmanov in /Users/nodirbekusmanov/workspace/poc-consumer/2/producer)
2020-05-23 00:03:40.741 INFO 9559 --- [ main] com.cdt.producer.ContractVerifierTest : No active profile set, falling back to default profiles: default
2020-05-23 00:03:42.501 INFO 9559 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-05-23 00:03:42.835 INFO 9559 --- [ main] com.cdt.producer.ContractVerifierTest : Started ContractVerifierTest in 2.453 seconds (JVM running for 3.49)
2020-05-23 00:03:43.231 INFO 9559 --- [ main] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
2020-05-23 00:03:43.304 INFO 9559 --- [ main] o.s.a.r.c.CachingConnectionFactory : Created new connection: rabbitConnectionFactory#3850e90c:0/SimpleConnection#1d7f2f0a [delegate=amqp://guest#127.0.0.1:5672/, localPort= 55164]
2020-05-23 00:03:43.339 ERROR 9559 --- [ main] .c.c.v.m.i.SpringIntegrationStubMessages : Exception occurred while trying to read a message from a channel with name [user-presence]
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'user-presence' available
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:814) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1282) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:297) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1114) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.cloud.contract.verifier.messaging.integration.SpringIntegrationStubMessages.receive(SpringIntegrationStubMessages.java:70) ~[spring-cloud-contract-verifier-2.2.2.RELEASE.jar:2.2.2.RELEASE]
at org.springframework.cloud.contract.verifier.messaging.integration.SpringIntegrationStubMessages.receive(SpringIntegrationStubMessages.java:83) ~[spring-cloud-contract-verifier-2.2.2.RELEASE.jar:2.2.2.RELEASE]
at org.springframework.cloud.contract.verifier.messaging.integration.SpringIntegrationStubMessages.receive(SpringIntegrationStubMessages.java:35) ~[spring-cloud-contract-verifier-2.2.2.RELEASE.jar:2.2.2.RELEASE]
at org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging.receive(ContractVerifierMessaging.java:44) ~[spring-cloud-contract-verifier-2.2.2.RELEASE.jar:2.2.2.RELEASE]
at com.cdt.producer.ContractVerifierTest.validate_user_presence(ContractVerifierTest.java:30) ~[test-classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675) ~[junit-platform-commons-1.5.2.jar:1.5.2]
at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:132) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:124) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:74) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:43) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:35) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:202) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:198) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at java.base/java.util.ArrayList.forEach(ArrayList.java:1540) ~[na:na]
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at java.base/java.util.ArrayList.forEach(ArrayList.java:1540) ~[na:na]
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) ~[junit-platform-engine-1.5.2.jar:1.5.2]
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220) ~[junit-platform-launcher-1.3.1.jar:1.3.1]
at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188) ~[junit-platform-launcher-1.3.1.jar:1.3.1]
at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202) ~[junit-platform-launcher-1.3.1.jar:1.3.1]
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181) ~[junit-platform-launcher-1.3.1.jar:1.3.1]
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128) ~[junit-platform-launcher-1.3.1.jar:1.3.1]
at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:150) ~[surefire-junit-platform-2.22.2.jar:2.22.2]
at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:124) ~[surefire-junit-platform-2.22.2.jar:2.22.2]
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384) ~[surefire-booter-2.22.2.jar:2.22.2]
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345) ~[surefire-booter-2.22.2.jar:2.22.2]
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126) ~[surefire-booter-2.22.2.jar:2.22.2]
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418) ~[surefire-booter-2.22.2.jar:2.22.2]
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 3.465 s <<< FAILURE! - in com.cdt.producer.ContractVerifierTest
[ERROR] validate_user_presence Time elapsed: 0.516 s <<< ERROR!
java.lang.IllegalStateException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'user-presence' available
at com.cdt.producer.ContractVerifierTest.validate_user_presence(ContractVerifierTest.java:30)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'user-presence' available
at com.cdt.producer.ContractVerifierTest.validate_user_presence(ContractVerifierTest.java:30)
2020-05-23 00:03:43.410 INFO 9559 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR] ContractVerifierTest.validate_user_presence:30 » IllegalState org.springframew...
[INFO]
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.182 s
[INFO] Finished at: 2020-05-23T00:03:43+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project producer: There are test failures.
[ERROR]
[ERROR] Please refer to /Users/nodirbekusmanov/workspace/poc-consumer/2/producer/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
When I run my Spring Cloud Config Client project config-client, I found these error:
2018-02-09 10:31:09.885 INFO 13933 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://localhost:8888
2018-02-09 10:31:10.022 WARN 13933 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/config-client/dev/master": 拒绝连接 (Connection refused); nested exception is java.net.ConnectException: 拒绝连接 (Connection refused)
2018-02-09 10:31:10.026 INFO 13933 --- [ main] c.y.c.ConfigClientApplication : No active profile set, falling back to default profiles: default
2018-02-09 10:31:10.040 INFO 13933 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#33b1c5c5: startup date [Fri Feb 09 10:31:10 CST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#1ffe63b9
2018-02-09 10:31:10.419 INFO 13933 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=65226c2b-524f-3b14-8e17-9fdbc9f72d85
2018-02-09 10:31:10.471 INFO 13933 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$25380e89] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-02-09 10:31:10.688 INFO 13933 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 10001 (http)
2018-02-09 10:31:10.697 INFO 13933 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-02-09 10:31:10.698 INFO 13933 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.27
2018-02-09 10:31:10.767 INFO 13933 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-02-09 10:31:10.768 INFO 13933 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 727 ms
2018-02-09 10:31:10.861 INFO 13933 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2018-02-09 10:31:10.864 INFO 13933 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-02-09 10:31:10.864 INFO 13933 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-02-09 10:31:10.864 INFO 13933 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-02-09 10:31:10.865 INFO 13933 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-02-09 10:31:10.895 WARN 13933 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configClientApplication': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'content' in value "${content}"
2018-02-09 10:31:10.896 INFO 13933 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2018-02-09 10:31:10.914 INFO 13933 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-02-09 10:31:10.923 ERROR 13933 --- [ main] o.s.boot.SpringApplication : Application startup failed
Apparently, the config server is wrong. However, the Spring Cloud Config Server is running at localhost:10000/ and application.yml of the project(config-client) is below. Why the spring.cloud.config.uri doesn't work?
application.yml [config-client]
server:
port: 10001
spring:
application:
name: config-client
cloud:
config:
label: master
profile: dev
uri: http://localhost:10000
Fur future readers, as answered here, when using Spring Cloud Config Server, we should specify basic bootstrap settings such as : spring.application.name and spring.cloud.config.uri inside bootstrap.yml (or "bootstrap.properties").
Upon startup, Spring Cloud makes an HTTP call to the config server with the name of the application and retrieves back that application's configuration.
That's said, since we're externalizing our settings using Spring Cloud Config Server, any default configurations defined in application.yml (or "application.properties") will be overridden during the bootstrap process upon startup.
IntelliJ Users: add the following override parameter in the run/Debug Configuration:
Name: spring.cloud.config.uri
Value: http://your-server-here/config-server
you can load configuration servers before starting the Application, using bootstrap.yml
just add configuration server and application name
spring:
application:
name: clientTest
cloud:
config:
uri: http://localhost:8889
enabled: true
fail-fast: true
if we are using bootstrap.properties. we have to include this dependency in pom for spring-2.4.0+
agregado para evitar un error al usar spring mayor que 2.4.0
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
in my case i was testing spring consul, which usually runs in 8500, i saw a different port in the log. Found that the different port is due to following deplendency of spring cloud. Hence i just have to remove it.
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
I am trying to run the simple jMeter test in non gui, I am using a simple command like:
jmeter -n -t davelatal-cz.jmx -Jusers=4 -Jduration=300
I changed thread preferences as you can see on screenshot below:
Thread Preferences
So if I try to run this simple HTTP Request test, bash shows me this error:
Error in NonGUIDriver java.lang.NullPointerException
Screenshot:
Error screenshot
Here is LOG file:
2017/09/19 08:05:15 INFO - jmeter.util.JMeterUtils: Setting Locale to cs_CZ
2017/09/19 08:05:15 ERROR - jmeter.util.JMeterUtils: Could not find resources for 'cs_CZ'
2017/09/19 08:05:15 INFO - jmeter.JMeter: Loading user properties from: /usr/share/jmeter/bin/user.properties
2017/09/19 08:05:15 INFO - jmeter.JMeter: Loading system properties from: /usr/share/jmeter/bin/system.properties
2017/09/19 08:05:15 INFO - jmeter.JMeter: Setting JMeter property: users=4
2017/09/19 08:05:15 INFO - jmeter.JMeter: Setting JMeter property: duration=300
2017/09/19 08:05:15 INFO - jmeter.JMeter: Copyright (c) 1998-2014 The Apache Software Foundation
2017/09/19 08:05:15 INFO - jmeter.JMeter: Version 2.11.20151206
2017/09/19 08:05:15 INFO - jmeter.JMeter: java.version=1.8.0_131
2017/09/19 08:05:15 INFO - jmeter.JMeter: java.vm.name=OpenJDK 64-Bit Server VM
2017/09/19 08:05:15 INFO - jmeter.JMeter: os.name=Linux
2017/09/19 08:05:15 INFO - jmeter.JMeter: os.arch=amd64
2017/09/19 08:05:15 INFO - jmeter.JMeter: os.version=4.4.0-43-Microsoft
2017/09/19 08:05:15 INFO - jmeter.JMeter: file.encoding=UTF-8
2017/09/19 08:05:15 INFO - jmeter.JMeter: Default Locale=čeština (Česká republika)
2017/09/19 08:05:15 INFO - jmeter.JMeter: JMeter Locale=čeština (Česká republika)
2017/09/19 08:05:15 INFO - jmeter.JMeter: JMeterHome=/usr/share/jmeter
2017/09/19 08:05:15 INFO - jmeter.JMeter: user.dir =/mnt/c/Users/latal/Documents/Nigga
2017/09/19 08:05:15 INFO - jmeter.JMeter: PWD =/mnt/c/Users/latal/Documents/Nigga
2017/09/19 08:05:15 INFO - jmeter.JMeter: IP: 127.0.1.1 Name: J5MPJ72 FullName: J5MPJ72.bscpraha.cz
2017/09/19 08:05:15 INFO - jmeter.services.FileServer: Default base='/mnt/c/Users/latal/Documents/Nigga'
2017/09/19 08:05:15 INFO - jmeter.services.FileServer: Set new base='/mnt/c/Users/latal/Documents/Nigga'
2017/09/19 08:05:15 INFO - jmeter.JMeter: Loading file: davelatal-cz.jmx
2017/09/19 08:05:15 INFO - jmeter.save.SaveService: Testplan (JMX) version: 2.2. Testlog (JTL) version: 2.2
2017/09/19 08:05:15 INFO - jmeter.save.SaveService: Using SaveService properties file encoding UTF-8
2017/09/19 08:05:15 INFO - jmeter.save.SaveService: Using SaveService properties version 2.6
2017/09/19 08:05:15 INFO - jmeter.save.SaveService: Using SaveService properties file version 1554411
2017/09/19 08:05:15 INFO - jmeter.save.SaveService: All converter versions present and correct
2017/09/19 08:05:15 ERROR - jmeter.save.SaveService: Conversion error com.thoughtworks.xstream.converters.ConversionException: No field 'sentBytes' found in class 'org.apache.jmeter.samplers.SampleSaveConfiguration' : No field 'sentBytes' found in class 'org.apache.jmeter.samplers.SampleSaveConfiguration'
---- Debugging information ----
message : No field 'sentBytes' found in class 'org.apache.jmeter.samplers.SampleSaveConfiguration'
cause-exception : com.thoughtworks.xstream.converters.reflection.MissingFieldException
cause-message : No field 'sentBytes' found in class 'org.apache.jmeter.samplers.SampleSaveConfiguration'
class : org.apache.jmeter.samplers.SampleSaveConfiguration
required-type : org.apache.jmeter.samplers.SampleSaveConfiguration
converter-type : org.apache.jmeter.save.converters.SampleSaveConfigurationConverter
path : /jmeterTestPlan/hashTree/hashTree/hashTree/ResultCollector/objProp/value/sentBytes
line number : 56
class[1] : org.apache.jmeter.testelement.property.ObjectProperty
converter-type[1] : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2] : org.apache.jmeter.reporters.ResultCollector
converter-type[2] : org.apache.jmeter.save.converters.TestElementConverter
class[3] : org.apache.jorphan.collections.ListedHashTree
converter-type[3] : org.apache.jmeter.save.converters.HashTreeConverter
------------------------------- : No field 'sentBytes' found in class 'org.apache.jmeter.samplers.SampleSaveConfiguration' : No field 'sentBytes' found in class 'org.apache.jmeter.samplers.SampleSaveConfiguration'
---- Debugging information ----
message : No field 'sentBytes' found in class 'org.apache.jmeter.samplers.SampleSaveConfiguration'
cause-exception : com.thoughtworks.xstream.converters.reflection.MissingFieldException
cause-message : No field 'sentBytes' found in class 'org.apache.jmeter.samplers.SampleSaveConfiguration'
class : org.apache.jmeter.samplers.SampleSaveConfiguration
required-type : org.apache.jmeter.samplers.SampleSaveConfiguration
converter-type : org.apache.jmeter.save.converters.SampleSaveConfigurationConverter
path : /jmeterTestPlan/hashTree/hashTree/hashTree/ResultCollector/objProp/value/sentBytes
line number : 56
class[1] : org.apache.jmeter.testelement.property.ObjectProperty
converter-type[1] : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2] : org.apache.jmeter.reporters.ResultCollector
converter-type[2] : org.apache.jmeter.save.converters.TestElementConverter
class[3] : org.apache.jorphan.collections.ListedHashTree
converter-type[3] : org.apache.jmeter.save.converters.HashTreeConverter
-------------------------------
message : No field 'sentBytes' found in class 'org.apache.jmeter.samplers.SampleSaveConfiguration' : No field 'sentBytes' found in class 'org.apache.jmeter.samplers.SampleSaveConfiguration'
---- Debugging information ----
message : No field 'sentBytes' found in class 'org.apache.jmeter.samplers.SampleSaveConfiguration'
cause-exception : com.thoughtworks.xstream.converters.reflection.MissingFieldException
cause-message : No field 'sentBytes' found in class 'org.apache.jmeter.samplers.SampleSaveConfiguration'
class : org.apache.jmeter.samplers.SampleSaveConfiguration
required-type : org.apache.jmeter.samplers.SampleSaveConfiguration
converter-type : org.apache.jmeter.save.converters.SampleSaveConfigurationConverter
path : /jmeterTestPlan/hashTree/hashTree/hashTree/ResultCollector/objProp/value/sentBytes
line number : 56
class[1] : org.apache.jmeter.testelement.property.ObjectProperty
converter-type[1] : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2] : org.apache.jmeter.reporters.ResultCollector
converter-type[2] : org.apache.jmeter.save.converters.TestElementConverter
class[3] : org.apache.jorphan.collections.ListedHashTree
converter-type[3] : org.apache.jmeter.save.converters.HashTreeConverter
-------------------------------
cause-exception : com.thoughtworks.xstream.converters.ConversionException
cause-message : No field 'sentBytes' found in class 'org.apache.jmeter.samplers.SampleSaveConfiguration' : No field 'sentBytes' found in class 'org.apache.jmeter.samplers.SampleSaveConfiguration'
first-jmeter-class : org.apache.jmeter.save.converters.TestElementConverter.unmarshal(TestElementConverter.java:107)
class : org.apache.jmeter.save.ScriptWrapper
required-type : org.apache.jmeter.samplers.SampleSaveConfiguration
converter-type : org.apache.jmeter.save.ScriptWrapperConverter
path : /jmeterTestPlan/hashTree/hashTree/hashTree/ResultCollector/objProp/value/sentBytes
line number : 56
version : 2.11.20151206
-------------------------------
2017/09/19 08:05:15 ERROR - jmeter.JMeter: Error in NonGUIDriver java.lang.NullPointerException
at org.apache.jmeter.gui.tree.JMeterTreeModel.addSubTree(JMeterTreeModel.java:92)
at org.apache.jmeter.JMeter.runNonGui(JMeter.java:755)
at org.apache.jmeter.JMeter.startNonGui(JMeter.java:733)
at org.apache.jmeter.JMeter.start(JMeter.java:392)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.jmeter.NewDriver.main(NewDriver.java:259)
I already tried to change project folder, google it but I'm at the end of the options. Can anybody tell me what I am doing wrong? Or where is the problem?
Thanks
Most probably you are running a test which is created using a newer JMeter version on JMeter 2.11 so my expectation is that you need to upgrade your JMeter.
Current JMeter release is JMeter 3.2.
You can always get the latest JMeter version from JMeter Downloads page.
So I would recommend switching from JMeter which you seem to be getting from your Linux distribution repositories to the binary bundle you can download directly from Apache. Just pull the tarball, unpack it somewhere and run JMeter from this folder. Make sure you're running Jmeter as ./jmeter or add it to your system PATH before the one which is from the repositories.
I am a new user of RabbitMQ and I really enjoy it but I have an issue (well it doesn't throw any error and it doesn't affect anything except my mind ...).
Each time I run a consumer, it creates 2 connections. I can't find why so I am asking for your help.
I am using Spring-Boot and Spring AMQP (maybe it because of Spring ...)
Here is the code :
receiver-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsd">
<rabbit:connection-factory id="connectionFactory" host="localhost" username="admin" password="admin" />
<bean id="receiver" class="com.test.Receiver" />
<bean id="messageListener" class="org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter" >
<constructor-arg name="delegate" ref="receiver"/>
<constructor-arg name="defaultListenerMethod" value="receiveMessage" />
</bean>
<bean id="container" class="org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer" >
<property name="connectionFactory" ref="connectionFactory" />
<property name="queueNames" value="AMQP-PoC" />
<property name="messageListener" ref="messageListener" />
<property name="defaultRequeueRejected" value="false" />
</bean>
AMQPPoCReceiverApplication.java
#SpringBootApplication
#ImportResource("classpath:com.test/rabbit-receiver-context.xml")
public class AMQPPoCReceiverApplication implements CommandLineRunner {
private AnnotationConfigApplicationContext context;
#Override
public void run(String... strings) throws Exception {
context = new AnnotationConfigApplicationContext(AMQPPoCReceiverApplication.class);
System.out.println("Waiting for message");
}
#Override
protected void finalize() throws Throwable {
super.finalize();
this.context.close();
}
public static void main(String[] args) {
SpringApplication.run(AMQPPoCReceiverApplication.class, args);
}
}
Receiver.java
public class Receiver {
public void receiveMessage(String message) {
System.out.println("Message received : " + message);
}
}
Here the logs at the start (notice the lines with the double '*'):
2016-02-18 11:32:51.956 INFO 10196 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2016-02-18 11:32:51.966 INFO 10196 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase -2147482648
2016-02-18 11:32:51.967 INFO 10196 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 2147483647
**2016-02-18 11:32:52.062 INFO 10196 --- [cTaskExecutor-1] o.s.a.r.c.CachingConnectionFactory : Created new connection: SimpleConnection#2069bb0a [delegate=amqp://admin#127.0.0.1:5672/]**
2016-02-18 11:32:52.148 INFO 10196 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 52752 (http)
2016-02-18 11:32:52.153 INFO 10196 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#57bf85b2: startup date [Thu Feb 18 11:32:52 GMT+01:00 2016]; root of contex
t hierarchy
**2016-02-18 11:32:52.320 INFO 10196 --- [ main] o.s.b.f.xml.XmlBeanDefinitionReader : Loading XML bean definitions from class path resource [com.test/receiver-context.xml]**
2016-02-18 11:32:52.357 INFO 10196 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2016-02-18 11:32:52.362 INFO 10196 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.amqp.rabbit.annotation.RabbitBootstrapConfiguration' of type [class org.springframework.amqp.rabbit.annotation.RabbitBootstrapConfigur
ation$$EnhancerBySpringCGLIB$$eccd4a65] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-02-18 11:32:52.487 INFO 10196 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2016-02-18 11:32:52.489 INFO 10196 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase -2147482648
2016-02-18 11:32:52.489 INFO 10196 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 2147483647
**2016-02-18 11:32:52.498 INFO 10196 --- [cTaskExecutor-1] o.s.a.r.c.CachingConnectionFactory : Created new connection: SimpleConnection#768748cf [delegate=amqp://admin#127.0.0.1:5672/]**
Waiting for message
2016-02-18 11:32:52.505 INFO 10196 --- [ main] com.test.AMQPPoCReceiverApplication : Started AMQPPoCReceiverApplication in 3.509 seconds (JVM running for 6.961)
And here the double connections:
If I stop the client, it closes both (that is why I am sure it's a double connections for the same consumer).
If you need more information, ask here and I will reply as soon as possible.
Thank you all for any kind of help.
The answer is simple : I created 2 contexts in the same application.
new AnnotationConfigApplicationContext(AMQPPoCReceiverApplication.class);
and
SpringApplication.run(AMQPPoCReceiverApplication.class, args);
Only create one and it's done !