简体   繁体   English

尝试通过URL访问tomcat中的xml文件,出现404错误

[英]Trying to access xml file in tomcat via URL, getting 404 error

I have a webapp deployed in Tomee+ 1.6.0 (tomcat 7.0). 我在Tomee + 1.6.0(tomcat 7.0)中部署了一个Webapp。 The app runs fine and I can access all pages. 该应用程序运行正常,我可以访问所有页面。 Within one of my app's folders (myapp/intructions/) I have placed a xml file that I will access via a client application. 在我的应用程序的一个文件夹(myapp / intructions /)中,我放置了一个xml文件,可以通过客户端应用程序访问该文件。

The application will access the file for its configuration, and will be called via a batch file with the following command: 该应用程序将访问该文件进行配置,并使用以下命令通过批处理文件调用该应用程序:

"C:\Java\jre7\bin\java" -cp MyApp.jar com.me.MyApplicationStart "argument1" "argument2"

Within MyApplicationStart the constructor tries to access the configuration from the URL 在MyApplicationStart中,构造函数尝试从URL访问配置。

http://webserver:8080/myapp/instruction/myconfig.xml

As I have no control over the above methodology, this cannot be changed. 由于我无法控制上述方法,因此无法更改。

I would expect the xml to be downloaded (or fetched) and my application to work fine, but instead I get a 404 error. 我希望可以下载(或提取)该xml,并且我的应用程序可以正常工作,但是却收到404错误。 If I change the extension of my config file to .properties, everything works fine, but someone else other than me in the team insists that we use xml for the config file, since it will allow more automation features. 如果我将配置文件的扩展名更改为.properties,则一切正常,但是团队中除我以外的其他人坚持认为我们将xml用于配置文件,因为它将允许更多自动化功能。

What gets me is why can't I access this xml (or any other) file from tomcat. 让我明白的是为什么我无法从tomcat访问此xml(或任何其他文件)。 It seems that in previous versions of tomcat this was not a problem, or at least not with files outside the WEB-INF folder. 似乎在先前版本的tomcat中这不是问题,或者至少对于WEB-INF文件夹之外的文件不是问题。 Now it is and it seems to be exclusive to xml files, which suggests that there's a configuration in place that prevents access to this extension from anywhere in the webapp. 现在,它似乎是xml文件所独有的,这表明存在适当的配置,阻止从Web应用程序中的任何位置访问此扩展名。

Would anybody know what this configuration is, or what is the mechanics behind this error? 有人会知道这个配置是什么,或者这个错误背后的机制是什么?

Thanks in advance. 提前致谢。

for security reason, WEB-INF folder is not accessible from client side. 出于安全原因,无法从客户端访问WEB-INF文件夹。

put your xml file in other location. 将您的xml文件放在其他位置。

and try again, It will work 然后再试一次,它将起作用

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

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