我有2个子项目(后端和ui)的gradle项目。 Ui完全由gradle tomcatRunWar
开始。后端有配置描述符,我们在生产地<tomcat home>/conf/Catalina/localhost/portal-api.xml
它包含一些资源定义,如数据库数据源(cuted部分):
<?xml version='1.0' encoding='UTF-8'?>
<Context>
<!-- Database access -->
<!-- For information about these DataSource Pool properties see: http://www.tomcatexpert.com/blog/2010/04/01/configuring-jdbc-pool-high-concurrency -->
<Resource type="javax.sql.DataSource" name="jdbc/EgaisDataSource" description="Database for EGAIS portal" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" driverClassName="org.postgresql.Driver" url="jdbc:postgresql://egais.perf.db.master:5432/e....>
<Resource name="mail/EgaisMail" auth="Container" type="javax.mail.Session" mail.transport.protocol="smtp" mail.smtp.host="smtp.mail.ru" mail.smtp.port="465" mail.smtp.starttls.enable="true" mail.smtp.socketFactory.port="465" mail.smtp.socketFactory.cla....>
<Environment name="ru.rlh.egais.portal.url" value="http://lesegais.ru/portal" type="java.lang.String"/>
</Context>
上下文本身<tomcat home>/conf/context.xml
非常简单:
<?xml version='1.0' encoding='utf-8'?>
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
我的后端gradle构建看起来像(稍微截断):
apply plugin: 'war'
apply plugin: 'com.bmuschko.tomcat'
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.bmuschko:gradle-tomcat-plugin:2.2.2'
}
}
dependencies {
def tomcatVersion = '7.0.57'
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}",
'org.slf4j:jul-to-slf4j:1.7.12',
'org.slf4j:slf4j-simple:1.7.12',
'ch.qos.logback:logback-classic:1.1.3',
'ch.qos.logback:logback-core:1.1.3',
'javax.mail:mail:1.5.0-b01',
'org.apache.xmlbeans:xmlbeans:2.6.0',
'com.mchange:c3p0:0.9.5.1',
'org.apache.tomcat:tomcat-jdbc:8.0.24',
'org.postgresql:postgresql:9.4-1201-jdbc41'
...
}
tomcat{
contextPath = 'portal-api'
httpPort = 8081
}
[tomcatRun, tomcatRunWar]*.configFile = file('/opt/configuration/context-backend.xml')
最后一行是我尝试通过官方常见问题处理它的方式。
似乎我接近胜利 - tomcat开始,但随后立即停止:
[localhost-startStop-1] INFO org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'spring': initialization completed in 224 ms
Started Tomcat Server
The Server is running at http://localhost:8081/portal-api
[main] INFO org.springframework.web.context.support.XmlWebApplicationContext - Closing WebApplicationContext for namespace 'spring-servlet': startup date [Thu Aug 06 20:45:35 MSK 2015]; parent: Root WebApplicationContext
[main] INFO org.springframework.web.context.support.XmlWebApplicationContext - Closing Root WebApplicationContext: startup date [Thu Aug 06 20:45:26 MSK 2015]; root of context hierarchy
[main] INFO org.springframework.context.support.DefaultLifecycleProcessor - Stopping beans in phase 2147483647
[main] INFO org.quartz.core.QuartzScheduler - Scheduler org.springframework.scheduling.quartz.SchedulerFactoryBean#0_$_NON_CLUSTERED paused.
[main] INFO org.springframework.scheduling.quartz.SchedulerFactoryBean - Shutting down Quartz Scheduler
[main] INFO org.quartz.core.QuartzScheduler - Scheduler org.springframework.scheduling.quartz.SchedulerFactoryBean#0_$_NON_CLUSTERED shutting down.
[main] INFO org.quartz.core.QuartzScheduler - Scheduler org.springframework.scheduling.quartz.SchedulerFactoryBean#0_$_NON_CLUSTERED paused.
[main] INFO org.quartz.core.QuartzScheduler - Scheduler org.springframework.scheduling.quartz.SchedulerFactoryBean#0_$_NON_CLUSTERED shutdown complete.
[main] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor - Shutting down ExecutorService
The web application [/portal-api] appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-1] but has failed to stop it. This is very likely to create a memory leak.
The web application [/portal-api] appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-2] but has failed to stop it. This is very likely to create a memory leak.
The web application [/portal-api] appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-3] but has failed to stop it. This is very likely to create a memory leak.
The web application [/portal-api] appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-4] but has failed to stop it. This is very likely to create a memory leak.
The web application [/portal-api] appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-5] but has failed to stop it. This is very likely to create a memory leak.
The web application [/portal-api] appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] but has failed to stop it. This is very likely to create a memory leak.
The web application [/portal-api] appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-7] but has failed to stop it. This is very likely to create a memory leak.
The web application [/portal-api] appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-8] but has failed to stop it. This is very likely to create a memory leak.
The web application [/portal-api] appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-9] but has failed to stop it. This is very likely to create a memory leak.
The web application [/portal-api] appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-10] but has failed to stop it. This is very likely to create a memory leak.
:service-backend:tomcatRunWar FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':service-backend:tomcatRunWar'.
> An error occurred starting the Tomcat server.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 31.409 secs
使用--stacktrace看起来好像发生了两个副本:
[localhost-startStop-1] INFO org.flywaydb.core.internal.dbsupport.DbSupportFactory - Database: jdbc:postgresql://localhost:5432/egais013 (PostgreSQL 9.4)
[localhost-startStop-1] INFO ru.rlh.egais.portal.backend.configuration.DatabaseVersionValidator - EGAIS database schema version: 3.0.35 (application requirement: 3.0.22+)
[localhost-startStop-1] INFO com.mangofactory.swagger.plugin.SwaggerPluginAdapter - Skipping SwaggerSpringMvcPlugin initialization already initialized!
[localhost-startStop-1] INFO org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'spring': initialization completed in 198 ms
Started Tomcat Server
The Server is running at http://localhost:8081/portal-api
[main] INFO org.springframework.web.context.support.XmlWebApplicationContext - Closing WebApplicationContext for namespace 'spring-servlet': startup date [Thu Aug 06 20:34:06 MSK 2015]; parent: Root WebApplicationContext
[main] INFO org.springframework.web.context.support.XmlWebApplicationContext - Closing Root WebApplicationContext: startup date [Thu Aug 06 20:33:55 MSK 2015]; root of context hierarchy
[main] INFO org.springframework.context.support.DefaultLifecycleProcessor - Stopping beans in phase 2147483647
[main] INFO org.quartz.core.QuartzScheduler - Scheduler org.springframework.scheduling.quartz.SchedulerFactoryBean#0_$_NON_CLUSTERED paused.
[main] INFO org.springframework.scheduling.quartz.SchedulerFactoryBean - Shutting down Quartz Scheduler
[main] INFO org.quartz.core.QuartzScheduler - Scheduler org.springframework.scheduling.quartz.SchedulerFactoryBean#0_$_NON_CLUSTERED shutting down.
[main] INFO org.quartz.core.QuartzScheduler - Scheduler org.springframework.scheduling.quartz.SchedulerFactoryBean#0_$_NON_CLUSTERED paused.
[main] INFO org.quartz.core.QuartzScheduler - Scheduler org.springframework.scheduling.quartz.SchedulerFactoryBean#0_$_NON_CLUSTERED shutdown complete.
[main] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor - Shutting down ExecutorService
:service-backend:tomcatRunWar FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':service-backend:tomcatRunWar'.
> An error occurred starting the Tomcat server.
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':service-backend:tomcatRunWar'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:305)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: org.gradle.api.GradleException: An error occurred starting the Tomcat server.
at com.bmuschko.gradle.tomcat.tasks.AbstractTomcatRun.startTomcat(AbstractTomcatRun.groovy:370)
at com.bmuschko.gradle.tomcat.tasks.AbstractTomcatRun$_validateConfigurationAndStartTomcat_closure2.doCall(AbstractTomcatRun.groovy:228)
at com.bmuschko.gradle.tomcat.tasks.AbstractTomcatRun$_validateConfigurationAndStartTomcat_closure2.doCall(AbstractTomcatRun.groovy)
at com.bmuschko.gradle.tomcat.internal.LoggingHandler.withJdkFileLogger(LoggingHandler.groovy:56)
at com.bmuschko.gradle.tomcat.internal.LoggingHandler$withJdkFileLogger.callStatic(Unknown Source)
at com.bmuschko.gradle.tomcat.tasks.AbstractTomcatRun.validateConfigurationAndStartTomcat(AbstractTomcatRun.groovy:227)
at com.bmuschko.gradle.tomcat.tasks.AbstractTomcatRun$_start_closure1.doCall(AbstractTomcatRun.groovy:220)
at com.bmuschko.gradle.tomcat.tasks.AbstractTomcatRun$_start_closure1.doCall(AbstractTomcatRun.groovy)
at com.bmuschko.gradle.tomcat.internal.utils.TomcatThreadContextClassLoader.withClasspath(TomcatThreadContextClassLoader.groovy:30)
at com.bmuschko.gradle.tomcat.internal.utils.ThreadContextClassLoader$withClasspath.call(Unknown Source)
at com.bmuschko.gradle.tomcat.tasks.AbstractTomcatRun.start(AbstractTomcatRun.groovy:219)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:218)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:579)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:562)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 44 more
Caused by: java.net.BindException: Address already in use
at com.bmuschko.gradle.tomcat.internal.ShutdownMonitor.<init>(ShutdownMonitor.groovy:48)
at com.bmuschko.gradle.tomcat.tasks.AbstractTomcatRun.startTomcat(AbstractTomcatRun.groovy:363)
... 62 more
BUILD FAILED
Total time: 29.435 secs
完整开始日志:http://ur1.ca/ndeis
P.S。最初我在插件的作者中问过它:https://github.com/bmuschko/gradle-tomcat-plugin/issues/130但是暂时没有任何答案......
答案 0 :(得分:0)
https://github.com/ndzou/httpie-negotiate 花了很多时间......我将gradle从2.2升级到2.7以及项目中的一些libs。我不能确切地说改变了什么,但它现在通过文档向前推进。 我认为这只是旧的问题。
回答这个问题同时标记它不再需要注意了。