Java spring docker 容器中的启动缓存生成失败
Java spring boot cache generation in docker container fails
运行 java spring 引导应用程序 Docker 中是否有必须考虑的特殊配置?
application I try to run in a Docker container fails with errors related to cache generation (full error log)。在没有 Docker 的情况下构建和 运行 应用程序可以正常工作。
快速浏览日志中的一些错误:
2019-10-31 08:24:37.982 INFO 617 --- [ main] org.ehcache.xml.XmlConfiguration : Loading Ehcache XML configuration from file:/usr/project/application/target/application-0.9.0.jar!/BOOT-INF/classes!/ehcache.xml.
2019-10-31 08:24:38.611 INFO 617 --- [ main] org.ehcache.jsr107.ConfigurationMerger : Configuration of cache introspectCache will be supplemented by template heap-cache
2019-10-31 08:24:38.612 INFO 617 --- [ main] org.ehcache.jsr107.ConfigurationMerger : Cache introspectCache will use expiry configuration from template heap-cache
2019-10-31 08:24:38.809 INFO 617 --- [ main] o.t.o.p.UpfrontAllocatingPageSource : Allocating 200.0MB in chunks
2019-10-31 08:24:38.965 INFO 617 --- [ main] org.ehcache.core.EhcacheManager : Cache 'introspectCache' created in EhcacheManager.
2019-10-31 08:24:38.978 INFO 617 --- [ main] org.ehcache.jsr107.ConfigurationMerger : Configuration of cache templateCache will be supplemented by template heap-cache
2019-10-31 08:24:38.978 INFO 617 --- [ main] org.ehcache.jsr107.ConfigurationMerger : Cache templateCache will use expiry configuration from template heap-cache
2019-10-31 08:24:38.986 INFO 617 --- [ main] o.t.o.p.UpfrontAllocatingPageSource : Allocating 200.0MB in chunks
2019-10-31 08:24:39.095 INFO 617 --- [ main] org.ehcache.core.EhcacheManager : Cache 'templateCache' created in EhcacheManager.
2019-10-31 08:24:39.098 INFO 617 --- [ main] org.ehcache.jsr107.ConfigurationMerger : Configuration of cache operationaltemplateCache will be supplemented by template heap-cache
2019-10-31 08:24:39.098 INFO 617 --- [ main] org.ehcache.jsr107.ConfigurationMerger : Cache operationaltemplateCache will use expiry configuration from template heap-cache
2019-10-31 08:24:39.110 INFO 617 --- [ main] o.t.o.p.UpfrontAllocatingPageSource : Allocating 200.0MB in chunks
2019-10-31 08:24:41.206 WARN 617 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'contributionServiceImp' defined in URL [jar:file:/usr/project/application/target/application-0.9.0.jar!/BOOT-INF/lib/service-0.9.0.jar!/org/ehrbase/service/ContributionServiceImp.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'knowledgeCacheService' defined in URL [jar:file:/usr/project/application/target/application-0.9.0.jar!/BOOT-INF/lib/service-0.9.0.jar!/org/ehrbase/service/KnowledgeCacheService.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cacheManagerCustomizer' defined in class path resource [org/ehrbase/configuration/CacheConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.cache.CacheManager]: Factory method 'cacheManagerCustomizer' threw exception; nested exception is org.ehcache.jsr107.MultiCacheException: [Exception 0] Cache 'operationaltemplateCache' creation in EhcacheManager failed.
2019-10-31 08:24:41.214 INFO 617 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2019-10-31 08:24:41.233 INFO 617 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-10-31 08:24:41.273 INFO 617 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2019-10-31 08:24:41.281 ERROR 617 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'contributionServiceImp' defined in URL [jar:file:/usr/project/application/target/application-0.9.0.jar!/BOOT-INF/lib/service-0.9.0.jar!/org/ehrbase/service/ContributionServiceImp.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'knowledgeCacheService' defined in URL [jar:file:/usr/project/application/target/application-0.9.0.jar!/BOOT-INF/lib/service-0.9.0.jar!/org/ehrbase/service/KnowledgeCacheService.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cacheManagerCustomizer' defined in class path resource [org/ehrbase/configuration/CacheConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.cache.CacheManager]: Factory method 'cacheManagerCustomizer' threw exception; nested exception is org.ehcache.jsr107.MultiCacheException: [Exception 0] Cache 'operationaltemplateCache' creation in EhcacheManager failed.
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
at org.ehrbase.application.EhrBase.main(EhrBase.java:38)
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.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'knowledgeCacheService' defined in URL [jar:file:/usr/project/application/target/application-0.9.0.jar!/BOOT-INF/lib/service-0.9.0.jar!/org/ehrbase/service/KnowledgeCacheService.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cacheManagerCustomizer' defined in class path resource [org/ehrbase/configuration/CacheConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.cache.CacheManager]: Factory method 'cacheManagerCustomizer' threw exception; nested exception is org.ehcache.jsr107.MultiCacheException: [Exception 0] Cache 'operationaltemplateCache' creation in EhcacheManager failed.
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
... 27 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cacheManagerCustomizer' defined in class path resource [org/ehrbase/configuration/CacheConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.cache.CacheManager]: Factory method 'cacheManagerCustomizer' threw exception; nested exception is org.ehcache.jsr107.MultiCacheException: [Exception 0] Cache 'operationaltemplateCache' creation in EhcacheManager failed.
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
... 41 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.cache.CacheManager]: Factory method 'cacheManagerCustomizer' threw exception; nested exception is org.ehcache.jsr107.MultiCacheException: [Exception 0] Cache 'operationaltemplateCache' creation in EhcacheManager failed.
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 54 common frames omitted
Caused by: org.ehcache.jsr107.MultiCacheException: [Exception 0] Cache 'operationaltemplateCache' creation in EhcacheManager failed.
at org.ehcache.jsr107.Eh107CacheManager.createCache(Eh107CacheManager.java:205)
at org.ehrbase.configuration.CacheConfiguration.buildCache(CacheConfiguration.java:64)
at org.ehrbase.configuration.CacheConfiguration.cacheManagerCustomizer(CacheConfiguration.java:53)
at org.ehrbase.configuration.CacheConfiguration$$EnhancerBySpringCGLIB$$a4ce32f5.CGLIB$cacheManagerCustomizer[=13=](<generated>)
at org.ehrbase.configuration.CacheConfiguration$$EnhancerBySpringCGLIB$$a4ce32f5$$FastClassBySpringCGLIB$$b982cbd8.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
at org.ehrbase.configuration.CacheConfiguration$$EnhancerBySpringCGLIB$$a4ce32f5.cacheManagerCustomizer(<generated>)
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.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 55 common frames omitted
The command '/bin/sh -c sh -c "./docker_build_script.sh"' returned a non-zero code: 1
不在应用程序存储库中的其他文件
Docker文件
# postgres db container with some ehrbase customizations
FROM ehrbaseorg/ehrbase-database-docker:11.5
# you may need to adjust the IP address
ENV DB_URL="jdbc:postgresql://172.17.0.2:5432/ehrbase"
ENV DB_USER="postgres"
ENV DB_PASS="postgres"
ENV POSTGRES_USER="postgres"
ENV POSTGRES_PASSWORD="postgres"
# install java openjdk, maven
RUN apk add --no-cache openjdk8
RUN apk add --no-cache maven
RUN java -version
RUN mvn -version
# copy repo into container filesystem
WORKDIR /usr/project
COPY . .
RUN mkdir -p file_repo/knowledge/archetypes \
&& mkdir -p file_repo/knowledge/operational_templates \
&& mkdir -p file_repo/knowledge/templates
# Start Build Process
COPY ./docker_build_script.sh .
RUN chmod +x ./docker_build_script.sh
RUN sh -c "./docker_build_script.sh"
EXPOSE 8080
Shell 启动脚本需要在 Docker 容器内处理
#!/bin/bash
set -e
# Start DB
su - postgres -c "pg_ctl -D ${PGDATA} -w start && pg_ctl -D ${PGDATA} status"
mvn package
sleep 1
java -jar application/target/application-0.9.0.jar
我已将完整的错误日志和重现问题的步骤放入 Github 要点:full error log
有解决此问题的想法吗?
我首先想到的是您没有将 -XX:MaxDirectMemorySize
设置为任何特定的内容。这意味着它默认与最大堆大小相同。鉴于您正在尝试创建 4(?)个缓存,每个缓存有 200MB 的堆外空间,您很可能只是 运行 堆外空间 space。生成 JVM 时尝试添加合适的值?
运行 java spring 引导应用程序 Docker 中是否有必须考虑的特殊配置?
application I try to run in a Docker container fails with errors related to cache generation (full error log)。在没有 Docker 的情况下构建和 运行 应用程序可以正常工作。
快速浏览日志中的一些错误:
2019-10-31 08:24:37.982 INFO 617 --- [ main] org.ehcache.xml.XmlConfiguration : Loading Ehcache XML configuration from file:/usr/project/application/target/application-0.9.0.jar!/BOOT-INF/classes!/ehcache.xml.
2019-10-31 08:24:38.611 INFO 617 --- [ main] org.ehcache.jsr107.ConfigurationMerger : Configuration of cache introspectCache will be supplemented by template heap-cache
2019-10-31 08:24:38.612 INFO 617 --- [ main] org.ehcache.jsr107.ConfigurationMerger : Cache introspectCache will use expiry configuration from template heap-cache
2019-10-31 08:24:38.809 INFO 617 --- [ main] o.t.o.p.UpfrontAllocatingPageSource : Allocating 200.0MB in chunks
2019-10-31 08:24:38.965 INFO 617 --- [ main] org.ehcache.core.EhcacheManager : Cache 'introspectCache' created in EhcacheManager.
2019-10-31 08:24:38.978 INFO 617 --- [ main] org.ehcache.jsr107.ConfigurationMerger : Configuration of cache templateCache will be supplemented by template heap-cache
2019-10-31 08:24:38.978 INFO 617 --- [ main] org.ehcache.jsr107.ConfigurationMerger : Cache templateCache will use expiry configuration from template heap-cache
2019-10-31 08:24:38.986 INFO 617 --- [ main] o.t.o.p.UpfrontAllocatingPageSource : Allocating 200.0MB in chunks
2019-10-31 08:24:39.095 INFO 617 --- [ main] org.ehcache.core.EhcacheManager : Cache 'templateCache' created in EhcacheManager.
2019-10-31 08:24:39.098 INFO 617 --- [ main] org.ehcache.jsr107.ConfigurationMerger : Configuration of cache operationaltemplateCache will be supplemented by template heap-cache
2019-10-31 08:24:39.098 INFO 617 --- [ main] org.ehcache.jsr107.ConfigurationMerger : Cache operationaltemplateCache will use expiry configuration from template heap-cache
2019-10-31 08:24:39.110 INFO 617 --- [ main] o.t.o.p.UpfrontAllocatingPageSource : Allocating 200.0MB in chunks
2019-10-31 08:24:41.206 WARN 617 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'contributionServiceImp' defined in URL [jar:file:/usr/project/application/target/application-0.9.0.jar!/BOOT-INF/lib/service-0.9.0.jar!/org/ehrbase/service/ContributionServiceImp.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'knowledgeCacheService' defined in URL [jar:file:/usr/project/application/target/application-0.9.0.jar!/BOOT-INF/lib/service-0.9.0.jar!/org/ehrbase/service/KnowledgeCacheService.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cacheManagerCustomizer' defined in class path resource [org/ehrbase/configuration/CacheConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.cache.CacheManager]: Factory method 'cacheManagerCustomizer' threw exception; nested exception is org.ehcache.jsr107.MultiCacheException: [Exception 0] Cache 'operationaltemplateCache' creation in EhcacheManager failed.
2019-10-31 08:24:41.214 INFO 617 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2019-10-31 08:24:41.233 INFO 617 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-10-31 08:24:41.273 INFO 617 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2019-10-31 08:24:41.281 ERROR 617 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'contributionServiceImp' defined in URL [jar:file:/usr/project/application/target/application-0.9.0.jar!/BOOT-INF/lib/service-0.9.0.jar!/org/ehrbase/service/ContributionServiceImp.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'knowledgeCacheService' defined in URL [jar:file:/usr/project/application/target/application-0.9.0.jar!/BOOT-INF/lib/service-0.9.0.jar!/org/ehrbase/service/KnowledgeCacheService.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cacheManagerCustomizer' defined in class path resource [org/ehrbase/configuration/CacheConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.cache.CacheManager]: Factory method 'cacheManagerCustomizer' threw exception; nested exception is org.ehcache.jsr107.MultiCacheException: [Exception 0] Cache 'operationaltemplateCache' creation in EhcacheManager failed.
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
at org.ehrbase.application.EhrBase.main(EhrBase.java:38)
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.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'knowledgeCacheService' defined in URL [jar:file:/usr/project/application/target/application-0.9.0.jar!/BOOT-INF/lib/service-0.9.0.jar!/org/ehrbase/service/KnowledgeCacheService.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cacheManagerCustomizer' defined in class path resource [org/ehrbase/configuration/CacheConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.cache.CacheManager]: Factory method 'cacheManagerCustomizer' threw exception; nested exception is org.ehcache.jsr107.MultiCacheException: [Exception 0] Cache 'operationaltemplateCache' creation in EhcacheManager failed.
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
... 27 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cacheManagerCustomizer' defined in class path resource [org/ehrbase/configuration/CacheConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.cache.CacheManager]: Factory method 'cacheManagerCustomizer' threw exception; nested exception is org.ehcache.jsr107.MultiCacheException: [Exception 0] Cache 'operationaltemplateCache' creation in EhcacheManager failed.
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
... 41 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.cache.CacheManager]: Factory method 'cacheManagerCustomizer' threw exception; nested exception is org.ehcache.jsr107.MultiCacheException: [Exception 0] Cache 'operationaltemplateCache' creation in EhcacheManager failed.
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 54 common frames omitted
Caused by: org.ehcache.jsr107.MultiCacheException: [Exception 0] Cache 'operationaltemplateCache' creation in EhcacheManager failed.
at org.ehcache.jsr107.Eh107CacheManager.createCache(Eh107CacheManager.java:205)
at org.ehrbase.configuration.CacheConfiguration.buildCache(CacheConfiguration.java:64)
at org.ehrbase.configuration.CacheConfiguration.cacheManagerCustomizer(CacheConfiguration.java:53)
at org.ehrbase.configuration.CacheConfiguration$$EnhancerBySpringCGLIB$$a4ce32f5.CGLIB$cacheManagerCustomizer[=13=](<generated>)
at org.ehrbase.configuration.CacheConfiguration$$EnhancerBySpringCGLIB$$a4ce32f5$$FastClassBySpringCGLIB$$b982cbd8.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
at org.ehrbase.configuration.CacheConfiguration$$EnhancerBySpringCGLIB$$a4ce32f5.cacheManagerCustomizer(<generated>)
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.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 55 common frames omitted
The command '/bin/sh -c sh -c "./docker_build_script.sh"' returned a non-zero code: 1
不在应用程序存储库中的其他文件
Docker文件
# postgres db container with some ehrbase customizations
FROM ehrbaseorg/ehrbase-database-docker:11.5
# you may need to adjust the IP address
ENV DB_URL="jdbc:postgresql://172.17.0.2:5432/ehrbase"
ENV DB_USER="postgres"
ENV DB_PASS="postgres"
ENV POSTGRES_USER="postgres"
ENV POSTGRES_PASSWORD="postgres"
# install java openjdk, maven
RUN apk add --no-cache openjdk8
RUN apk add --no-cache maven
RUN java -version
RUN mvn -version
# copy repo into container filesystem
WORKDIR /usr/project
COPY . .
RUN mkdir -p file_repo/knowledge/archetypes \
&& mkdir -p file_repo/knowledge/operational_templates \
&& mkdir -p file_repo/knowledge/templates
# Start Build Process
COPY ./docker_build_script.sh .
RUN chmod +x ./docker_build_script.sh
RUN sh -c "./docker_build_script.sh"
EXPOSE 8080
Shell 启动脚本需要在 Docker 容器内处理
#!/bin/bash
set -e
# Start DB
su - postgres -c "pg_ctl -D ${PGDATA} -w start && pg_ctl -D ${PGDATA} status"
mvn package
sleep 1
java -jar application/target/application-0.9.0.jar
我已将完整的错误日志和重现问题的步骤放入 Github 要点:full error log
有解决此问题的想法吗?
我首先想到的是您没有将 -XX:MaxDirectMemorySize
设置为任何特定的内容。这意味着它默认与最大堆大小相同。鉴于您正在尝试创建 4(?)个缓存,每个缓存有 200MB 的堆外空间,您很可能只是 运行 堆外空间 space。生成 JVM 时尝试添加合适的值?