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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:03:41+00:00 2026-05-27T06:03:41+00:00

Some strange behavior from Spring 3.0 here. package com.service.schedule; import org.springframework.stereotype.Component; @Component(outroJob) public class

  • 0

Some strange behavior from Spring 3.0 here.

package com.service.schedule;

import org.springframework.stereotype.Component;

@Component("outroJob")
public class OutroJob {

    public void printMe() {
        System.out.println("running...");
    }

}

and

package com.service.schedule;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Component;

@Component("testeAutowired")
public class TesteAutowired {

    @Autowired
    public TesteAutowired(OutroJob outroJob) {
        outroJob.printMe();
    }

    public static void main(String[] args) {
        ClassPathResource res = new ClassPathResource("applicationContext.xml");
        XmlBeanFactory ctx = new XmlBeanFactory(res);

        OutroJob outroJob = (OutroJob) ctx.getBean("outroJob");
        outroJob.printMe(); // gives: running...

        ctx.getBean("testeAutowired");
    }
}

None of these beans are declared on applicationContext.xml

So, line outroJob.printMe(); works fine… prints “running…”

But when I try to get the “testeAutowired” bean, it says:

Could not instantiate bean class
[com.service.schedule.TesteAutowired]: No default constructor found;
nested exception is java.lang.NoSuchMethodException:
com.service.schedule.TesteAutowired.

The question is: why, if Spring found the “outroJob” bean it doesn’t autowired it on the TesteAutowired constructor ?

It seems obvious what it has to do…

  • 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-27T06:03:42+00:00Added an answer on May 27, 2026 at 6:03 am

    Try using ApplicationContext instead of XmlBeanFactory. XmlBeanFactory doesn’t postprocess annotations ie doesn’t use AutowiredAnnotationBeanPostProcessor which would explain the behaviour you’re experiencing.

    Here’s some more explanation

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

Sidebar

Related Questions

I'm experiencing some strange behavior for which I can't find any documented knowledge. Here's
I am using jQuery Accordion here and find some strange behavior when opening a
I am getting some strange behavior from list view. I need to change background
I'm getting some strange behavior from a listview/the getChildAt method. I have a HashSet,
I have some new strange Eclipse behavior from yesterday. When I want to run
I found some rather strange behavior... Here is how to replicate the problem: Create
I'm implementing drag & drop from a ListBox, but I'm seeing some strange behaviour
I'm witnessing some strange behavior with SharePoint when changing user's Active Directory passwords. I
I just found some strange behavior of database's order by clause. In string comparison,
So I am seemingly encountering some strange behavior when using NSString 's -sizeWithFont family

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.