Error : "No global global web.xml found" while deploying web Java application to tomcat using Gradle

时间:2016-04-25 09:32:55

标签: java web gradle web.xml tomcat8

I use Gradle and Tomcat plugin to deploy my Java web application to Tomcat. gradle war works fine, but when I execute gradle tomcatRun --info, I get error "No global global web.xml found" and building stops on 75%.

My build.gradle:

 buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.bmuschko:gradle-tomcat-plugin:2.0'
    }
}

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'com.bmuschko.tomcat'

// JDK version source compatibility
sourceCompatibility = 1.8
// project version
version = '1.0'
// War file name
war.baseName = 'jcg-gradle-war-example'
// Web directory, this overrides the default value "webapp"
project.webAppDirName = 'WebContent'
project.buildDir = 'WebContent/WEB-INF/classes'

sourceSets {
    main {
        java {
            srcDir 'src/pack'
        }
        resources {
            srcDir 'src/resources'
        }
    }
}

configurations {
   moreLibs
}

war {
    from 'src/pack' // adds a file-set to the root of the archive
    webInf { from 'WebContent/WEB-INF' } // adds a file-set to the WEB-INF dir.
    classpath fileTree('WebContent/WEB-INF/lib') // adds a file-set to the WEB-INF/lib dir.
    classpath configurations.moreLibs // adds a configuration to the WEB-INF/lib dir.
    webXml = file('WebContent/WEB-INF/web.xml') // copies a file to WEB-INF/web.xml
}

repositories {
   mavenCentral()
}

dependencies {
    def tomcatVersion = '8.0.33'
    tomcat 'org.apache.tomcat.embed:tomcat-embed-core:8.0.33',
            'org.apache.tomcat.embed:tomcat-embed-logging-juli:8.0.33'
    tomcat('org.apache.tomcat.embed:tomcat-embed-jasper:8.0.33') {
        exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
    }

}

tomcatRun {
    webDefaultXml = file("WebContent/WEB-INF/web.xml")
    httpPort = 8080
    httpsPort = 8091
    enableSSL = true
}

tomcatRun.contextPath = '/'
tomcatRunWar.contextPath = '/'

Project folders:

TestGradle
---.gradle
---.setting
---src
------main
------pack
---------AAA.java
------resources
---------main
---WebContent
------META-INF
------WEB-INF
---------classes
---------lib
---------web.xml
------index.jsp
---.classpath
---.project
---build.gradle

And this is gradle tomcatRun results:

D:\My Documents\Workspase_EE\TestGradle>gradle tomcatRun --info
Starting Build
Settings evaluated using settings file 'D:\master\settings.gradle'.
Projects loaded. Root project using build file 'D:\My Documents\Workspase_EE\Te
tGradle\build.gradle'.
Included projects: [root project 'TestGradle']
Evaluating root project 'TestGradle' using build file 'D:\My Documents\Workspas
_EE\TestGradle\build.gradle'.
All projects evaluated.
Selected primary task 'tomcatRun' from project :
Tasks to be executed: [task ':compileJava', task ':processResources', task ':cl
sses', task ':tomcatRun']
:compileJava (Thread[main,5,main]) started.
:compileJava
file or directory 'D:\My Documents\Workspase_EE\TestGradle\src\main\java', not
ound
file or directory 'D:\My Documents\Workspase_EE\TestGradle\src\main\java', not
ound
Skipping task ':compileJava' as it is up-to-date (took 0.065 secs).
:compileJava UP-TO-DATE
:compileJava (Thread[main,5,main]) completed. Took 0.159 secs.
:processResources (Thread[main,5,main]) started.
:processResources
file or directory 'D:\My Documents\Workspase_EE\TestGradle\src\main\resources',
not found
Skipping task ':processResources' as it has no source files.
:processResources UP-TO-DATE
:processResources (Thread[main,5,main]) completed. Took 0.02 secs.
:classes (Thread[main,5,main]) started.
:classes
Skipping task ':classes' as it has no actions.
:classes UP-TO-DATE
:classes (Thread[main,5,main]) completed. Took 0.013 secs.
:tomcatRun (Thread[main,5,main]) started.
:tomcatRun
Executing task ':tomcatRun' (up-to-date check took 0.001 secs) due to:
  Task.upToDateWhen is false.
Configuring Tomcat for root project 'TestGradle'
Default web.xml = D:\My Documents\Workspase_EE\TestGradle\WebContent\WEB-INF\we
.xml
HTTP protocol handler classname = org.apache.coyote.http11.Http11Protocol
HTTPS protocol handler classname = org.apache.coyote.http11.Http11Protocol
Webapp source directory = D:\My Documents\Workspase_EE\TestGradle\WebContent
Resolved Tomcat 8x server implementation in classpath
web app loader classpath = D:\My Documents\Workspase_EE\TestGradle\WebContent\W
B-INF\classes\classes\main;D:\My Documents\Workspase_EE\TestGradle\WebContent\W
B-INF\classes\resources\main
Creating SSL certificate
Created SSL certificate
Initializing ProtocolHandler ["http-bio-8080"]
Initializing ProtocolHandler ["ajp-bio-8009"]
Initializing ProtocolHandler ["http-bio-8091"]
Starting service Tomcat
Starting Servlet Engine: Apache Tomcat/8.0.33
No global web.xml found
At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug loggi
g for this logger for a complete list of JARs that were scanned but no TLDs wer
 found in them. Skipping unneeded JARs during scanning can improve startup time
and JSP compilation time.
Starting ProtocolHandler ["http-bio-8080"]
Starting ProtocolHandler ["ajp-bio-8009"]
Starting ProtocolHandler ["http-bio-8091"]
Started Tomcat Server
The Server is running at http://localhost:8080
> Building 75% > :tomcatRun

I know, I'm a little bit stupid, but I have been fighting with this a few days:) I use Eclipse EE, Tomcat 8.0.33, Gradle-2.12.

P.S. Sorry for my English:)

0 个答案:

没有答案
相关问题