部署 WAR 时为空指针
我在 /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>
问题是,每当我执行“shstartup.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)
我尝试在给出的方法中插入打印语句(来源不明),但是,它不会进入那里。还有什么可能出问题吗? WAR 文件已正确解压。
编辑: 嗨,问题已解决。问题是上下文路径和应用程序库以及主属性文件中给出的路径不完全相同。因此,某些事情不断出错。谢谢。对于log4j,属性是在属性文件中定义的。
I have 3 WAR files in /home/local/deploy/eclipse/webapps. They were generated using Ant build files. Now, I want to deploy them using Tomcat , from the command line. The relevant snippet from my server.xml looks like the following :
<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>
The problem is that whenever I do "sh startup.sh" , I get a null pointer exception , like the following :
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)
I tried to insert print statements in the method that gives an (Unknown Source), but , its not going in there. What else could be going wrong ? The WAR files are unpacked and correctly so .
EDIT: Hi , the problem got solved. The issue was that the context path and the app base and the path given in the main properties file were not exactly same. Due to that, something or the other kept going wrong. Thanks. About log4j, the properties were defined in the properties file .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在指定位置找不到 log4j 配置文件。
查看您的相关源代码,无法解析网址或(相对?)文件名。
提示:
启动远程调试会话(对于 Eclipse 来说不太困难)并使调试器在 NPE 异常时停止。然后您应该能够读取实际的文件名,并能够将丢失的文件复制/部署到正确的位置。
The log4j configuration file can't be found at the specified location.
Have a look at your relevant source code, the url or (relative?) filename can't be resolved.
Hint:
start a remote debugging session (not too difficult with eclipse) and make the debugger stop on NPE exceptions. Then you should be able to read the actual filename and be able to copy/deploy the mising file to the correct location.
log4j properties/xml 中指定的日志文件/目录不存在。
The log file/directory specified in log4j properties/xml does not exist.
所有例外均来自 org.apache.log4j.PropertyConfigurator,这意味着您的应用程序已准备好加载,并且 log4j 的配置可能是错误/丢失的。
请参阅您的 web.xml 以获取配置 od 侦听器
All excpetions come from
org.apache.log4j.PropertyConfigurator
this means your app is allready loading and have prooably bad/missing config for log4jSee your web.xml for config od listener