我正在尝试在部署战争时加载Spring批处理作业上下文文件。
我已经添加了contextConfigLocation,但是没有工作.Even在pom.xml中添加了spring-web但是当我将我的war应用程序部署到tomcat spring时仍未初始化。请帮助我,因为我已经提到了大部分SO和spring论坛答案,我不想使用调度程序servlet,因为这不是现在的Web应用程序。它只是一个批处理作业,但将来它将是一个批处理作业+ Web应用程序,那时我将有一个调度程序servlet 。请告诉我如何在服务器启动时加载spring。
我的git存储库,其中包含完整代码 https://github.com/sumateja/patternfinder https://github.com/sumateja/patternfinder.git
tomcat日志
Dec 25, 2015 12:20:59 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.7.0_45\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Java\jdk1.7.0_45\bin;C:\Development\apache-maven-3.1.1\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\MySQL\MySQL Enterprise Backup 3.12\;C:\Program Files\Git\cmd;C:\Ruby21-x64\bin;C:\Users\Tejas\AppData\Local\Programs\Python\Python35-32\Scripts\;C:\Users\Tejas\AppData\Local\Programs\Python\Python35-32\;C:\Users\Tejas\AppData\Local\Programs\Python\Launcher\;C:\Users\Tejas\AppData\Roaming\npm;C:\Program Files\Git\bin;.
Dec 25, 2015 12:20:59 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:patternfinder' did not find a matching property.
Dec 25, 2015 12:20:59 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-9090"]
Dec 25, 2015 12:20:59 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-9009"]
Dec 25, 2015 12:20:59 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 548 ms
Dec 25, 2015 12:20:59 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Dec 25, 2015 12:20:59 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
Dec 25, 2015 12:20:59 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-9090"]
Dec 25, 2015 12:20:59 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-9009"]
Dec 25, 2015 12:20:59 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 547 ms
的web.xml
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:equity-eod-job.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
答案 0 :(得分:1)
我在你的机器上克隆了你的项目。我做了&#34; mvn clean package&#34;。当我要将war文件从目标文件夹复制到tomcat webapps文件夹时,我注意到你将它打包为jar而不是war 。 :)
更改你的pom.xml,从jar到war的包装价值:
<modelVersion>4.0.0</modelVersion>
<groupId>patternfinder</groupId>
<artifactId>patternfinder</artifactId>
<packaging>war</packaging> <!-- This line from jar to war-->
<version>1.0</version>
<name>patternfinder</name>
在此之后:
现在您可以看到您的应用程序将开始加载。似乎有一个错误的文件路径,在日志中你可以发现FileNotFoundException发生。我希望你能解决这个问题。
答案 1 :(得分:-1)
是的,最后这个问题得到了解决。似乎我的web.xml没有被选中,因为openshift已将web.xml放在webapps文件夹中。在将WEB-INF文件夹复制到WebContent后,将该文件夹删除。当我们将在openshift中创建的项目下载到我们的工作区时, web.xml存在于webapps文件夹中。谢谢你的帮助。