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.
Related
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.
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'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.
I have created created a Grails application and created the Spring Security plugin set up into It.
When I run the application I get following error. Hibernate folder is empty. Can anyone help me resolve this?
2014-06-20 13:41:26,946 [http-bio-8080-exec-21] ERROR [/GrailsLoginWithSpring].[gsp] -
Servlet.service() for servlet [gsp] in context with path [/GrailsLoginWithSpring] threw exception
Message: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'org.grails.internal.SESSION_FACTORY_HOLDER':
Cannot create inner bean '(inner bean)#3720a15d' of type
[org.codehaus.groovy.grails.orm.hibernate.ConfigurableLocalSessionFactoryBean]
while setting bean property 'sessionFactory';
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name '(inner bean)#3720a15d': Invocation of init method failed;
nested exception is java.io.FileNotFoundException: class path resource [hibernate.cfg.xml]
cannot be resolved to URL because it does not exist
Try adding
hibernate {
reload = false
}
As suggested by Graeme Rocher in this JIRA
I use load time weaving in spring. All works fine with websphere, because it has own class loader, but i have troubles in dev mode, where i use embedded jetty. How can i set class loader in jetty?
When i run it i see following error
[INFO] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.weaving.AspectJWeavingEnabler#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loadTimeWeaver': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.instrument.classloading.ReflectiveLoadTimeWeaver]: Constructor threw exception; nested exception is java.lang.IllegalStateException: ClassLoader [com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload$WebAppClassLoaderExtension] does NOT provide an 'addTransformer(ClassFileTransformer)' method.
I've resolved it by adding a "-Xbootclasspath/a:[path to jar]" as JvmArgs param.
Now it's looks like
<extraJvmArgs>-Xmx4g -XX:MaxPermSize=512m -javaagent:C:\Users\auldanov\.m2\repository\org\springframework\spring-instrument\3.1.4.RELEASE\spring-instrument-3.1.4.RELEASE.jar -Xbootclasspath/a:C:\Users\auldanov\.m2\repository\org\springframework\spring-instrument\3.1.4.RELEASE\spring-instrument-3.1.4.RELEASE.jar</extraJvmArgs>