Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3623838
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:25:58+00:00 2026-05-18T23:25:58+00:00

Framework: Spring, Hibernate. O/S: Windows I am trying to implement hibernate’s Custom message interpolator

  • 0

Framework: Spring, Hibernate. O/S: Windows

I am trying to implement hibernate’s Custom message interpolator following the direction of this Link.

When implementing the below class, it gives an error “Cannot make a static reference to the non-static type Locale”.

public class ClientLocaleThreadLocal<Locale> {
  private static ThreadLocal tLocal = new ThreadLocal();

  public static void set(Locale locale) {
    tLocal.set(locale);
  }

  public static Locale get() {
    return tLocal.get();
  }

  public static void remove() {
    tLocal.remove();
  } 

}

As I do not know generics enough, not sure how < Locale > is being used by TimeFilter class below and the purpose of definition in the above class.

public class TimerFilter implements Filter {
public void destroy() {
}

public void doFilter(ServletRequest req, ServletResponse res, FilterChain filterChain) throws IOException, ServletException {
    try {
        ClientLocaleThreadLocal.set(req.getLocale());       
        filterChain.doFilter(req, res);
    }finally {
        ClientLocaleThreadLocal.remove();
    }
}
public void init(FilterConfig arg0) throws ServletException {
}

}

Will doing the following be okay?

  1. Change static method/field in ClientLocaleThreadLocal to non-static method/fields

  2. In TimeFilter, set locale by instantiating new object as below.
    new ClientLocaleThreadLocal().set(req.getLocale())

Thanks for your help in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T23:25:59+00:00Added an answer on May 18, 2026 at 11:25 pm
    public class ClientLocaleThreadLocal<Locale>
    

    declares a generic class ClientLocaleThreadLocal with a type parameter called Locale. Since the ClientLocaleThreadLocal always contains a Locale, there is no need for a type parameter here.

    private static ThreadLocal tLocal = new ThreadLocal();
    

    A ThreadLocal in contrast is a generic type, and has as type parameter the type of object it holds. In your case, this is Locale. Your code should therefore read:

    public class ClientLocaleThreadLocal {
        private static ThreadLocal<Locale> tLocal = new ThreadLocal<Locale>();
    

    As for what a ThreadLocal is, read its Javadoc or google its name.

    Whether res.getLocale() is the “client locale” is something we can’t know, since “client locale” is a little vague.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using hibernate validator framework with Spring. A class implementing the Spring Validator validates
OS: Windows vista, Framework: Spring (latest), JQuery (latest), Hibernate (latest). I have a domain
I'm currently trying to get into the Java EE development with the Spring framework.
We are developing a web application using Spring framework and Hibernate ORM. As far
Is it possible put these three framework Spring, Struts 2.0 and Hibernate in single
I'm new in Spring Framework (2.5.6) and I have Hibernate integration problem on Glassfish
I have a web-application in java, spring framework, hibernate on tomcat, that has basically
Im working with the Spring Framework 3.0.5 and the Hibernate Framework and Im starting
Im working on a webapplication with Spring Framework 3 and Hibernate 3.6 and I
as it is stated at http://static.springsource.org/spring/docs/2.0.8/reference/orm.html The Spring Framework provides integration with Hibernate, JDO,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.