aspose file tools*
The moose likes JSF and the fly likes messages.properties file location Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "messages.properties file location" Watch "messages.properties file location" New topic
Author

messages.properties file location

sonia pandit
Ranch Hand

Joined: Apr 19, 2008
Posts: 137
Hi,

I put this file under a package mypackage in the source directory and in my jsp
I have:

<f:loadBundle basename="mypackage.messages" var="msg" />

But I am getting an error that says resource bundle cannot be found on classpath.
What is the problem here?

Thanks,

Sonia
Teena George
Ranch Hand

Joined: May 01, 2008
Posts: 82
Where is your mypackage located? always give the full path like mypackage/messages.properties. Its a '/' which separates the path hierarchy and not a '.'

Regards,
Teena
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

The message is correct, although the idea might seem surprising. Properties files and bundles are intended to be placed in the same directories as your java classes, which means that they can be found on the app's classpath. Treat them exactly like you would treat your classes, which means refer to them using fully qualified "classnames".

For examples, let's say I have an "appResources.properties" file and I want to put it in "WEB-INF/classes/com/mousetech/myapp/resources", since WEB-INF/classes is a fundamental part of any WAR's classpath. The fully qualified resource name would then be "com.mousetech.myapp.resources.appResources.properties".


Customer surveys are for companies who didn't pay proper attention to begin with.
Teena George
Ranch Hand

Joined: May 01, 2008
Posts: 82

Thanks Tim. You are right. I never created a resources file in the source packages. I copied all my properties files under a folder in WebContent and accessed it using the '/'. Yes, we can access it using the fully qualified name of the resource file, when the resource files are under one of the source packages, or even under WebContent. Thanks once again, it was a new piece of information.

Regards,
Teena
sonia pandit
Ranch Hand

Joined: Apr 19, 2008
Posts: 137
So if I understood you correctly, build/classes is also on the classpath. So I tried copying my messages.properties to this directory and to the mypackage directory underneath build/classes and
eclipse still complains that it cant find it?

Thanks,

Sonia
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

Eclipse is not a web application server. You can install a web application service debugging and control interface into Eclipse, but Eclipse itself doesn't participate. Therefore the build classpath isn't sufficient.

A J2EE web application server needs a WAR, either as a WAR file or the unzipped (exploded) equivalent. The classpath for that WAR is the WEB-INF/classes and the jars in the WEB-INF/lib directory of that WAR. Additional system classpath elements come from the web application server and not from Eclipse.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: messages.properties file location