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 6596875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:08:03+00:00 2026-05-25T18:08:03+00:00

I am writing a very simple tutorial about Spring (3.0.x) for my fellow developers

  • 0

I am writing a very simple tutorial about Spring (3.0.x) for my fellow developers and have encountered a weird behaviour: bean of type java.util.Locale is not autowired into other bean and there is no error message. But still, the other bean gets created ok, just the field is null.

To the details:

  • Configuration is purely XML based.
  • Bean definitions are as follows:

    <bean id="spanishLocale" class="java.util.Locale">
        <constructor-arg value="es"/>
        <constructor-arg value="ES"/>
    </bean>
    
    <bean id="dateTimeBeanSetter" class="com.bsl.training.theclock.SimpleDateTimeBean3" autowire="byType"/>
    
  • No autowire customisation has been used.

  • Class:

package com.bsl.training.theclock;

import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;


public class SimpleDateTimeBean3 {
    private Locale locale;

    public SimpleDateTimeBean3() {

    }

    public void setLocale(final Locale loc) {
        locale = loc;
    }

    public Locale getLocale() {
        return locale;
    }

    public String getDateTime() {
        DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, locale);
        return df.format(new Date());
    }   
}
  • If I add a field to the SimpleDateTimeBean3 class, which type is one of my own classes and such bean exists, everything works perfectly.
  • No errors are printed, both beans (spanishLocale, dateTimeBeanSetter) are created and accessible from ApplicationContext, but calling getDateTime() on the ‘dateTimeBeanSetter’ bean gives a NPE.

Any ideas?

Thanks 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-25T18:08:03+00:00Added an answer on May 25, 2026 at 6:08 pm

    Two key documentation fragments:

    From reference manual section 3.4.5.1:

    You cannot autowire so-called simple properties such as primitives, Strings, and Classes (and arrays of such simple properties). This limitation is by-design

    And from org.springframework.beans.BeanUtils#isSimpleProperty() javadoc:

    Check if the given type represents a “simple” property: a primitive, a String or other CharSequence, a Number, a Date, a URI, a URL, a Locale, a Class, or a corresponding array.Check if the given type represents a “simple” property: a primitive, a String or other CharSequence, a Number, a Date, a URI, a URL, a Locale, a Class, or a corresponding array.

    So, Working As Designed.

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

Sidebar

Related Questions

I'm writing a very simple text editor and have run into a somewhat minor
I am writing a very simple RMI server, and I am seeing intermittent java.rmi.NoSuchObjectExceptions
Writing a test app to emulate PIO lines, I have a very simple Python/Tk
I am writing an app that’s a very simple web service client. I have
I have followed a tutorial to create a simple blog writing application in PHP
I am testing a site written in Javascript, by writing (very simple) Java tests
I'm writing a very simple Java Game. Let me describe it briefly: There are
I have a very simple managed bean LOB which is used for reading existing
I'm writing a very simple flash app (AS 2) to sign users up to
I'm currently writing a very simple game engine for an assignment and to make

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.