开发者

How can I access <tomcat>\bin\*.properties when running from inside eclipse?

Does anyone know if Tomcat running inside of Eclipse truly uses the <tomcat>\bin\ directory when you've configured your server to use your local Tomcat install (Server view) inside Eclipse?

For example: I'm using a colleagues jar, which subsequently requires the X.properties file. I've been instructed to place that properties file in the <tomcat>\bin\ directory. This is sort of odd to me, but the line that fails is simply:

InputStream in = new FileInputStream("X.properties");

Anyhow, I'm pretty sure editing any of the Server config files will not help me, though I'm open to any suggestions. Or perhaps there's something in my launch configuration (below) that I can change?

How can I access <tomcat>\bin\*.properties when running from inside eclipse?

No matter what, I get the following stack trace:

java.io.FileNotFoundException: X.properties (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:106)
    at java.io.FileInputStream.<init>(FileInputStream.java:66)
    at com.mycompany.myteam.colleaguesproject.colleaguesservlet.init(colleaguesservlet.java:93)
    at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:开发者_如何学C966)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4230)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:448)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)

Any help is greatly appreciated! :-)


Java designates the directory that you started it from as its 'working directory', and any relative paths are relative to that directory. In this case, that's Tomcat's bin directory, which contains Tomcat's startup script.

You should put the properties file in C:\apache-tomcat-5.5.25\bin to make this work, though this is not a good practice for java properties files. Reading them in off of Java's classpath is standard, and much more flexible.


I totally agree with mblinn !

Eclipse creates a local instance of tomcat server, for which eclipse.exe is the Main application.

Try placing your X.properties file in eclipse root folder.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜