1

我一直在eclipse的STS中开发一个Grails项目,当我从那里运行/调试它时它运行良好,但是当我在Intellij-Idea(v-12.1.4)中打开同一个项目时,它没有运行给我异常跟踪如下:

"C:\Program Files\Java\jdk1.7.0_17\bin\java" -Dgrails.home=C:\grails-2.2.1 -Dbase.dir=C:\Users\nnill2\Documents\workspace-sts-3.2.0.RELEASE\SocialAuthWithSpringSecurity "-Dtools.jar=C:\Program Files\Java\jdk1.7.0_17\lib\tools.jar" -Dgroovy.starter.conf=C:\grails-2.2.1/conf/groovy-starter.conf -Dserver.port=8080 -Xmx768M -Xms768M -XX:MaxPermSize=256m -XX:PermSize=256m -Djline.WindowsTerminal.directConsole=false -javaagent:C:\grails-2.2.1\lib\org.springsource.springloaded\springloaded-core\jars\springloaded-core-1.1.1.jar -noverify -Dspringloaded=profile=grails -Didea.launcher.port=7532 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 12.1.4\bin" -Dfile.encoding=UTF-8 -classpath "C:\grails-2.2.1\lib\org.codehaus.groovy\groovy-all\jars\groovy-all-2.0.7.jar;C:\grails-2.2.1\dist\grails-bootstrap-2.2.1.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 12.1.4\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.groovy.grails.cli.support.GrailsStarter --main org.codehaus.groovy.grails.cli.GrailsScriptRunner --conf C:\grails-2.2.1/conf/groovy-starter.conf --classpath C:\Users\nnill2\Desktop\dist\dist\socialauth-4.2.jar;C:\Users\nnill2\Desktop\dist\dist\socialauth-cdi-2.1.jar;C:\Users\nnill2\Desktop\dist\dist\socialauth-cmd-utility-1.1.jar;C:\Users\nnill2\Desktop\dist\dist\socialauth-filter-2.4.jar;C:\Users\nnill2\Desktop\dist\dist\socialauth-seam-2.1.jar;C:\Users\nnill2\Desktop\dist\dist\socialauth-spring-2.3.jar run-app

     Loading Grails 2.2.1
| Configuring classpath
| Configuring classpath.
| Environment set to development
| Environment set to development.
| Environment set to development..
| Environment set to development...
| Environment set to development....
| Environment set to development.....
| Packaging Grails application
| Packaging Grails application.
| Packaging Grails application..
| Packaging Grails application...
| Packaging Grails application....
| Compiling 1 source files
| Compiling 1 source files.
| Compiling 1 source files..
| Compiling 1 source files...
| Compiling 1 source files....
| Compiling 1 source files.....
| Running Grails application
| Error 2013-06-26 10:11:04,250 [Tomcat-startStop-1] ERROR core.ContainerBase  - A child container failed during start
Message: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/SocialAuthWithSpringSecurity]]
    Line | Method
->>  252 | innerGet  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    111 | get       in java.util.concurrent.FutureTask
|    334 | innerRun  in java.util.concurrent.FutureTask$Sync
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread

Caused by LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/SocialAuthWithSpringSecurity]]
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread

Caused by NoSuchMethodError: javax.servlet.ServletContext.getSessionCookieConfig()Ljavax/servlet/SessionCookieConfig;
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread
| Error 2013-06-26 10:11:04,376 [main] ERROR core.ContainerBase  - A child container failed during start
Message: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
   Line | Method
->> 252 | innerGet in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   111 | get      in java.util.concurrent.FutureTask
|   140 | doStart  in org.grails.plugins.tomcat.InlineExplodedTomcatServer
|   124 | start    in org.grails.plugins.tomcat.TomcatServer
|    65 | doCall . in _GrailsRun_groovy$_run_closure1
|    35 | doCall   in RunApp$_run_closure1
^   120 | main . . in com.intellij.rt.execution.application.AppMain

Caused by LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   166 | run      in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|   615 | run      in java.util.concurrent.ThreadPoolExecutor$Worker
^   722 | run . .  in java.lang.Thread

Caused by LifecycleException: A child container failed during start
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   166 | run      in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|   615 | run      in java.util.concurrent.ThreadPoolExecutor$Worker
^   722 | run . .  in java.lang.Thread
| Error Server failed to start: Failed to start component [StandardServer[-1]] (Use --stacktrace to see the full trace)

Process finished with exit code 1

我已经阅读了许多类似的问题,例如: https://stackoverflow.com/questions/11112483/trying-to-start-tomcat-server-for-the-first-time-and-getting-an-error,https: //stackoverflow.com/questions/11713839/cant-run-app-on-grails,https://stackoverflow.com/questions/10556201/tomcat-7-0-27-not-starting。每个建议都表明项目构建路径中存在一些导致问题的 servlet-api.jar。但是我在我的项目中搜索过它但找不到jar。我正在使用 JDK-7。任何帮助将不胜感激!!!

编辑 该项目使用 grails 命令行工具 (Tools->Grails->Run-Target) 运行得非常好,但只有运行/调试图标失败。

4

2 回答 2

2

禁用 Grails 运行配置中的“添加 --classpath”复选框,以防止将“--classpath socialauth-*-*.jar”添加到命令行。所有外部库都将由 Grails 加载,不需要“--classpath socialauth-*-*.jar”。

手动删除 socialauth-cmd-utility-1.1.jar 不是一个好主意,因为 IntelliJ 会在下一个同步 Grails 设置中自动添加 socialauth-cmd-utility-1.1.jar。

于 2013-06-26T09:09:19.077 回答
0

呸!我终于解决了!实际上堆栈跟踪中的以下行:

 Caused by NoSuchMethodError: javax.servlet.ServletContext.getSessionCookieConfig()Ljavax/servlet/SessionCookieConfig;
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync

指出 javax.servlet.ServletContext.getSessionCookieConfig() 函数的一些致病因素。我扫描了外部库以找出类似的匹配函数,并意识到有两种情况:

  1. 在 grails-2.2.1 下有一个名为 servlet-api-2.4.jar 的 jar
  2. 还有另一个名为 socialauth-cmd-utility-1.1.jar 的 jar

实际上错误是由于第二个罐子造成的。因此,我使用以下步骤将其从外部库中删除:

  1. 右键单击 socialauth-cmd-utility-1.1.jar
  2. 转到打开库设置
  3. 在那里我在列表中找到了 socialauth-cmd-utility-1.1.jar
  4. 我选择了它并单击右侧的 -(减号)图标将其删除。

哇!它像宝石一样工作!!!

于 2013-06-26T06:43:27.203 回答