It looks like it is looking for it in the root of either the machine or
CATALINA_HOME. Resolve the path correctly and you'll probably find your
problem. You didn't provide the path so the loader assumes the root.

Robert S. Harper
Senior Engineer
Information Access Technology, Inc.
1100 East 6600 South, Suite 300
Salt Lake City Utah USA 84121-7411
(801)265-8800 Ext. 255 
FAX (801)265-8880
 

This e-mail is intended only for the addressee and may contain confidential
and/or privileged information. Any review, retransmission, or action taken
upon this information by persons other than the intended recipient is
prohibited by law. If you received this communication in error, please
contact us immediately at 801-265-8800. Although this e-mail and any
attachments are believed to be free of any virus or other defect, it is the
responsibility of the recipient to ensure that anything received or opened
is virus free. No responsibility is accepted by IAT for any loss or damage
in the event that such a virus or defect exists.

-----Original Message-----
From: James Dekker [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 16, 2007 3:33 PM
To: Tomcat Users List
Subject: Configurable Errors

Hello there,

I am creating a configurable errors file which gets loaded as a
properties file from an init servlet:

import java.io.IOException;
import java.util.Properties;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

public class ErrorInitServlet extends HttpServlet {

        static Properties errorProps = new Properties();

        public void init() throws ServletException {
            Properties props = new Properties();
            try {
 
props.load(this.getClass().getClassLoader().getResourceAsStream(
                        "/error.properties"));
            }
            catch (IOException e) {
                e.printStackTrace();
            }
        }

       public static Properties getErrorProperties() {
                return errorProps;
        }
}

The error.properties file looks like this:

error.required.field=Required %s
error.invalid.entry=Invalid %s
error.unknown.entry=Unknown %s

I created an ActionErrors.java file:

package org.coffeebreak.wrapper;

import java.util.Formatter;
import java.util.ResourceBundle;

/**
 * @author jdekker
 */
public class ActionError {

    private final ResourceBundle m_resource;

    public ActionError() {
         m_resource = ResourceBundle.getBundle("error.properties");
    }

    public String getMessage(String id, Object... parameters) {
        String value = m_resource.getString(id);
        if (null != value) {
            StringBuilder builder = new StringBuilder();
            Formatter f = new Formatter(builder);
            f.format(value, parameters);
            f.flush();
            return builder.toString();
        }
        return value;
    }
}

I had my ant build script move the error.properties to:
TOMCAT_HOME/WEB-INF/classes/org/coffeebreak/wrapper/

Now, when I invoke this class, through a client, this is the error that I
get:

INFO: Deploying web application archive coffeebreak.war
2007-01-16 13:55:41,753 WARN
[org.coffeebreak.model.AttributeBeanXmlConfigHelper] - commons
digester rules location:
file:/C:/DevTools/tomcat/jakarta-tomcat-5.5.9/webapps/coffeebreak/WEB-INF/cl
asses/org/coffeebreak/model/attribute-rules.xml
2007-01-16 13:55:42,128 WARN
[org.coffeebreak.config.XmlConfigInitServlet] - Finished parsing the
attribute XML config file.
2007-01-16 13:55:42,128 WARN
[org.coffeebreak.config.LoadErrorProperties] - Loaded error.properties
file.
2007-01-16 13:56:16,421 ERROR
[org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/coffeebreak
].[CoffeebreakAppServlet]]
- Servlet.service() for servlet CoffeebreakAppServlet threw exception
java.util.MissingResourceException: Can't find bundle for base name
/error.properties, locale en_US
        at
java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:8
36)
        at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:805)
        at java.util.ResourceBundle.getBundle(ResourceBundle.java:549)
        at org.coffeebreak.wrapper.ActionError.<init>(ActionError.java:21)
        at
org.coffeebreak.views.EditUserPane.validateFields(EditUserPane.java:159)
        at
org.coffeebreak.views.EditUserPane.processSave(EditUserPane.java:148)
        at
org.coffeebreak.views.EditUserPane.actionPerformed(EditUserPane.java:141)

Why is ActionError having trouble finding the error.properties file?
Is there a way to use my InitServlet's getter to set the resource
bundle? Am I going about this the wrong way?

Sincerely,

James

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to