无法将 camunda-bom 添加到 springboot 项目

Posted

技术标签:

【中文标题】无法将 camunda-bom 添加到 springboot 项目【英文标题】:Can't add camunda-bom to springboot project 【发布时间】:2018-05-05 02:48:12 【问题描述】:

我正在尝试使用 springboot 创建一个 camunda 应用程序,但我需要使用 Spin Json Node,当我将依赖项添加到 pom.xml 时,当我将项目作为 java 应用程序运行时,它给了我这个错误:

org.springframework.context.ApplicationContextException:无法 启动嵌入式容器;嵌套异常是 org.springframework.boot.context.embedded.EmbeddedServletContainerException: 无法在以下位置启动嵌入式 Tomcat org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE] 在 org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE] 在 org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE] 在 org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE] 在 org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE] 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE] 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE] 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE] 在 br.com.ntconsult.camundaProject.app.CamundaSpringbootApplication.main(CamundaSpringbootApplication.java:9) [classes/:na] 由以下原因引起: org.springframework.boot.context.embedded.EmbeddedServletContainerException: 无法在以下位置启动嵌入式 Tomcat org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:123) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE] 在 org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.(TomcatEmbeddedServletContainer.java:84) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE] 在 org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:554) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE] 在 org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:179) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE] 在 org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE] 在 org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE] ... 8个常用框架 省略原因:org.apache.catalina.LifecycleException: Failed to 启动组件 [StandardServer[-1]] 在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-embed-core-8.5.20.jar:8.5.20] 在 org.apache.catalina.startup.Tomcat.start(Tomcat.java:367) ~[tomcat-embed-core-8.5.20.jar:8.5.20] 在 org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:99) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE] ... 13个常用框架 省略原因:org.apache.catalina.LifecycleException: Failed to 启动组件 [StandardService[Tomcat]] 在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-embed-core-8.5.20.jar:8.5.20] 在 org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793) ~[tomcat-embed-core-8.5.20.jar:8.5.20] 在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.20.jar:8.5.20] ...省略了15个常用框架 引起:org.apache.catalina.LifecycleException:启动失败 组件 [StandardEngine[Tomcat]] 位于 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-embed-core-8.5.20.jar:8.5.20] 在 org.apache.catalina.core.StandardService.startInternal(StandardService.java:422) ~[tomcat-embed-core-8.5.20.jar:8.5.20] 在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.20.jar:8.5.20] ...省略17个常用框架 引起:org.apache.catalina.LifecycleException:一个子容器 在开始时失败 org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:947) ~[tomcat-embed-core-8.5.20.jar:8.5.20] 在 org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) ~[tomcat-embed-core-8.5.20.jar:8.5.20] 在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.20.jar:8.5.20] ...省略了19个常用框架

如果我从 pom.xml 中的 dependencyManagement 中删除 camunda-bom 一切正常,但我不能使用 spin json node 之类的东西。

我在 github 中创建了一个带有此错误的简单项目:https://github.com/jradesenv/camunda-springboot

【问题讨论】:

【参考方案1】:

您在 GitHub 上提供的项目在我这边工作得非常好,并且按预期运行。你切断了堆栈跟踪的一部分,所以我看不到根本原因。某些东西阻止了 Tomcat 启动 - 可能是一个已经使用的端口?

PS:我们昨天发布了即将推出的 Spring Boot 原型的预览:https://github.com/camunda/camunda-archetypes/tree/master/camunda-archetype-spring-boot/ - 也可能是一个很好的起点。

仅供参考我的控制台(我只是提取代码并运行它):

 ____                                 _         ____  ____  __  __
/ ___| __ _ _ __ ___  _   _ _ __   __| | __ _  | __ )|  _ \|  \/  |
| |   / _` | '_ ` _ \| | | | '_ \ / _` |/ _` | |  _ \| |_) | |\/| |
| |__| (_| | | | | | | |_| | | | | (_| | (_| | | |_) |  __/| |  | |
\____/\__,_|_| |_| |_|\__,_|_| |_|\__,_|\__,_| |____/|_|   |_|  |_|

  Spring-Boot:  (v1.5.7.RELEASE)
  Camunda BPM: (v7.8.0-alpha6)
  Camunda BPM Spring Boot Starter: (v2.3.0-alpha1)

2017-11-22 09:12:24.931  INFO 13404 --- [           main] b.c.n.c.a.CamundaSpringbootApplication   : Starting CamundaSpringbootApplication on LAPTOP-LFHA6NM6 with PID 13404 (C:\Temp\camunda-springboot-support\target\classes started by ruecker in C:\Temp\camunda-springboot-support)
2017-11-22 09:12:24.954  INFO 13404 --- [           main] b.c.n.c.a.CamundaSpringbootApplication   : No active profile set, falling back to default profiles: default
2017-11-22 09:12:25.052  INFO 13404 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@37918c79: startup date [Wed Nov 22 09:12:25 CET 2017]; root of context hierarchy
2017-11-22 09:12:26.624  INFO 13404 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2017-11-22 09:12:27.830  INFO 13404 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-11-22 09:12:27.854  INFO 13404 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2017-11-22 09:12:27.856  INFO 13404 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.20
2017-11-22 09:12:28.079  INFO 13404 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2017-11-22 09:12:28.080  INFO 13404 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3033 ms
2017-11-22 09:12:28.522  INFO 13404 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2017-11-22 09:12:28.567  INFO 13404 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-11-22 09:12:28.568  INFO 13404 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-11-22 09:12:28.568  INFO 13404 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-11-22 09:12:28.568  INFO 13404 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2017-11-22 09:12:29.118  INFO 13404 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@37918c79: startup date [Wed Nov 22 09:12:25 CET 2017]; root of context hierarchy
2017-11-22 09:12:29.232  INFO 13404 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "[/error]" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2017-11-22 09:12:29.234  INFO 13404 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "[/error],produces=[text/html]" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2017-11-22 09:12:29.264  INFO 13404 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Root mapping to handler of type [class org.springframework.web.servlet.mvc.ParameterizableViewController]
2017-11-22 09:12:29.287  INFO 13404 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-11-22 09:12:29.288  INFO 13404 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-11-22 09:12:29.288  INFO 13404 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/lib/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-11-22 09:12:29.288  INFO 13404 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/api/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-11-22 09:12:29.289  INFO 13404 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/app/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-11-22 09:12:29.359  INFO 13404 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-11-22 09:12:29.870  INFO 13404 --- [           main] org.camunda.bpm.spring.boot              : STARTER-SB040 Setting up jobExecutor with corePoolSize=3, maxPoolSize:10
2017-11-22 09:12:29.891  INFO 13404 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService  'camundaTaskExecutor'
2017-11-22 09:12:30.101  INFO 13404 --- [           main] org.camunda.bpm.engine.cfg               : ENGINE-12003 Plugin 'CompositeProcessEnginePlugin[genericPropertiesConfiguration, camundaProcessEngineConfiguration, camundaDatasourceConfiguration, camundaJobConfiguration, camundaHistoryConfiguration, camundaMetricsConfiguration, camundaAuthorizationConfiguration, camundaDeploymentConfiguration, failedJobConfiguration]' activated on process engine 'default'
2017-11-22 09:12:32.841  INFO 13404 --- [           main] org.camunda.bpm.spring.boot              : STARTER-SB021 Auto-Deploying resources: []
2017-11-22 09:12:36.911  INFO 13404 --- [           main] org.camunda.bpm.engine.persistence       : ENGINE-03016 Performing database operation 'create' on component 'engine' with resource 'org/camunda/bpm/engine/db/create/activiti.h2.create.engine.sql'
2017-11-22 09:12:36.965  INFO 13404 --- [           main] org.camunda.bpm.engine.persistence       : ENGINE-03016 Performing database operation 'create' on component 'history' with resource 'org/camunda/bpm/engine/db/create/activiti.h2.create.history.sql'
2017-11-22 09:12:36.993  INFO 13404 --- [           main] org.camunda.bpm.engine.persistence       : ENGINE-03016 Performing database operation 'create' on component 'identity' with resource 'org/camunda/bpm/engine/db/create/activiti.h2.create.identity.sql'
2017-11-22 09:12:37.024  INFO 13404 --- [           main] org.camunda.bpm.engine.persistence       : ENGINE-03016 Performing database operation 'create' on component 'case.engine' with resource 'org/camunda/bpm/engine/db/create/activiti.h2.create.case.engine.sql'
2017-11-22 09:12:37.037  INFO 13404 --- [           main] org.camunda.bpm.engine.persistence       : ENGINE-03016 Performing database operation 'create' on component 'case.history' with resource 'org/camunda/bpm/engine/db/create/activiti.h2.create.case.history.sql'
2017-11-22 09:12:37.045  INFO 13404 --- [           main] org.camunda.bpm.engine.persistence       : ENGINE-03016 Performing database operation 'create' on component 'decision.engine' with resource 'org/camunda/bpm/engine/db/create/activiti.h2.create.decision.engine.sql'
2017-11-22 09:12:37.068  INFO 13404 --- [           main] org.camunda.bpm.engine.persistence       : ENGINE-03016 Performing database operation 'create' on component 'decision.history' with resource 'org/camunda/bpm/engine/db/create/activiti.h2.create.decision.history.sql'
2017-11-22 09:12:37.159  INFO 13404 --- [           main] org.camunda.bpm.engine.persistence       : ENGINE-03067 No history level property found in database
2017-11-22 09:12:37.159  INFO 13404 --- [           main] org.camunda.bpm.engine.persistence       : ENGINE-03065 Creating historyLevel property in database for level: HistoryLevelFull(name=full, id=3)
2017-11-22 09:12:37.171  INFO 13404 --- [           main] org.camunda.bpm.engine                   : ENGINE-00001 Process Engine default created.
2017-11-22 09:12:37.370  INFO 13404 --- [           main] o.c.b.s.b.s.w.f.LazyInitRegistration     : lazy initialized org.camunda.bpm.spring.boot.starter.webapp.filter.LazyProcessEnginesFilter@4e25e00f
2017-11-22 09:12:37.470  INFO 13404 --- [           main] o.c.b.s.b.s.w.f.LazyInitRegistration     : lazy initialized org.camunda.bpm.spring.boot.starter.webapp.filter.LazySecurityFilter@2097d719
2017-11-22 09:12:37.808  INFO 13404 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-11-22 09:12:37.934  INFO 13404 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-11-22 09:12:37.944  INFO 13404 --- [           main] org.camunda.bpm.engine.jobexecutor       : ENGINE-14014 Starting up the JobExecutor[org.camunda.bpm.engine.spring.components.jobexecutor.SpringJobExecutor].
2017-11-22 09:12:37.947  INFO 13404 --- [           main] b.c.n.c.a.CamundaSpringbootApplication   : Started CamundaSpringbootApplication in 13.493 seconds (JVM running for 14.344)
2017-11-22 09:12:37.949  INFO 13404 --- [ingJobExecutor]] org.camunda.bpm.engine.jobexecutor       : ENGINE-14018 JobExecutor[org.camunda.bpm.engine.spring.components.jobexecutor.SpringJobExecutor] starting to acquire jobs

【讨论】:

我正在使用 jdk 1.8 并且仍然出现错误。我会尝试使用你的新模板。你有 camunda springboot 用 gradle 而不是 maven 的模板吗?

以上是关于无法将 camunda-bom 添加到 springboot 项目的主要内容,如果未能解决你的问题,请参考以下文章

无法将组件添加到扩展 JFrame 的类

无法将 ReactiveUI 添加到 NUnit 测试项目

无法将 UILabel 添加到 UICollectionViewCell

无法将孩子添加到 GameScene,只能添加到 SKSpriteNode

无法将元素添加到数组

无法将 JSON 响应添加到领域