开发者

Grails beginner problem "Failed to invoke Servlet 2.5"

开发者 https://www.devze.com 2022-12-31 17:41 出处:网络
[UPDATE] Apparently I\'m not the only one with this problem - http://grails.1312388.n4.nabble.com/Beginner-ERROR-Failed-to-invoke-Servlet-2-5-getContextPath-method-td2222279.html .It has also appeare

[UPDATE]

Apparently I'm not the only one with this problem - http://grails.1312388.n4.nabble.com/Beginner-ERROR-Failed-to-invoke-Servlet-2-5-getContextPath-method-td2222279.html . It has also appeared on a Windows machine and in the Netbeans IDE on OS X.

At this point, the part that has me particularly perplexed, is I can run my Grails apps just fine from within Eclipse, but the second I try to run them from the Terminal they bomb. As far as I can tell, they are both being run from the grails-core directory, so why would it work from within Eclipse but not from the Terminal?

[/UPDATE]

I'm trying to get Grails set up on a Snow Leopard machine. I followed all the grails.com install directions and am trying to start the application from Grails: A Quick-Start Guide by Dave Klein. I ran grails create-app TekDays with no apparent problems and was able to cd to the TekDays folder, but when I try to run grails run-app I get the following:

Welcome to Grails 1.3.1 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /grails

Base Directory: /apps/TekDays
Resolving dependencies...
Dependencies resolved in 4469ms.
Running script /grails/scripts/RunApp.groovy
Environment set to development
   [delete] Deleting directory /Users/name/.grails/1.3.1/projects/TekDays/tomcat
Running Grails application..
2010-05-24 21:42:39,559 [main] ERROR context.GrailsContextLoader  - Error executing bootstraps: Failed to invoke Servlet 2.5 getContextPath method
java.lang.IllegalStateException: Failed to invoke Servlet 2.5 getContextPath method
    at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:164)
    at grails.web.container.EmbeddableServer$start.call(Unknown Source)
    at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy:159)
    at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy)
    at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:282)
    at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
    at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:150)
    at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy)
    at _GrailsRun_groovy.runInline(_GrailsRun_groovy:116)
    at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
    at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59)
    at RunApp$_run_closure1.doCall(RunApp.groovy:33)
    at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
    at gant.Gant.withBuildListeners(Gant.groovy:427)
    at gant.Gant.this$2$withBuildListeners(Gant.groovy)
    at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
    at gant.Gant.dispatch(Gant.groovy:415)
    at gant.Gant.this$2$dispatch(Gant.groovy)
    at gant.Gant.invokeMethod(Gant.groovy)
    at gant.Gant.executeTargets(Gant.groovy:590)
    at gant.Gant.executeTargets(Gant.groovy:589)
Caused by: java.lang.NoSuchMethodException: javax.servlet.ServletContext.getC开发者_如何学PythonontextPath()
    at java.lang.Class.getMethod(Class.java:1605)
    ... 23 more

I've googled every derivative of "Failed to invoke Servlet 2.5" that I can think of, but have thus far been unable to find anything that helps me understand, yet alone resolve, the error.

Any advice to help me resolve this would be very much appreciated!


I know I'm a little late to the party, but I was just able to resolve this same issue on my machine, and thought i'd share my results incase anyone else stumbles across this on Google.

Newer versions of Grails (1.3.7) include the groovy libraries, so you do not need to reference the groovy jars in your project. When I downgraded from IntelliJ 10 to 9, I incorrectly added the reference to Groovy thinking I needed it. One of the explanations for java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath() is that you are including libraries with methods already declared, which appears to have been the problem for me.

Hope this helps someone else!


Look for a servlet-api jar file in /lib and delete it.

In my case I had servlet-api-2.3.jar, which was imported by another dependency. The error specifically states getContextPath is a Servlet 2.5 method.


It is most definitely an issue with the CLASSPATH. For me it was a selenium-server.jar for some reason, but for someone else it could be something else.

I would delete a jar from the CLASSPATH in my shell window (export CLASSPATH=".;C:/one/less/jar.jar;") until figure out which jar is causing problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消