Question

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.

JNCA

Bet when that is used inside a maven project it doesn't work and gives this exception.

jnca

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

Was it helpful?

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

OTHER TIPS

Copy your .properties files to the resources folder in the root (not inside packages) And then in your code when you want to access these .properties files don't mention any package name. just only the name of the .properties files in enough. like this:

 resources = ResourceBundle.getBundle(myName, Locale.getDefault());
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top