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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:35:24+00:00 2026-05-25T00:35:24+00:00

I have a bean Config that has a required setter. However, when I don’t

  • 0

I have a bean Config that has a required setter. However, when I don’t set the setting in the bean config file I don’t get an exception regarding the missing attribute.

public class Config extends MatchSet{
   ...
   @Required
   public void setSections(List<Section> section){...}
}

public class OtherClass{
   ...
   @Required
   public void setMatchSets(List<MatchSet> sets){...}
}

public interface MatchSet{...}

If I don’t include the matchSets field of OtherClass I get a BeanInitializationException. But if I don’t set the sections field of Config I don’t get the exception. I am passing the instance of Config as one of the elements of the MatchSet list passed to OtherClass.

I have tried this using unit tests (SpringJUnit4ClassRunner) and using my main (ClassPathXmlApplicationContext) and the behavior is the same in either case.

Why is the @Required attribute not being checked for Config? Is it because it is being passed as a MatchSet?

Thanks

  • 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-25T00:35:24+00:00Added an answer on May 25, 2026 at 12:35 am

    Turns out this was caused by a different issue. I did not have the getter/setter set up correctly. Primarily, this was because I had tried to set up method chaining and so was not returning null from the setter. Also, I was accepting a List in the setting but returning an ImmutableList from the getter. The combination was causing Spring to not recognize the setter and therefore not check

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

Sidebar

Related Questions

I have a bean foo which has a setter and a couple of @Autowired
I have a JSF ManagedBean which has a property that should be set by
I have this Spring config: <bean id=boo class=com.x.TheClass/> The class TheClass implements TheInterface .
I have a bean of type string[] which has two or more values. I
I have a Spring/Hibernate webapp that has some integration tests that run on an
My app-config.xml has a definition for my UserDao bean: <bean id=userDao class=com.blah.core.db.hibernate.UserDaoImpl> <property name=sessionFactory
I have a simple Spring config for unit tests that includes ActiveMQ embedded broker,
I have an excel file that contain columns of data, my target is to
I have been having a problem that has troubled me for a while. Searching
I have spring Java config object that loads my properties but does not override

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.