我试图在部署war的时候加载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 msweb.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>Am trying to load spring batch job context file on deployment of war.
I have added contextConfigLocation as below but not working.Even added spring-web in pom.xml but still when i deploy my war application onto tomcat spring is not being initialized.Please help me since i have referred to most of SO and spring forums answers,i dont want to use dispatcher servlet since this is not a web application as of now .It is just a batch job but in future it will be a batch job + web application ,at that time i will have a dispatcher servlet .Please let me know how to load spring on server start up.
My git repository where full code is present https://github.com/sumateja/patternfinder https://github.com/sumateja/patternfinder.git
tomcat logs
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 msweb.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>最满意答案
我在你的机器上克隆了你的项目。 我做了“mvn clean package”。 当我准备将目标文件夹中的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>在此之后:
mvn清理软件包 将target / patternfinder-1.0.war复制到tomcat webapp文件夹 启动tomcat现在您可以看到您的应用程序将开始加载。 似乎有一个错误的文件路径,在日志中你可以发现FileNotFoundException发生。 我希望你能解决这个问题。
Yes finally this got solved . It seems that my web.xml was not being picked up ,since openshift had put the web.xml in webapps folder.Hence deleted this folder after copying WEB-INF folder to WebContent.When we download a project created in openshift into our workspace ,web.xml is present in webapps folder.Thanks prem for your help.
更多推荐
发布评论