Grails:run-app,run-war工作正常。但是无法在tomcat7上运行war文件。得到错误“一个或多个听众未能启动”

时间:2016-05-09 04:23:51

标签: tomcat grails

我正在使用Grails 2.1.5,JDK 1.7来构建 当我使用“run-app”命令运行我的grails项目时,它运行正常。 当我使用“run-war”命令时它也运行正常(我假设它使用tomcat作为服务器来运行)。 当我使用“grails dev war”命令创建war文件并尝试在我的本地tomcat中部署时,它会失败。 我在Catalina.log中获得了以下日志

"SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file"

在tomcat7.stdout.log中,我收到以下错误

2016-05-06 15:50:22,810 [http-bio-8099-exec-4] WARN  

lifecycle.ShutdownOperations  - Error occurred running shutdown operation: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
    at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:172)
    at org.springframework.context.support.AbstractApplicationContext.containsBean(AbstractApplicationContext.java:1121)
    at org.codehaus.groovy.grails.web.context.GrailsContextLoader$1.run(GrailsContextLoader.java:89)
    at org.codehaus.groovy.grails.lifecycle.ShutdownOperations.runOperations(ShutdownOperations.java:61)
    at org.codehaus.groovy.grails.web.context.GrailsContextLoader.closeWebApplicationContext(GrailsContextLoader.java:137)
    at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:142)
    at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:5115)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5779)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:224)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:159)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1092)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:560)
    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1779)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(Unknown Source)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(Unknown Source)
    at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1506)
    at org.apache.catalina.manager.HTMLManagerServlet.upload(HTMLManagerServlet.java:285)
    at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:205)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:136)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)

以下是web.xml代码

    <web-app xmlns="http://java.sun.com/xml/ns/javaee" metadata-complete="true" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <display-name>/mileiq-development-2.1</display-name>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <context-param>
        <param-name>webAppRootKey</param-name>
        <param-value>mileiq-development-2.1</param-value>
    </context-param>
    <context-param>
        <param-name>sample</param-name>
        <param-value>Sample Value</param-value>
    </context-param>
    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    <filter>
        <filter-name>sitemesh</filter-name>
        <filter-class>org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter</filter-class>
    </filter>
    <filter>
        <filter-name>AssetPipelineFilter</filter-name>
        <filter-class>asset.pipeline.AssetPipelineFilter</filter-class>
    </filter>
    <filter>
        <filter-name>charEncodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        <init-param>
            <param-name>targetBeanName</param-name>
            <param-value>characterEncodingFilter</param-value>
        </init-param>
        <init-param>
            <param-name>targetFilterLifecycle</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter>
        <filter-name>urlMapping</filter-name>
        <filter-class>org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter</filter-class>
    </filter>
    <filter>
        <filter-name>hiddenHttpMethod</filter-name>
        <filter-class>org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter</filter-class>
    </filter>
    <filter>
        <filter-name>grailsWebRequest</filter-name>
        <filter-class>org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>charEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>hiddenHttpMethod</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>REQUEST</dispatcher>
    </filter-mapping>
    <filter-mapping>
        <filter-name>AssetPipelineFilter</filter-name>
        <url-pattern>/assets/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
    </filter-mapping>
    <filter-mapping>
        <filter-name>grailsWebRequest</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>ERROR</dispatcher>
    </filter-mapping>
    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>ERROR</dispatcher>
        <dispatcher>REQUEST</dispatcher>
    </filter-mapping>
    <filter-mapping>
        <filter-name>sitemesh</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>ERROR</dispatcher>
    </filter-mapping>
    <filter-mapping>
        <filter-name>urlMapping</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>REQUEST</dispatcher>
    </filter-mapping>
    <listener>
        <listener-class>org.codehaus.groovy.grails.plugins.log4j.web.util.Log4jConfigListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>H2Console</servlet-name>
        <servlet-class>org.h2.server.web.WebServlet</servlet-class>
        <init-param>
            <param-name>-webAllowOthers</param-name>
            <param-value>true</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>H2Console</servlet-name>
        <url-pattern>/dbconsole/*</url-pattern>
    </servlet-mapping>
    <servlet>
        <servlet-name>grails</servlet-name>
        <servlet-class>org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>gsp</servlet-name>
        <servlet-class>org.codehaus.groovy.grails.web.pages.GroovyPagesServlet</servlet-class>
        <init-param>
            <description>Allows developers to view the intermediate source code, when they pass a showSource argument in the URL.</description>
            <param-name>showSource</param-name>
            <param-value>1</param-value>
        </init-param>
    </servlet>
    <servlet>
        <servlet-name>grails-errorhandler</servlet-name>
        <servlet-class>org.codehaus.groovy.grails.web.servlet.ErrorHandlingServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>gsp</servlet-name>
        <url-pattern>*.gsp</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>grails-errorhandler</servlet-name>
        <url-pattern>/grails-errorhandler</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>grails</servlet-name>
        <url-pattern>*.dispatch</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>index.gsp</welcome-file>
    </welcome-file-list>
    <error-page>
        <error-code>404</error-code>
        <location>/grails-errorhandler</location>
    </error-page>
    <error-page>
        <error-code>500</error-code>
        <location>/grails-errorhandler</location>
    </error-page>
    <jsp-config>
        <taglib>
            <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
            <taglib-location>/WEB-INF/tld/c.tld</taglib-location>
        </taglib>
        <taglib>
            <taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
            <taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
        </taglib>
        <taglib>
            <taglib-uri>http://www.springframework.org/tags</taglib-uri>
            <taglib-location>/WEB-INF/tld/spring.tld</taglib-location>
        </taglib>
        <taglib>
            <taglib-uri>http://grails.codehaus.org/tags</taglib-uri>
            <taglib-location>/WEB-INF/tld/grails.tld</taglib-location>
        </taglib>
    </jsp-config>
</web-app>

以下是ApplicationContext.xml条目。

    <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">


    <bean id="grailsApplication" class="org.codehaus.groovy.grails.commons.GrailsApplicationFactoryBean">
        <description>Grails application factory bean</description>
        <property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
        <property name="grailsResourceLoader" ref="grailsResourceLoader" />
    </bean>

    <bean id="pluginManager" class="org.codehaus.groovy.grails.plugins.GrailsPluginManagerFactoryBean">
        <description>A bean that manages Grails plugins</description>
        <property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
        <property name="application" ref="grailsApplication" />
    </bean>

    <bean id="grailsConfigurator" class="org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator">
        <constructor-arg>
            <ref bean="grailsApplication" />
        </constructor-arg>
        <property name="pluginManager" ref="pluginManager" />
    </bean>

    <bean id="grailsResourceLoader" class="org.codehaus.groovy.grails.commons.GrailsResourceLoaderFactoryBean" />

    <bean id="characterEncodingFilter" class="org.springframework.web.filter.CharacterEncodingFilter">
        <property name="encoding">
            <value>utf-8</value>
        </property>
    </bean>
</beans>

以下是我的buildconfig.groovy中的内容

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.target.level = 1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"

grails.project.dependency.resolution = {
    // inherit Grails' default dependencies
    inherits("global") {
        // uncomment to disable ehcache
        // excludes 'ehcache'
    }
    log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
    checksums true // Whether to verify checksums on resolve

    repositories {
        inherits true // Whether to inherit repository definitions from plugins
        grailsPlugins()
        grailsHome()
        grailsCentral()
        mavenCentral()

        grailsRepo "http://repo.grails.org/grails/webapp"
        mavenRepo "http://repo.grails.org/grails/plugins"

        mavenRepo "http://www.hibernatespatial.org/repository"
        mavenRepo "http://datanucleus.org/downloads/maven2/"

        // uncomment these to enable remote dependency resolution from public Maven repositories
        //mavenCentral()
        //mavenLocal()
        //mavenRepo "http://snapshots.repository.codehaus.org"
        //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 eg.

        // MixPanel
//      compile ":mixpanel:1.0"
//      compile ":mixpanel:1.4"
//        compile 'com.mixpanel:mixpanel-java:1.1.4'

        compile 'com.stripe:stripe-java:1.5.1'

//        compile 'net.sf.opencsv:opencsv:2.3'
        compile "org.grails.plugins:plugin-config:0.1.5"        // there is also a 0.2.0 version
        runtime "org.postgresql:postgresql:9.3-1102-jdbc4"
        compile "org.grails.plugins:postgresql-extensions:3.2.0"
//        compile "org.grails.plugins:hibernate-spatial:0.0.4"
//        compile "org.grails.plugins:hibernate-spatial-postgresql:0.0.4"

        // TODO: determine if this is just needed for MONGO
        compile "com.google.code.gson:gson:2.2.4"

        compile ('org.hibernatespatial:hibernate-spatial-postgis:1.1.1') {
            exclude 'org.hibernate:hibernate-core:3.6.0.Final'
        }
        compile 'com.vividsolutions:jts:1.13'
        compile 'org.postgis:postgis-jdbc:2.1.0'

        compile "org.mockito:mockito-all:1.8.4"

        // TODO: determine if these 5 plugins are needed for anything other than MONGO
        compile 'org.springframework:spring-tx:3.1.2.RELEASE'   //: configuration not found in org.springframework#spring-tx;3.1.2.RELEASE'         //: 'master'. It was required from org.springframework.data#spring-data-mongodb;1.1.0.RELEASE compile
        compile 'org.springframework:spring-context:3.1.2.RELEASE'  //: configuration not found in org.springframework#spring-context;3.1.2.RELEASE'        //: 'master'. It was required from org.springframework.data#spring-data-mongodb;1.1.0.RELEASE compile
        compile 'org.springframework:spring-beans:3.1.2.RELEASE'    //: configuration not found in org.springframework#spring-beans;3.1.2.RELEASE'          //: 'master'. It was required from org.springframework.data#spring-data-mongodb;1.1.0.RELEASE compile
        compile 'org.springframework:spring-core:3.1.2.RELEASE'     //: configuration not found in org.springframework#spring-core;3.1.2.RELEASE'               //: 'master'. It was required from org.springframework.data#spring-data-mongodb;1.1.0.RELEASE compile
        compile 'org.springframework:spring-expression:3.1.2.RELEASE'   //: configuration not found in org.springframework#spring-expression;3.1.2.RELEASE' //: 'master'. It was required from org.springframework.data#spring-data-mongodb;1.1.0.RELEASE compile

        // Twilio
        compile "com.twilio.sdk:twilio-java-sdk:3.4.5"

        //aws dependency
        build 'org.apache.httpcomponents:httpcore:4.2'
        build 'org.apache.httpcomponents:httpclient:4.2'
        runtime 'org.apache.httpcomponents:httpcore:4.2'
        runtime 'org.apache.httpcomponents:httpclient:4.2'
        runtime 'commons-codec:commons-codec:1.10'
        runtime 'com.fasterxml.uuid:java-uuid-generator:3.1.3'

        // zendesk JWT support
        compile 'com.nimbusds:nimbus-jose-jwt:3.10'
    }

    plugins {
        runtime ":hibernate:$grailsVersion"

        compile ":platform-core:1.0.0"

        // Asset pipeline
        compile ":asset-pipeline:1.8.7"
        compile(":coffee-asset-pipeline:1.7.0") {
            exclude "asset-pipeline"
        }
        compile ":less-asset-pipeline:1.7.0"

        compile ":cache-headers:1.1.5"

        build ":tomcat:$grailsVersion"
        build(':release:2.2.0', ':rest-client-builder:1.0.3') {
            export = false
        }

        compile ":csv:0.3.1"

        compile ":webxml:1.4.1"

        // for login
        compile ":spring-security-core:1.2.7.3"

        //Heroku support
        compile ':database-session:1.2.1'
        compile (':heroku:1.0.1') {excludes 'database-session'}
        compile ':cloud-support:1.0.8'

//        compile ':mongodb:1.3.3'          //1.1.0.GA' - REMOVED MONGO FROM PROJECT

        compile ":quartz:1.0.1"

        compile ":executor:0.3"
        compile ":runtime-logging:0.4"

        compile ":spock:0.7"

        //aws support
        compile ':aws-sdk:1.9.22'

为了测试我的设置,我创建了一个示例grails app / war并且能够在我的tomcat中运行

我尝试在stackoverflow中搜索问题。 专家提到我会在某处获得另一个日志。但是我无法找到相同的。 请帮我解决这个问题。

0 个答案:

没有答案