Coder Social home page Coder Social logo

Comments (6)

bmuschko avatar bmuschko commented on June 3, 2024

Did you try to assign the configuration providedCompile? If you still get the same error message I guess you have a transitive dependency to javax.servlet.Servlet in one of your dependencies. You'd need to find out which one it is and exclude it.

from gradle-tomcat-plugin.

303devworks avatar 303devworks commented on June 3, 2024

Yes, we had providedCompile in there as documented in the FAQ. The (maybe) solution ended up being:

    configurations{
         runtime.exclude group: 'javax.servlet'
    }

However, some people get this when they hit a web page. I have no idea why as tomcat should provide this. 3 people work fine, 2 people get this error:
org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 11 in the generated java file
D:\projects\eventstore\build\tmp\tomcatRunWar\work\Tomcat\localhost\eventstore\org\apache\jsp\index_jsp.java:11: package javax.servlet does not exist
import javax.servlet.*;
^

from gradle-tomcat-plugin.

bmuschko avatar bmuschko commented on June 3, 2024

A JSP becomes a Servlet when it gets compiled on the first request. Therefore, you will need to have a dependency on javax.servlet.Servlet. Using runtime.exclude group: 'javax.servlet' will exclude all dependencies on javax.servlet.Servlet. You will need to have one and only one dependency to it for Tomcat to work correctly.

Do you have a public repository that I can have a look at?

from gradle-tomcat-plugin.

303devworks avatar 303devworks commented on June 3, 2024

Sadly, no public repo. Here is the build.gradle though: https://gist.github.com/1583362

I wouldn't think that I'd need to have a servlet dependency as tomcat has javax.servlet provided.

the whole thing is quite confusing as it works fine on some machines. I did a clean checkout from svn and clean gradle install and it worked. both machines that it failed on had gradle m6 installed.

btw, have you thought about contributing this plugin to gradle?

from gradle-tomcat-plugin.

bmuschko avatar bmuschko commented on June 3, 2024

OK, let's eliminate some potential environment issues first. I'd recommend you use the Gradle Wrapper for your project. Everyone will have to use the Wrapper and not their locally installed Gradle runtime. This should make all environments behave the same and makes upgrading the Gradle version much easier.

The following code block in your Gist excludes all javax.servlet.Servlet dependencies and therefore you get the compilation issue. It doesn't really matter if it is being pulled in as a transitive dependency by Tomcat or by Spring.

configurations {
    runtime.exclude group: 'javax.servlet'
}

You will have to decide weather you want to use the standard or Spring Servlet. You can find out the transitive dependencies for each declaration by running gradle dependencies. Based on that result exclude it and make sure there's only one on the classpath. If you run gradle tomcatRun -i you will get info logging for the Tomcat plugin as well. It will give you detailed information on the used runtime classpath. That should give you an idea which javax.servlet.Servlet dependencies are used.

BTW: You won't need the following code block because port 8080 is used by default.

tomcatRun {
   httpPort = 8080
}

Actually, I did think of contributing the plugin but it might pose several issues. I might ask on the Gradle Forum to see if they are interested.

  • Currently, each plugin in Gradle core also brings in it's dependencies. These dependencies will clash with the dependencies of the Jetty plugin.
  • Gradle core might restrict the Tomcat version you can use.
  • Potential classloading issues.

from gradle-tomcat-plugin.

303devworks avatar 303devworks commented on June 3, 2024

thanks for your answer. I can't duplicate the problem on my machine, so it makes it tough to solve. I'll be spending more time on this next week.

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.