Missing Resource Exception

I

Ivan Redi

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
 
R

Rhino

Ivan Redi said:
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:8
04)
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
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
 
I

Ivan Redi

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 said:
Ivan Redi said:
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:8
04)
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
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
 
R

Rhino

Ivan Redi said:
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


Rhino said:
Ivan Redi said:
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:8
04)
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
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
 
I

Ivan Redi

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 said:
Ivan Redi said:
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


Rhino said:
"Ivan Redi" <ivan.redi ( at ) ortlos . com> wrote in message
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:8
04)
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

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
 
R

Rhino

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 said:
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 said:
Ivan Redi said:
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


Rhino said:
"Ivan Redi" <ivan.redi ( at ) ortlos . com> wrote in message
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:8
04)
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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top