[英]java ResourceBundle.getBundle() undeterministic
I have a very, very strange situation happening on our Java EE app running on WebSphere. 在WebSphere上运行的Java EE应用程序上发生了非常非常奇怪的情况。
EAR
--someJar.jar
----config/propfile.properties
--WAR
----WEB-INF
------classes
--------config/propfile.properties
When the application start up, ResourceBundle.getBundle("config/propfile.properties") seems to read someProperty from the WAR/WEB-INF/classes/config/propfile.properties. 当应用程序启动时,ResourceBundle.getBundle(“ config / propfile.properties”)似乎从WAR / WEB-INF / classes / config / propfile.properties中读取了一些属性。
However, after the app is up and running, ResourceBundle.getBundle("config/propfile.properties") seems to read someProperty from someJar.jar/config/propfile.properties instead. 但是,在应用程序启动并运行后,ResourceBundle.getBundle(“ config / propfile.properties”)似乎从someJar.jar / config / propfile.properties中读取了someProperty。
I think that's how it's happening is because we have different values for someProperty on each file, and we got some error (due to the incorrect value from the someJar.jar/config/propfile.properties). 我认为这是由于每个文件的someProperty值不同而导致的(由于someJar.jar / config / propfile.properties中的值不正确)导致错误。 According to Java EE spec, WEB-INF/classes should get loaded first before anything else? 根据Java EE规范,应该先加载WEB-INF / classs,然后再进行其他操作?
Is it even possible? 可能吗? We could not replicate the problem in any of our lower environments. 我们无法在任何较低环境中复制该问题。
The WAR/META-INF/MANIFEST.MF
is ... Class-Path: lib/begin...lib/end someJar.jar
WAR/META-INF/MANIFEST.MF
是... Class-Path: lib/begin...lib/end someJar.jar
If the second call to ResourceBundle.getBundle("config/propfile.properties")
is from a class in the ejb module, it would no have access to WAR/WEB-INF/classes/config/propfile.properties
. 如果第二次调用ResourceBundle.getBundle("config/propfile.properties")
来自ejb模块中的类,则它将无权访问WAR/WEB-INF/classes/config/propfile.properties
。 This is because each module has a different class loader. 这是因为每个模块都有一个不同的类加载器。
Download the ee spec at the following link (or the corresponding spec for your javaee standard). 通过以下链接下载ee规范(或您的javaee标准的相应规范)。
http://download.oracle.com/otndocs/jcp/javaee-6.0-fr-eval-oth-JSpec/ http://download.oracle.com/otndocs/jcp/javaee-6.0-fr-eval-oth-JSpec/
In this version the relevant section is EE.8.3 在此版本中,相关部分为EE.8.3
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.