grails-core: Intermittent 404 error when deployed in Tomcat 7
Steps to Reproduce
Please fork my sample application
- Create a prod war
- Deploy it in one Tomcat 7 (I’m using apache-tomcat-7.0.55)
- Try to access http://localhost:8080/teste2/teste/index. Sometimes it will display the page and others will show the /error page. To test the intermittent behavior just restart and redeploy the same war.
Expected Behaviour
The expected in this scenario is to always show the page, since it’s not secured. I’m not confident if this is a Grails core or Spring Security plugin bug, so I’m reporting it here.
Actual Behaviour
Sometimes the flow will end in the /error page, and others will display it correctly.
Environment Information
- Operating System: Windows 8.1 or 10
- Grails Version: 3.1.4
- Groovy Version: 2.4.6
- JVM Version: 1.7.0_79
- Tomcat Version: 7.0.55
Debug information
I nailed down to UrlMappingsHandlerMapping
class, you can see that I created a new class to debug it. I can notice that sometimes it handles correctly and return the org.grails.web.mapping.mvc.GrailsControllerUrlMappingInfo
intance, but sometimes the flow will use one org.grails.web.mapping.DefaultUrlMappingInfo
instance, causing the 404 error. Maybe the problem is inside the urlMappingsHolder
class.
Here’s the debug that will be printed when the flow ends incorrectly
DEBUG org.grails.web.mapping.DefaultUrlMappingsHolder - Attempting to match URI
[/teste/index] with pattern [/oauth/(*)/(*)]
DEBUG org.grails.web.mapping.DefaultUrlMappingsHolder - Attempting to match URI
[/teste/index] with pattern [/(*)/(*)?/(*)?(.(*))?]
DEBUG org.grails.web.mapping.DefaultUrlMappingsHolder - Matched URI [/teste/inde
x] with pattern [/(*)/(*)?/(*)?(.(*))?], adding to posibilities
INFO org.grails.web.mapping.mvc.CwiUrlMappingsHandler - LOOP in UrlMappingsInfo
availables for the match: org.grails.web.mapping.mvc.GrailsControllerUrlMappings
@6399bced
INFO org.grails.web.mapping.mvc.CwiUrlMappingsHandler - UrlMappingInfo: /(*)/(*)
?/(*)?(.(*))? , class org.grails.web.mapping.DefaultUrlMappingInfo
INFO org.grails.web.mapping.mvc.CwiUrlMappingsHandler - RETURN NULL!
INFO org.grails.web.mapping.mvc.CwiUrlMappingsHandler - getHandlerInternal() : n
ull
Any report is really appreciated, since this error is blocking us from deploying this application in the production environment (run-app works).
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 21 (21 by maintainers)
Tested on Windows 7 again with the following setup:
Still not able to reproduce. I advise that you navigate to your Tomcat
bin
directory and start Tomcat using (assuming Windows):Attach a remote debugger and set a break point around here:
https://github.com/grails/grails-core/blob/master/grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/mvc/AbstractGrailsControllerUrlMappings.groovy#L52
And observe whether the controllers are being registered correctly. My suspicion is this is a JDK specific concurrency bug, but without the ability to reproduce we would need feedback from yourself to advance this issue.
Huge thanks! Now all makes sense, and my test application works correctly.
Try a
gradle clean install
on your plugin project, I suspect the issue is that IntelliJ compiled classes were used when building your pluginI’m pretty sure it was created by the
create-plugin
command.