Tomcat7在windows上运行
我的磁盘上安装了一个包含 Tomcat7 的文件夹,我用它对从 eclipse 运行它的 Web 应用程序进行一些测试,并且运行良好。当我尝试在独立的 tomcat 服务器上部署应用程序时,它给出了一个错误:(我使用的是 windows)
Fev 08, 2012 9:10:04 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet Process
java.lang.NullPointerException
at hs.server.CommandFactory.<init>(CommandFactory.java:27)
at hs.server.Process.init(Process.java:40)
并且第 27 行是在这个上下文中:
19-String pathname = "/"+packageName.replace(".", "/")+"/";
20 //String pathname = packageName.replace(".", "/");
21- URL resource = loader.getResource(pathname);
22- File commandDir = (new File(resource.getFile()));
23-
24- //File commandDir = new File(loader.getResource(packageName.replace(".", 25-"/")).getFile());
26-
27- for(String classFilepath: commandDir.list()) {
我猜是关于 URL 的一些内容,但问题是我正在运行它在eclipse上的tomcat实例上没有任何问题。谢谢
I have a folder with Tomcat7 installed on my disk that I use to do some tests on my web application running it from eclipse and it I works well. When I try to deploy the application on a stand alone tomcat server it gives an error: (I'm using windows)
Fev 08, 2012 9:10:04 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet Process
java.lang.NullPointerException
at hs.server.CommandFactory.<init>(CommandFactory.java:27)
at hs.server.Process.init(Process.java:40)
and the line 27 is in this context:
19-String pathname = "/"+packageName.replace(".", "/")+"/";
20 //String pathname = packageName.replace(".", "/");
21- URL resource = loader.getResource(pathname);
22- File commandDir = (new File(resource.getFile()));
23-
24- //File commandDir = new File(loader.getResource(packageName.replace(".", 25-"/")).getFile());
26-
27- for(String classFilepath: commandDir.list()) {
I guess is something about the URL but the problem is that I'm running it without any problems on the tomcat instance on eclipse. Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果
File
表示不存在的目录,File.list()
将返回null
。此null
将导致您的for
循环抛出空指针异常。您需要使代码具有防御性,并在尝试读取目录之前使用
File
上的方法检查该目录是否存在。File.list()
will returnnull
ifFile
represents a non-existent directory. Thisnull
will then cause yourfor
loop to throw a null-pointer exception.You need to make your code defensive, and check that the directory exists using the methods on
File
before you attempt to read it.