Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Missing Resource Exception

4 views
Skip to first unread message

Ivan Redi at

unread,
Feb 22, 2005, 5:38:19 AM2/22/05
to
hello,

i've got this exception. does anybody knows how to solve this, or what is
wrong?

java.util.MissingResourceException: Can't find bundle for base name
connection, locale de_AT
at
java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:804)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:773)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:511)
at server.ANDIServer.<init>(ANDIServer.java:54)
at server.ANDIServer.main(ANDIServer.java:89)
Exception in thread "main"

the code mentioned in the exception looks like this:

//Initialize global variables
54:>>> String driver =
ResourceBundle.getBundle("connection").getString("driver");
String url = ResourceBundle.getBundle("connection").getString("url");
String username =
ResourceBundle.getBundle("connection").getString("username");
String password =
ResourceBundle.getBundle("connection").getString("password");
tempPath = ResourceBundle.getBundle("common").getString("tmpdir");

and

public static void main(String[] args) {
89:>>> new ANDIServer(args);
}

thank you in advance
ivan


Rhino

unread,
Feb 22, 2005, 9:10:25 AM2/22/05
to

"Ivan Redi" <ivan.redi ( at ) ortlos . com> wrote in message
news:421b0d19$0$10578$3b21...@aconews.univie.ac.at...
Ivan,

The error message you are seeing indicates that the resource bundle you
requested, connection_de_AT, couldn't be found at runtime. As a result, your
getString("driver") couldn't be executed to determine the Austrian German
version of the driver name. If this is a List ResourceBundle, that means
that the program was looking for a file named connection_de_AT.java; if it
was a Text or Message ResourceBundle, it was looking for a file named
connection_de_AT.properties. I don't recall precisely where the program will
look for these files but I assume it is the same as the classpath. Either
your ResourceBundle doesn't exist at all or it isn't anywhere that the
program can find it.

I'm guessing that you are new to I18N (Internationalization). The reason I
say that is that the normal approach in I18N programs is to get the
ResourceBundle *once*, then do as many getString() operations as necessary
against the ResourceBundle reference.

If you are new to I18N, you should have a look at the Internationalization
trail in the Java Tutorial, which you can see at
http://java.sun.com/docs/books/tutorial/i18n/index.html. I used the
information in that trail to construct my own successful I18N code.

The "Quick Example" topic -
http://java.sun.com/docs/books/tutorial/i18n/intro/quick.html - will give
you a good overview of the process that you need to follow; the rest of the
trail goes into the details.

Rhino


Ivan Redi

unread,
Feb 23, 2005, 6:31:48 AM2/23/05
to
rhino,

i copy-pasted connection.properties to connection_de_AT.properties into
class path, but still doesnt work. i just get a new error message: Error :

java.util.MissingResourceException: Can't find bundle for base name

connection_de_AT, locale de_AT.
so i am thinking something else is wrong with this: ResourceBundle myRes
= ResourceBundle.getBundle("connection_de_AT");
String driver = myRes.getString("driver");
btw. i dont want internationalization. i would like to use one properties
file for all locals.

best
ivan


"Rhino" <rhi...@NOSPAM.sympatico.ca> schrieb im Newsbeitrag
news:j3HSd.19372$Am3.5...@news20.bellglobal.com...

Rhino

unread,
Feb 23, 2005, 2:48:35 PM2/23/05
to

"Ivan Redi" <ivan@'*remove*ortlos.com> wrote in message
news:421c68a6$0$8024$3b21...@aconews.univie.ac.at...

> rhino,
>
> i copy-pasted connection.properties to connection_de_AT.properties into
> class path, but still doesnt work. i just get a new error message: Error :
> java.util.MissingResourceException: Can't find bundle for base name
> connection_de_AT, locale de_AT.
> so i am thinking something else is wrong with this: ResourceBundle
myRes
> = ResourceBundle.getBundle("connection_de_AT");
> String driver = myRes.getString("driver");

You never hard-code the _de_AT in the getBundle() method. As the tutorial I
cited shows, you pass the leading part of the file name in one argument and
the Locale in the second part. Something like this:

Locale myLocale = new Locale("de", "AT);
try {
ResourceBundle myBundle = ResourceBundle.getBundle("connection",
myLocale);
} catch (MissingResourceException mr_excp) {
//error handling
}

Then, get the individual values you need, like this:

String myDriver = myBundle.getString("driver");
String myUserid = myBundle.getString("userid");

> btw. i dont want internationalization. i would like to use one properties
> file for all locals.
>

I don't understand. That seems to be a contradiction in terms: if you have
'locals', which presumably means an input value that differs from one Locale
to another, you *are* doing internationalization whether you think of it
that way or not.

If you want all users of the program to get the same value for 'driver',
'userid', etc. then you don't need Locales at all. In that case, you don't
need ResourceBundles either; you should simply be able to set up a single
properties file and access it with the Properties classes, particularly the
getProperty() method. Alternatively, you could use the Preferences API to
save these values to a BackingStore like the Windows Registry.

Rhino

Ivan Redi

unread,
Feb 24, 2005, 7:26:32 AM2/24/05
to
thank you rhino,

i now solved this by making the code like this:
String driver =
ResourceBundle.getBundle("com.common.connection").getString("driver");
i dont't know why this didn't work since i had: import com.common.*;
no reason why this worked on linux machine without problems and on windows
was a class problem.
but through your answers i've learnd also many new things.

best
ivan

"Rhino" <rhi...@NOSPAM.sympatico.ca> schrieb im Newsbeitrag

news:d65Td.14587$uO.5...@news20.bellglobal.com...

Rhino

unread,
Feb 24, 2005, 9:01:41 AM2/24/05
to
Ivan,

Changing getBundle("connection") to getBundle("com.common.connection") makes
sense; the getBundle() method needs the full name of the package that
contains the ResourceBundle class or properties file.

I'm glad you solved your problem.

Rhino

"Ivan Redi" <ivan@'*remove*ortlos.com> wrote in message

news:421dc6f9$0$12126$3b21...@aconews.univie.ac.at...

0 new messages