1

I have been developing a Grails project in eclipse's STS and it runs fine when I run/debug it from there but when I open the same project in Intellij-Idea(v-12.1.4), it does not run giving me the exception whose trace is as:

"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

I have read many similar question on SO like: 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. Each of the suggest that there is some servlet-api.jar in the project build path which is causing the problems. But I have searched for it in my project but could not find the jar. I am using JDK-7. Any help would be highly appreciated!!!

EDIT The project runs perfectly well with the grails command line tool (Tools->Grails->Run-Target) but only fails with the run/debug icon.

Community
  • 1
  • 1
rahulserver
  • 10,411
  • 24
  • 90
  • 164

2 Answers2

2

Disable "Add --classpath" checkbox in your Grails Run Configuration to prevent adding "--classpath socialauth-*-*.jar" to command line. All external libraries will be loaded by Grails, "--classpath socialauth-*-*.jar" is not needed.

Manual removing socialauth-cmd-utility-1.1.jar is not a good idea because IntelliJ will add socialauth-cmd-utility-1.1.jar automatically in the next Synchronize Grails Settings.

Sergey
  • 841
  • 6
  • 7
0

Phew! I finally solved it!. Actually the following line in the stacktrace:

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

Points out about something pathogenic with the javax.servlet.ServletContext.getSessionCookieConfig() function. I scanned out the external libraries to find out such similar matching functions and realized that there are two such occurences:

  1. Under grails-2.2.1 there is a jar called servlet-api-2.4.jar
  2. There was another jar called socialauth-cmd-utility-1.1.jar

Actually the error was due to the second jar. So I removed it from the external libraries using the following steps:

  1. Right click on the socialauth-cmd-utility-1.1.jar
  2. Go to Open library settings
  3. There I found the socialauth-cmd-utility-1.1.jar in the list
  4. I selected it and clicked the -(minus) icon on the right to remove it.

And wow! It worked like a gem!!!

rahulserver
  • 10,411
  • 24
  • 90
  • 164