Coder Social home page Coder Social logo

Comments (13)

bmuschko avatar bmuschko commented on June 13, 2024

Thanks, I am glad you find the plugin useful. It's good you are letting me know about this issue.

I personally haven't used the new Spring 3.1 MVC features yet but based on the documentation it looks like they do some special things with the default web.xml.

The caveat to overriding the "/" Servlet mapping is that the RequestDispatcher for the default Servlet must be retrieved by name rather than by path. The DefaultServletHttpRequestHandler will attempt to auto-detect the default Servlet for the container at startup time, using a list of known names for most of the major Servlet containers (including Tomcat, Jetty, Glassfish, JBoss, Resin, WebLogic, and WebSphere). If the default Servlet has been custom configured with a different name, or if a different Servlet container is being used where the default Servlet name is unknown, then the default Servlet's name must be explicitly provided.

I guess this works fine if you deploy it to an installed container because it provides its default web.xml. The Tomcat Gradle plugin uses an embedded Tomcat container implementation instead. I'd have to check both Tomcat and Spring implementations to see what the default Servlet gets registered with and see if I can make this work. I already have a convention property in place that lets you set the default web.xml so I guess that will be the key to making it work.

FYI: I tried out the Gradle Jetty plugin and couldn't get it running right away as well.

from gradle-tomcat-plugin.

tinhtruong avatar tinhtruong commented on June 13, 2024

I want to add some more details to this issue with my findings on version 0.8.1.
My Spring MVC 3.1 web app does not have web.xml file (Servlet 3.0). I can tomcatRunWar (@RequestMapping work perfectly) with my application but cannot with tomcatRun (the behavior is the same as djKianoosh described).

from gradle-tomcat-plugin.

bmuschko avatar bmuschko commented on June 13, 2024

Thanks for your feedback @tinhtruong. Unfortunately, I couldn't get @djKianoosh's application running with tomcatRunWar either. The console output is certainly different though. I will have to further investigate on this.

@tinhtruong: Do you have your app publicly available?

from gradle-tomcat-plugin.

sdeleuze avatar sdeleuze commented on June 13, 2024

Same issue here, also on spring-backbone example application.

What is strange is that classpath scanning occured (typical stratup lag) but I got the following message :

No global web.xml found
No Spring WebApplicationInitializer types detected on classpath

I hope somebody will be able to fix this bug ...

from gradle-tomcat-plugin.

bmuschko avatar bmuschko commented on June 13, 2024

I believe this to be a bug in the embedded Tomcat container implementation. Please check this issue I created. Looks like I need to provide a test case. I will try to set up a test project for them soon.

from gradle-tomcat-plugin.

sdeleuze avatar sdeleuze commented on June 13, 2024

Perhaps an information that can help : it works with t7mp Maven plugin (http://t7mp.github.com/) with the Spring 3.1 Backbone example application https://github.com/sdeleuze/spring-backbone-todo. I think it use also the embedded Tomcat, but perhaps in another way ...

from gradle-tomcat-plugin.

cbeams avatar cbeams commented on June 13, 2024

See my comments on the bugzilla issue: https://issues.apache.org/bugzilla/show_bug.cgi?id=52853#c11

They basically echo @sdeleuze, giving a different working example of the tomcat7-maven-plugin deploying a web.xml-free Spring 3.1 app without any problem.

from gradle-tomcat-plugin.

sdeleuze avatar sdeleuze commented on June 13, 2024

I have updated the sample yesterday in order to make it work also is Maven Jetty plugin. I think it could make it work also with the Gradle Tomcat plugin, I will test and send a feedback shortly.

For information, I had to provide a custom empty web.xml in order to override Jetty webdefault.xml that contained a dispatcher that conflicted with the one declared in Java code + a fix in the WebApplicationInitializer.

Related changeset is here : sdeleuze/spring-backbone-todo@9e4d65c

from gradle-tomcat-plugin.

bmuschko avatar bmuschko commented on June 13, 2024

It would be great if you could provide a pull request. As far as I understood the spec you don't need to provide an empty web.xml. But if that's what it takes to make it work for now I'd be happy with it. I think this empty web.xml would have to be generated on-the-fly. Thanks for the pointer. I won't have time this weekend to have a look at it but I might have some room next week.

from gradle-tomcat-plugin.

bmuschko avatar bmuschko commented on June 13, 2024

I tried to use an empty web.xml but that doesn't seem to make it work. Apparently, the behavior is different from Jetty. This is what I tried:

tomcatRun.webDefaultXml = file('web.xml')

After checked the Maven plugin I found this patch. I played around with this a bit but couldn't achieve the result we are aiming for. However, I finished up my test cases for the Tomcat guys so hopefully they will have a look at this issue now and give me the correct advice to make it work.

from gradle-tomcat-plugin.

bmuschko avatar bmuschko commented on June 13, 2024

This is fixed with version 0.9.2.

from gradle-tomcat-plugin.

cbeams avatar cbeams commented on June 13, 2024

That's great news, Benjamin. Thanks!

from gradle-tomcat-plugin.

sdeleuze avatar sdeleuze commented on June 13, 2024

Thanks !

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.