Can't find bundle for base name /Bundle, locale en_US

后端 未结 12 916
走了就别回头了
走了就别回头了 2020-12-05 09:22

I\'m using a library that has a dependency on JSF.

When I try to run my project, it show following exception massage..

java.util.MissingResourceExce         


        
相关标签:
12条回答
  • 2020-12-05 09:56

    I had the same problemo, and balus solution fixed it.

    For the record:

    WEB-INF\faces-config is

    <?xml version="1.0" encoding="UTF-8"?>
    <faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0">
        <application>
            <locale-config>
                <default-locale>en</default-locale>
            </locale-config>
            <message-bundle>
                Message
            </message-bundle>
        </application>
    </faces-config>
    

    And had Message.properties under WebContent\Resources (after mkyong's tutorial)

    the pesky exception appeared even when i renamed the bundle to "Message_en_us" and "Message_en". Moving it to src\ worked.

    Should someone post the missing piece to make bundles work under resources,it would be a beautiful thing.

    0 讨论(0)
  • 2020-12-05 09:59

    I use Eclipse (without Maven) so I place the .properties file in src folder that also contains the java source code, in order to have the .properties file in the classes folder after building the project. It works fine. Take a look at this post: https://www.mkyong.com/jsf2/cant-find-bundle-for-base-name-xxx-locale-en_us/

    Hope this help you.

    0 讨论(0)
  • 2020-12-05 09:59

    I was able to resolve the issue, the resource was in my project directories but when the junit utility tries to load it, it was returning an error of MissingResourceException. And the reason was the resource was in the not on the classpath of the test class package so when I added the cfg/ folder to my classpath path entry in eclipse and set the output directory in the build conf to the same class package the issue was resolved.

    When you try this approach just make sure, the classpath conf file shows the classpath entry of the resource directory (eg. cfg/)

    0 讨论(0)
  • 2020-12-05 10:00

    In maven, folder resources, create the same package structure where the configuration files are located and copy them there

    0 讨论(0)
  • 2020-12-05 10:03

    In my case I was dealing with SpringBoot project and I got the same exception.

    Solution is made by adding env.properties file into classpath (i.e. src/main/resource folder). What was making the issue is that in log4j configuration there was property like

    <Property name="basePath">${bundle:env:log.file.path}</Property>

    0 讨论(0)
  • 2020-12-05 10:03

    Make sure you didn't add the properties files in the wrong resources folder as there is one under 'Web Pages' and one under 'Other Sources/...'. They needed to be under 'Other Sources/...'.

    0 讨论(0)
提交回复
热议问题