該應用程序使用Spring Framework,它需要一個名爲config.path的環境變量,可以在名爲web.xml的文件中進行配置。它看起來像這樣:使用Spring Framework部署.war文件時出錯
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<!-- *** Opcional, si no se quiere arrancar la aplicación con ninguna JAVA_OPT *** -->
<!-- context-param>
<param-name>config.path</param-name>
<param-value>ruta_absoluta_carpeta_ficheros_configuracion</param-value>
</context-param-->
<listener>
<listener-class>es.mpt.dsic.inside.ws.configuration.ConfigLoaderListener</listener-class>
</listener>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>file:${config.path}/log4j.properties</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:es/mpt/dsic/inside/context/inside-ws-context.xml,
/WEB-INF/mvc-dispatcher-servlet.xml,
classpath:es/mpt/dsic/inside/context/inside-security-context.xml,
classpath:es/mpt/dsic/inside/context/inside-context.xml
</param-value>
</context-param>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/ws/*</url-pattern>
</servlet-mapping>
<!-- Spring MVC -->
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Spring encoding obligando a utf-8 -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Firma Trifasica -->
<servlet>
<description>Servicio de firma electronica en 3 fases v2.1</description>
<servlet-name>SignatureService</servlet-name>
<servlet-class>es.gob.afirma.triphase.server.SignatureService</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SignatureService</servlet-name>
<url-pattern>/SignatureService</url-pattern>
</servlet-mapping>
,我把它像這樣:
<context-param>
<param-name>config.path</param-name>
<param-value>/var/lib/tomcat8/webapps/aplicacion/resources/config</param-value>
</context-param>
彌問題是,如果我讓評論那些線條和嘗試部署的應用程序,我得到這個錯誤在catalina.out:
INFORMACIÓN: Despliegue del archivo /var/lib/tomcat8/webapps/inside.war de la aplicación web abr 25, 2017 1:51:12 PM org.apache.jasper.servlet.TldScanner scanJars INFORMACIÓN: Al menos un JAR, que se ha explorado buscando TLDs, aún no contenía TLDs. Activar historial de depuración para este historiador para una completa lista de los JARs que fueron explorados y de los que nos se halló TLDs. Saltarse JARs no necesarios durante la exploración puede dar lugar a una mejora de tiempo significativa en el arranque y compilación de JSP . DEBUG: setDebug: JavaMail version 1.4ea 13:51:16,880 ERROR ContextLoader:308 - Context initialization failed java.lang.IllegalArgumentException: Could not resolve placeholder 'config.path' at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:173) at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:125) at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:151) at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:142) at org.springframework.core.env.AbstractEnvironment.resolveRequiredPlaceholders(AbstractEnvironment.java:440) at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:188) at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:149) at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:126) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:263) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:203) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:617) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:446) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:939) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1812) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) abr 25, 2017 1:51:16 PM org.apache.catalina.core.StandardContext startInternal GRAVE: One or more listeners failed to start. Full details will be found in the appropriate container log file abr 25, 2017 1:51:16 PM org.apache.catalina.core.StandardContext startInternal GRAVE: Falló en arranque del Contexto [/inside] debido a errores previos 13:51:16,938 WARN XmlWebApplicationContext:1028 - Exception thrown from ApplicationListener handling ContextClosedEvent java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date [Tue Apr 25 13:51:12 CEST 2017]; root of context hierarchy at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:337) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:324) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1025) at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:988) at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:556) at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:142) at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4859) at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5478) 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:725) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:939) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1812) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) 13:51:16,939 WARN XmlWebApplicationContext:1036 - Exception thrown from LifecycleProcessor on context close java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Tue Apr 25 13:51:12 CEST 2017]; root of context hierarchy at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:350) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1033) at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:988) at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:556) at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:142) at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4859) at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5478) 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:725) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:939) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1812) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) abr 25, 2017 1:51:17 PM org.apache.catalina.startup.HostConfig deployWAR INFORMACIÓN: Deployment of web application archive /var/lib/tomcat8/webapps/inside.war has finished in 8.323 ms
但是如果行沒有被評論,tomcat會NT啓動和catalina.out中表明這一點:
abr 25, 2017 12:10:08 PM org.apache.jasper.servlet.TldScanner scanJars INFORMACIÓN: Al menos un JAR, que se ha explorado buscando TLDs, aún no contenía TLDs. Activar historial de depuración para este historiador para una completa lista de los JARs que fueron explorados y de los que nos se halló TLDs. Saltarse JARs no necesarios durante la exploración puede dar lugar a una mejora de tiempo significativa en el arranque y compilación de JSP . DEBUG: setDebug: JavaMail version 1.4ea
我知道這是對的配置,但我不知道如何着手
注: 決不會的.war文件,所以我是個有點失落的工作。我使用tomcat8。
我們不知道如何進行,因爲你沒有指定你真正想要的。你的應用依賴於一個配置值,如果它沒有定義,你會得到一個異常。這不是預期的嗎? – eis
我想知道爲什麼當我配置這些行時它沒有部署應用程序,tomcat在部署時會「卡住」。 順便說一下,該應用程序不是我的,我下載了應用程序以在我們的網絡中實現它。 –
它沒有部署,因爲它依賴於這些值來進行配置。 – eis