The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

walrus (14) [Avatar] Offline
After following your instructions on pg. 46 (not using a Fragment at this time but just the file), I receive the following message . . .

java.util.MissingResourceException: Can't find bundle for base name fancyfoods.web.messages, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(
at java.util.ResourceBundle.getBundleImpl(
at java.util.ResourceBundle.getBundle(
at fancyfoods.web.SayHello.doGet(
. . .

Looks like it is looking for a message that is tagged (in some way) with en_US.
I see that the code asks for the locale from the browser, but I don't see where it get the message based on the locale.

Was something left out in the instructions?

holly.cummins (16) [Avatar] Offline
Re: Issue Under Fragments - Ch. 2
I'm sorry to hear you're hitting problems. I wonder whether what you're seeing is a build issue.

It should be that as long as you have a file called, your messages will be found. If you're in the en_US locale, the ResourceBundle will look first for a file called If it can't find that, it will look for, and if it can't find that either, it will look for So in principle, no matter what locale you're using, messages will be found.

The first thing I'd suggest checking is the contents of your fancyfoods.web bundle; you should have a file in the fancyfoods/web folder, called Depending how you're packaging up the bundle, the build tools could have left out the properties files. Certainly from your stack trace it looks like it can't find the default file.

The lines which triy to get the message from the file are these ones:

String bundleName = "fancyfoods.web.messages";
ResourceBundle resources = ResourceBundle.getBundle(bundleName, locale);
String greeting = resources.getString("SayHello.hello");

(Those bundles are normal Java resource bundles, not OSGi bundles, which does rather muddy things.)

Hope this helps,
holly.cummins (16) [Avatar] Offline
Re: Issue Under Fragments - Ch. 2
Hi again,

I've just done a bit more digging into this, and I think my diagnosis that a build problem is causing the file to be missing from your fancyfoods.web bundle is probably correct. However, the problem is our fault (if you're using the poms provided with the source download)! A mistake in where the file gets laid out in the source zip means it doesn't get included in the built jar. It should be in src/main/resources, but it's in src/main/java. I'll make sure that's fixed in the next refresh of the source zip.

Thanks for reporting the issue.

walrus (14) [Avatar] Offline
Re: Issue Under Fragments - Ch. 2
Thank you for checking into this further and updating.