2015-08-25 2 views
0

Использование Grails 2.3.8 и плагин MongoDB 3.0.3. Моя база данных MongoDB размещена MongoLab. Когда я запускаю приложение на местном уровне, проблем нет.Grails MongoDB не может запустить приложение на Tomcat

Но, при создании файла WAR, а затем разместить его на сервере Tomcat, он дает мне следующую ошибку:

2015-08-25 18:50:19,604 [ContainerBackgroundProcessor[StandardEngine[PSA]]] 
ERROR context.ContextLoader - Context initialization failed 
org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'grailsApplication' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: 
Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/servlet/AsyncContext 
    at java.lang.Thread.run(Thread.java:701) 
Caused by: java.lang.NoClassDefFoundError: javax/servlet/AsyncContext 
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2575) 
    at java.lang.Class.getDeclaredMethods(Class.java:1857) 
    at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46) 
    at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33) 
    at java.lang.Class.forName(Class.java:274) 
    ... 1 more 
Caused by: java.lang.ClassNotFoundException: javax.servlet.AsyncContext 
    ... 6 more 
2015-08-25 18:50:19,607 [ContainerBackgroundProcessor[StandardEngine[PSA]]] 
ERROR context.GrailsContextLoader - Error initializing the application: 
Error creating bean with name 'grailsApplication' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: 
Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/servlet/AsyncContext 
org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'grailsApplication' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: 
Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/servlet/AsyncContext 
    at java.lang.Thread.run(Thread.java:701) 
Caused by: java.lang.NoClassDefFoundError: javax/servlet/AsyncContext 
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2575) 
    at java.lang.Class.getDeclaredMethods(Class.java:1857) 
    at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46) 
    at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33) 
    at java.lang.Class.forName(Class.java:274) 
    ... 1 more 
Caused by: java.lang.ClassNotFoundException: javax.servlet.AsyncContext 
    ... 6 more 
2015-08-25 18:50:19,608 [ContainerBackgroundProcessor[StandardEngine[PSA]]] 
ERROR context.GrailsContextLoader - Error initializing Grails: 
Error creating bean with name 'grailsApplication' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: 
Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/servlet/AsyncContext 
org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'grailsApplication' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: 
Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/servlet/AsyncContext 
    at java.lang.Thread.run(Thread.java:701) 
Caused by: java.lang.NoClassDefFoundError: javax/servlet/AsyncContext 
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2575) 
    at java.lang.Class.getDeclaredMethods(Class.java:1857) 
    at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46) 
    at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33) 
    at java.lang.Class.forName(Class.java:274) 
    ... 1 more 
Caused by: java.lang.ClassNotFoundException: javax.servlet.AsyncContext 
    ... 6 more Aug 25, 2015 6:50:19 PM 
org.apache.catalina.core.StandardContext listenerStart 
SEVERE: Exception sending context initialized event to listener instance of class org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener 
org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'grailsApplication' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: 
Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/servlet/AsyncContext 
    at java.lang.Thread.run(Thread.java:701) 
Caused by: java.lang.NoClassDefFoundError: javax/servlet/AsyncContext 
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2575) 
    at java.lang.Class.getDeclaredMethods(Class.java:1857) 
    at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46) 
    at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33) 
    at java.lang.Class.forName(Class.java:274) 
    ... 1 more 
Caused by: java.lang.ClassNotFoundException: javax.servlet.AsyncContext 
    ... 6 more 
Aug 25, 2015 6:50:19 PM org.apache.catalina.core.StandardContext start 
SEVERE: Error listenerStart 
Aug 25, 2015 6:50:19 PM org.apache.catalina.core.StandardContext start 
SEVERE: Context [/Sacramento] 
startup failed due to previous errors 
Aug 25, 2015 6:50:19 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap 
SEVERE: A web application created a ThreadLocal with key of type [org.codehaus.groovy.runtime.GroovyCategorySupport.MyThreadLocal] (value [[email protected]6f8786da]) and a value of type [null] (value [null]) but failed to remove it when the web application was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed. 
Aug 25, 2015 6:50:19 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap 
SEVERE: A web application created a ThreadLocal with key of type [org.springframework.core.NamedThreadLocal] (value [Prototype beans currently in creation]) and a value of type [null] (value [null]) but failed to remove it when the web application was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed. 
Aug 25, 2015 6:50:36 PM org.apache.catalina.core.ApplicationContext log 
INFO: Manager: list: Listing contexts for virtual host 'serialbetter.com' 

Это мой BuildConfig:

grails.servlet.version = "2.5" // Change depending on target container compliance (2.5 or 3.0) 
    grails.project.class.dir = "target/classes" 
    grails.project.test.class.dir = "target/test-classes" 
    grails.project.test.reports.dir = "target/test-reports" 
    grails.project.work.dir = "target/work" 
    grails.project.target.level = 1.6 
    grails.project.source.level = 1.6 
    //grails.project.war.file = "target/${appName}-${appVersion}.war" 

    grails.project.fork = [ 
     // Configure settings for compilation JVM, note that if you 
     // alter the Groovy version forked compilation is required. 
     // Compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true], 

     // Configure settings for the test-app JVM, uses the daemon by default 
     test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true], 

     // Configure settings for the run-app JVM 
     run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false], 

     // Configure settings for the run-war JVM 
     war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false], 

     // Configure settings for the Console UI JVM 
     console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256] 
    ] 

    grails.project.dependency.resolver = "maven" // or ivy 
    grails.project.dependency.resolution = { 

     // Inherit Grails' default dependencies 
     inherits("global") { 

     // Specify dependency exclusions here; for example, uncomment 
     // this to disable ehcache: 
     // 
     //  excludes 'ehcache' 
    } 

    log "error" // Log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose' 
    checksums true // Whether to verify checksums on resolve 
    legacyResolve false // Whether to do a secondary resolve on plugin installation, 
         // not advised and here for backwards compatibility 

    repositories { 
     inherits true // Whether to inherit repository definitions from plugins 

     grailsPlugins() 
     grailsHome() 
     mavenLocal() 
     grailsCentral() 
     mavenCentral() 

     // Uncomment these (or add new ones) to enable remote dependency 
     // resolution from public Maven repositories 
     // 
     //mavenRepo "http://repository.codehaus.org" 
     //mavenRepo "http://download.java.net/maven/2/" 
     //mavenRepo "http://repository.jboss.com/maven2/" 
    } 

    dependencies { 
     // Specify dependencies here under either 'build', 'compile', 'runtime', 
     // 'test' or 'provided' scopes e.g. 
     // 
     // runtime 'mysql:mysql-connector-java:5.1.27' 
     // runtime 'org.postgresql:postgresql:9.3-1100-jdbc41' 
    } 

    plugins { 
     // Plugins for the build system only 
     build ":tomcat:7.0.52.1" 

     // Plugins for the compile step 
     compile ":scaffolding:2.0.3" 

     //Compile ':cache:1.1.2' 
     compile ':mongodb:3.0.3' 
     compile ":webxml:1.4.1" 

     // Plugins needed at runtime but not for compilation 
     //runtime ":hibernate:3.6.10.13" // or ":hibernate4:4.3.5.1" 
     runtime ":database-migration:1.4.0" 
     runtime ":jquery:1.11.0.2" 
     runtime ":resources:1.2.7" 
     //runtime ":simple-blog:0.3.3" 

     // Uncomment these (or add new ones) to enable additional resources capabilities 
     // 
     //runtime ":zipped-resources:1.0.1" 
     //runtime ":cached-resources:1.1" 
     //runtime ":yui-minify-resources:0.1.5" 

     // An alternative to the default resources plugin is the asset-pipeline plugin 
     //compile ":asset-pipeline:1.6.1" 

     // Uncomment these to enable additional asset-pipeline capabilities 
     //compile ":sass-asset-pipeline:1.5.5" 
     //compile ":less-asset-pipeline:1.5.3" 
     //compile ":coffee-asset-pipeline:1.5.0" 
     //compile ":handlebars-asset-pipeline:1.3.0.1" 
    } 
} 

Это DataSource :

environments { 
    development { 
     grails { 
      mongo { 
       host = "ds059682.mongolab.com" 
       port = 59682 
       username = "xxx" 
       password="yyy" 
       databaseName = "sacramento" 
      } 
     } 
    } 
    test { 
     grails { 
      mongo { 
       host = "ds059682.mongolab.com" 
       port = 59682 
       username = "xxx" 
       password="yyy" 
       databaseName = "sacramento" 
      } 
     } 
    } 
    production { 
     grails { 
      mongo { 
       // based on: cloudbees:[email protected]:10044/456 
         host = "ds059682.mongolab.com" 
       port = 59682 
       username = "xxx" 
       password="yyy" 
       databaseName = "sacramento" 
      } 
     } 
    } 
} 

Как исправить эту проблему?

+1

можно дублировать http://stackoverflow.com/questions/10715363/classnotfoundexception-javax-servlet-asynccontext- in-jetty-hello-world-in-eclip – injecteer

+0

попробуйте изменить 'grails.servlet.version =" 2.5 "' на 'grails.servlet.version =" 3.0 "' – injecteer

ответ

0

Похоже, ваше приложение не работает, потому что ваш экземпляр Tomcat не содержит класс javax.servlet.AsyncContext, что приводит к:

java.lang.ClassNotFoundException: javax.servlet.AsyncContext

Этот класс вводится в Servlet 3.0, который является частью Java EE 6. Servlet 2.5 является частью Java   EE   5. Вам необходимо обновить до Tomcat 7, который является контейнером Servlet 3.0.

  • Tomcat 7.X содержит servelet 3.0
  • Tomcat 6.X содержит servelet 2,5
Смежные вопросы