使用AWS Elastic Beanstalk和EC2在Tomcat7下找不到文件

时间:2012-06-24 22:44:24

标签: eclipse unix amazon-ec2 amazon-web-services tomcat7

我使用Eclipse在使用UNIX 64位环境的AWS Elastic Beanstalk上部署我的Java Web应用程序。我的应用程序需要从同一个项目文件夹中读取文件。但是,在运行项目后,管理控制台中的日志显示无法找到该目录。我试图通过使用相对路径或绝对路径来解决这个问题。但都没有奏效。

一个令人厌烦的事情是我在ec2实例中找不到Tomcat文件夹。有没有人知道如何在应用程序中设置我的文件路径,或者我应该将文件放在哪里以便找到它?

谢谢!

1 个答案:

答案 0 :(得分:0)

I'm not certain what you're doing with your file, but I had the same problem finding a path to an image to use in a class. I hope this helps!

Preface: I'm deploying my .war to my elastic beanstalk instance via the AWS-Elastic Beanstalk console. I moved my image into the exact same package/folder as the class I'm referencing it in.

BufferedImage imBuff = ImageIO.read(MyAwesomeFooBarClass.class.getResourceAsStream("foobar.png"));

And that's it! I'm sure this isn't the most elegant solution, but it certainly works/I'm a bit crunched for time ;)