.MissingResourceException: Can't find bundle for base name

java, maven, resourcebundle

Solution

When using Maven, properties files should be located inside src/main/resources not in src/main/java (see here)

So, for instance, if you have the following definition in your faces-config.xml (for using the msgs variable in your facelet pages) :

    <resource-bundle>
        <base-name>i18n.PanneauPrincipal</base-name>
        <var>msgs</var>
    </resource-bundle>

Or if you load the resource files programmatically :

    ResourceBundle bundle = ResourceBundle.getBundle("i18n.PanneauPrincipal", locale);

Then the PanneauPrincipal_en.properties file should be located in the following directory :

    src/main/resources/i18n

Problem

I'm using library called jnca to capture netflow udp packets sent from a router. When it's imported in to a new project in IntellijIDea it works. Bet when that is used inside a maven project it doesn't work and gives this exception. Exception: ``` java.util.MissingResourceException: Can't find bundle for base name org.wso2.event.adaptor.udp.jnca.etc.NetFlow, locale en_US at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1499) at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1322) at java.util.ResourceBundle.getBundle(ResourceBundle.java:795) at org.wso2.event.adaptor.udp.jnca.cai.utils.Resources.<init>(Resources.java:24) at org.wso2.event.adaptor.udp.jnca.cai.flow.collector.Collector.<clinit>(Collector.java:51) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:190) at org.wso2.event.adaptor.udp.jnca.cai.flow.collector.Run.<clinit>(Run.java:14) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:190) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:113) NetFlow.properties: Can't find bundle for base name org.wso2.event.adaptor.udp.jnca.etc.NetFlow, locale en_US ``` There is no package naming issues. Problem is with this code segment ``` try { resources = ResourceBundle.getBundle("org.wso2.event.adaptor.udp.jnca.etc." + myName, Locale .getDefault()); } catch (MissingResourceException exc) { exc.printStackTrace(); error(SuperString.exceptionMsg(exc.toString())); } ``` myName = Netflow I have tried changing the path to the resource but it didn't work. And tried to include that netflow.properties file inside the maven project's resources folder it also didn't work How to fix this Thank you

Original source

Related problems