简体   繁体   English

在Windows上运行的Tomcat7

[英]Tomcat7 running on windows

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. 我在磁盘上安装了一个装有Tomcat7的文件夹,该文件夹用于在从eclipse运行它的Web应用程序上进行一些测试,并且运行良好。 When I try to deploy the application on a stand alone tomcat server it gives an error: (I'm using windows) 当我尝试在独立的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)

and the line 27 is in this context: 第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()) {

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. 我猜想是关于URL的,但是问题是我在Eclipse的tomcat实例上运行它没有任何问题。 Thank you 谢谢

File.list() will return null if File represents a non-existent directory. 如果File表示不存在的目录,则File.list()将返回null This null will then cause your for loop to throw a null-pointer exception. 然后,此null将导致您的for循环引发null指针异常。

You need to make your code defensive, and check that the directory exists using the methods on File before you attempt to read it. 您需要使代码具有防御性,并在尝试读取目录之前使用File上的方法检查该目录是否存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM