简体   繁体   English

java ResourceBundle.getBundle()不明确

[英]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.

相关问题 Java ResourceBundle.getBundle缺少资源异常 - Java ResourceBundle.getBundle missing resource exception ResourceBundle.getBundle和Websphere - ResourceBundle.getBundle and Websphere Java ResourceBundle.getBundle如何加载属性文件? - How does Java ResourceBundle.getBundle load properties file? 如何忽略ResourceBundle.getBundle中的defaultLocale? - How to ignore defaultLocale in ResourceBundle.getBundle? Java 1.5,Java EE 5,WAS 6.1:使用ResourceBundle.getBundle(…)加载资源束的异常 - Java 1.5, Java EE 5, WAS 6.1: Exception loading a resource bundle with ResourceBundle.getBundle(…) getbundle(basename)ResourceBundle java - getbundle(basename) ResourceBundle java ResourceBundle.getBundle(class,locale)没有获得默认捆绑 - ResourceBundle.getBundle(class,locale) don't get default Bundle 为什么ResourceBundle.getBundle(String,Locale)忽略了Locale? - Why is ResourceBundle.getBundle(String, Locale) ignoring the Locale? 在Android应用程序中使用ResourceBundle.getBundle()的正确方法是什么? - What is the proper way to use ResourceBundle.getBundle() in an Android application? 无法使用 ResourceBundle.getBundle() 加载 ResourceBundle 找不到基本名称的包,区域设置 en_US - Unable to load ResourceBundle with ResourceBundle.getBundle() Can't find bundle for base name , locale en_US
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM