Comments (6)
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.
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.
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.
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.
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.
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)
- Daemon does not stop HOT 4
- Define which war to use HOT 9
- Gradle Daemon - Caused by: java.lang.Error: factory already defined HOT 2
- Can I tell `TomcatRun` where is the exploded web directory? HOT 1
- Documentation - add example to compile translated jsps HOT 1
- Setting default jsp package name from org.apache.jsp to your choice HOT 2
- Acessing environment variables with the plugin HOT 1
- Gradle 6.2.2 shows deprecation warning regarding jasperAttributes HOT 3
- IllegalArgumentException: The AJP Connector is configured with secretRequired="true" but the secret attribute is either null or "". HOT 7
- How to run the Tomcat server at http://localhost:8080 instead of http://localhost:8080/ProjectName? HOT 2
- Skip Jar Scanning for Annotations HOT 1
- tomcatRun fails with Gradle 7.0 due to @Internal annotation on private getter HOT 11
- 2.6 Release HOT 3
- How to configure environment variables when calling tomcatRun? HOT 1
- Tomcat 10 support
- HTTP2 support
- does this can do like maven tomcat plugin which can build jar not war HOT 1
- Remove usage of WarPluginConvention
- Getting groovy.lang.MissingMethodException after upgrading to tomcat plugin 2.7.0, was using 2.5 before HOT 1
- The AJP Connector is configured with secretRequired="true"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gradle-tomcat-plugin.