Coder Social home page Coder Social logo

Comments (4)

bmuschko avatar bmuschko commented on June 3, 2024

Did you assign your Servlet dependency to the providedCompile configuration? Please see the FAQ section "Why do I get a java.lang.ClassCastException on javax.servlet.Servlet?". If that doesn't help please post your full build script.

from gradle-tomcat-plugin.

nileshmalpekar avatar nileshmalpekar commented on June 3, 2024

Thanks for your prompt response. Tried the FAQ option but didn't work.

here's the build.gradle file
{code}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'tomcat'

sourceCompatibility='1.6'

repositories {
mavenCentral()
}

dependencies {
def tomcatVersion = '7.0.35'

compile group: 'org.apache.tomcat', name: 'tomcat-servlet-api', version: '7.0.35'

    tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
           "org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"

    tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
        exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
    }

}

buildscript {
repositories {
mavenCentral()
}

dependencies {
    classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:0.9.6'
}

}

Version ver = new Version(major: 0, minor: 1, releaseType: 'BETA')
version = ver

project.ext.set("ver", ver);

war {
manifest {
attributes(
"Specification-Title": "Sample Webapp",
"Specification-Version": ver.specVersion(),
"Specification-Vendor": "Nilux Inc",
"Implementation-Title": "Sample Webapp Servlet Framework",
"Implementation-Version": version
)
}
}

[tomcatRun, tomcatRunWar]*.contextPath = "try1"

class Version {
int major
int minor
int bugfix
String releaseType

String specVersion() {
    "${major}.${minor}";
}
String toString() {
    specVersion() + "-${releaseType}${bugfix ? '.' + bugfix : ''}";
}

}
{code}

Note: that tomcatRunWar works fine but not tomcatRun

Essentially I want to run integration tests in the end. If there is a way to run tomcatRunWar for integration tests then that would work as well
{code}
task integrationTest(type: Test) {
include '_/_IntegrationTest.'

doFirst {
    tomcatRun.daemon = true
    tomcatRun.execute()
}

doLast {
    tomcatStop.execute()
}

}

test {
exclude '_/_IntegrationTest.'
}
{code}

from gradle-tomcat-plugin.

bmuschko avatar bmuschko commented on June 3, 2024

I think I'd need to play around with your sample app. If you can check it into GitHub I might be able to have a look. You can run the integration tests with tomcatRunWar as well. You don't necessarily have to use tomcatRun.

BTW: Can you please use correct Markdown notation for your code when commenting on GitHub?

from gradle-tomcat-plugin.

nileshmalpekar avatar nileshmalpekar commented on June 3, 2024

I fixed my problem my moving to tomcatRunWar and putting dependency on the task war for the same.

from gradle-tomcat-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.