I'm trying to run test cases for a project and encountered the following issue: When running test class it tries to connect to the database and fails giving the following error.
java.lang.IllegalStateException: Failed to load ApplicationContext
at
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cache': Unsatisfied dependency expressed through field 'migrationPatternService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'migrationPatternService' defined in file [C:\Projects\cloud_genie\cloud-genie-microservice\target\classes\com\virtusa\gto\cloudgenie\service\MigrationPatternService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'commonDAO': Unsatisfied dependency expressed through field 'jdbcTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.DatabaseException: java.sql.SQLNonTransientConnectionException: Could not connect to address=(host=23.236.55.227)(port=3306)(type=master) : Socket fail to connect to host:23.236.55.227, port:3306. Connection timed out: connect
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643)
This is most likely because you provided your Spring boot application.properties / -.yml file with liquibase or datasource properties.
You should override these properties in your test class.
By example for using a in memory database like H2.
Related
I am attempting to install a WPS plugin for Geoserver to my local Windows machine, and moving *.jar files into WEB-INF/inf folder causes error that doesn't allow to load Geoserver unless I delete them from there.
The version of Geoserver is 2.20.3 and it's web instance gets loaded with the built-in Jetty web server.
The error message:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'wmtsCapabilitiesProvider' defined in URL [jar:file:/C:/Program%20Files/GeoServer/webapps/geoserver/WEB-INF/lib/gs-gwc-2.20.3.jar!/applicationContext.xml]: Cannot resolve reference to bean 'geoServer' while setting constructor argument;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'geoServer' defined in URL [jar:file:/C:/Program%20Files/GeoServer/webapps/geoserver/WEB-INF/lib/gs-main-2.20.3.jar!/applicationContext.xml]: Cannot resolve reference to bean 'catalog' while setting bean property 'catalog'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'localWorkspaceCatalog' defined in URL [jar:file:/C:/Program%20Files/GeoServer/webapps/geoserver/WEB-INF/lib/gs-main-2.20.3.jar!/applicationContext.xml]: Cannot resolve reference to bean 'advertisedCatalog' while setting constructor argument; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'advertisedCatalog' defined in URL [jar:file:/C:/Program%20Files/GeoServer/webapps/geoserver/WEB-INF/lib/gs-main-2.20.3.jar!/applicationContext.xml]: Cannot resolve reference to bean 'secureCatalog' while setting constructor argument; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'secureCatalog' defined in URL [jar:file:/C:/Program%20Files/GeoServer/webapps/geoserver/WEB-INF/lib/gs-main-2.20.3.jar!/applicationContext.xml]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.geoserver.security.SecureCatalogImpl]: Constructor threw exception; nested exception is
java.lang.NullPointerException at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:314)
I have a Flyway SQL script called V3__test.sql and i have separated DDL and DML statements into two files called V3.1__test_create.sql and V3.1.1__test_insert.sql. Since Flyway schema history table has an entry of old file V3__test.sql. I am getting an exception org.flywaydb.core.api.FlywayException: Validate failed
with an error
Detected resolved migration not applied to database: 3.1
I have added config spring.flyway.ignore-missing-migrations: true into application.yml but doesnt seem working.
Flyway version 6 and cant disable migration validation because of requirement.
Exception Stacktrace:
Cannot create inner bean '(inner bean)#5a021cb9' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#5a021cb9': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Validate failed:
Detected resolved migration not applied to database: 3.1
I want jboss to read properties from spring-boot.war file's inner application.properties file. When i deploy my application as war i get these error
java.lang.RuntimeException: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.
DispatcherServletAutoConfiguration$DispatcherServletRegistrationConfiguration':
Unsatisfied dependency expressed through constructor parameter 0;
nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException:
Error creating bean with name 'spring.mvc-org.springframework.boot.autoconfigure.web.servlet.WebMvcProperties': Could not bind properties to 'WebMvcProperties' : prefix=spring.mvc, ignoreInvalidFields=false, ignoreUnknownFields=true;
nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.mvc.servlet' to org.springframework.boot.autoconfigure.web.servlet.WebMvcProperties$Servlet
What can i do to configure this?
Thanks
I have containerised a spring boot application. It is contained in a jar file. when I call the jar file separately It is working but when I run it through docker-compose up it yields the following error:
ConfigServletWebServerApplicationContext : Exception encountered
during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'crawlerController': Unsatisfied
dependency expressed through field 'campaignservice'; nested exception
is org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'campaignService': Unsatisfied
dependency expressed through field 'campaignrepository'; nested
exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'campaignRepository': Cannot resolve
reference to bean
'org.springframework.data.neo4j.transaction.SharedSessionCreator#0'
while setting bean property 'session'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name
'org.springframework.data.neo4j.transaction.SharedSessionCreator#0':
Cannot resolve reference to bean 'sessionFactory' while setting
constructor argument; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'sessionFactory' defined in class path
resource
[org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.class]:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method
'sessionFactory' threw exception; nested exception is
java.lang.TypeNotPresentException: Type javafx.util.Pair not present
Given that the jar works when invoked separately I assume that all of the dependencies are contained in the classpath. so I do not understand why it does not work when called through Docker
the dockerFile is :
FROM openjdk:8-jre
VOLUME /tmp
ADD target/SpringNeoServer.jar /SpringNeoServer.jar
EXPOSE 7864
ENTRYPOINT ["java", "-jar", "SpringNeoServer.jar"]
JavaFX is not included in this version of openjdk.
Instructions to add it can be found here.
I'm seeing the below error when deploying war with Spring AWS on AWS EB:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'embeddedServletContainerCustomizerBeanPostProcessor': Initialization of bean failed;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cache.annotation.ProxyCachingConfiguration': Injection of autowired dependencies failed;
nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: void org.springframework.cache.annotation.AbstractCachingConfiguration.setConfigurers(java.util.Collection);
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cloud.aws.cache.config.annotation.ElastiCacheCachingConfiguration': Injection of autowired dependencies failed;
nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.cloud.aws.core.env.stack.ListableStackResourceFactory org.springframework.cloud.aws.cache.config.annotation.ElastiCacheCachingConfiguration.stackResourceFactory;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stackResourceRegistryFactoryBean' defined in class path resource [org/springframework/cloud/aws/autoconfigure/context/ContextStackAutoConfiguration$StackAutoDetectConfiguration.class]: Bean instantiation via factory method failed;
nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.aws.core.env.stack.config.StackResourceRegistryFactoryBean]: Factory method 'stackResourceRegistryFactoryBean' threw exception;
nested exception is com.amazonaws.AmazonServiceException: User: arn:aws:sts::<id>:assumed-role/aws-elasticbeanstalk-ec2-role/<id> is not authorized to perform: cloudformation:DescribeStackResources (Service: AmazonCloudFormation; Status Code: 403; Error Code: AccessDenied; Request ID: <request-id>)
The username shown is apparently a temp user created during the process.
Not sure what all info I need to provide -- please let me know, and I shall add.
Thanks!
This was apparently due to a problem in the spring config file. Some xsd URLs where invalid, and so the aws credentials provided weren't being used.
Fixing the URLs fixed the issue.