我在/ home / local / deploy / eclipse / webapps中有3个WAR文件。它们是使用Ant构建文件生成的。现在,我想从命令行使用Tomcat部署它们。我的server.xml中的相关代码段如下所示:
<Host appBase="/home/local/deploy/eclipse/webapps" autoDeploy="true" name="localhost" unpackWARs="true">
<Context docBase="/home/local/deploy/eclipse/webapps/VechileTracking"
Path="/V" reloadable="true"
source="org.eclipse.jst.jee.server:VechileTracking"/>
<Context docBase="/home/local/deploy/eclipse/webapps/RE"
Path="/RouteEngine" reloadable="true"
source="org.eclipse.jst.jee.server:RouteEngine"/>
<Context docBase="/home/local/deploy/eclipse/webapps/Main"
Path="/GHyd" reloadable="true"
source="org.eclipse.jst.jee.server:Main"/>
</Host>
问题在于每当我执行“sh startup.sh”时,我都会得到一个空指针异常,如下所示:
INFO: Deploying web application archive VechileTracking.war
- java.lang.NullPointerException
at java.io.FileInputStream.<init>(FileInputStream.java:116)
at java.io.FileInputStream.<init>(FileInputStream.java:79)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:306)
at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:324)
at com.stw.server.infrastructure.ApplicationContextListener.contextInitialized(Unknown Source)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Feb 8, 2012 1:13:58 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive RE.war
-
java.lang.NullPointerException
at java.io.FileInputStream.<init>(FileInputStream.java:116)
at java.io.FileInputStream.<init>(FileInputStream.java:79)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:306)
at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:324)
at com.stw.routeengine.infrastructure.ApplicationContextListener.contextInitialized(Unknown Source)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Feb 8, 2012 1:14:00 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive Main.war
- java.lang.NullPointerException
at java.io.FileInputStream.<init>(FileInputStream.java:116)
at java.io.FileInputStream.<init>(FileInputStream.java:79)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:306)
at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:324)
at com.stw.server.infrastructure.ApplicationContextListener.contextInitialized(Unknown Source)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
我试图在给出(未知来源)的方法中插入print语句,但是,它不在那里。还有什么可能出错? WAR文件已解压缩且正确无误。
编辑: 嗨,问题解决了。问题是上下文路径和应用程序库以及主属性文件中给出的路径不完全相同。由于这个原因,某些事情或其他事情一直出错。谢谢。关于log4j,属性在属性文件中定义。
答案 0 :(得分:0)
在指定位置找不到log4j配置文件。
查看相关的源代码,无法解析url或(相对?)文件名。
提示:
启动远程调试会话(使用eclipse不太困难)并使调试器停止在NPE异常上。然后,您应该能够读取实际的文件名,并能够将mising文件复制/部署到正确的位置。
答案 1 :(得分:0)
log4j properties / xml中指定的日志文件/目录不存在。
答案 2 :(得分:0)
所有异常都来自org.apache.log4j.PropertyConfigurator
这意味着您的应用已经加载并且可能已经错误/缺少log4j的配置
请参阅web.xml以获取配置od侦听器
com.stw.server.infrastructure.ApplicationContextListener