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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:30:03+00:00 2026-06-17T01:30:03+00:00

I have a Java class which I’m using to instantiate multiple objects for use

  • 0

I have a Java class which I’m using to instantiate multiple objects for use in test cases.
In my spring configuration for invoking this class I have something like the following:

<bean id="myClass" class="com.foo.MyClass">
   <constructor-arg ref="myBean" />
</bean>

<bean id="myBeanA" factory-bean="myClass" factory-method="getA" />
<bean id="myBeanB" factory-bean="myClass" factory-method="getB" />
<bean id="myBeanC" factory-bean="myClass" factory-method="getC" />

MyClass does not extend anything.
My issue is that calling methods MyClass.getA() and MyClass.getB() works but MyClass.getC() does not and always throws a BeanCreationException: No factory method found getC()

None of the methods are static and all of them are public. Debugging through Spring jars I can see that when the bean for MyClass.getC() is created it doesn’t pick up the method when it does getLeafMethods(), but will find methods getA() and getB() and Object methods but none of the other methods in the class. Has anyone encountered a issue like this before or know why its unable to find all the methods in the class?

I cannot post the actual code but here is simpler version of it:

public class MyClass {
        private A a;
        private int i;
        public MyClass(D param) {
           //initialize here
        }

        public A getA() {
            return a;
        }

        public B getB() {
            return new B(i++);
        }

        //I could invoke this in a static way
        //however the same issue occurs either way.
        public C getC() {
            return new C();
        }
}
  • 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-06-17T01:30:05+00:00Added an answer on June 17, 2026 at 1:30 am

    It seems there were 2 issues for me, one was a build issue which was cleared with blowing away and recreating my workspace. The second issue was in my case the type C was parametrized, and I needed to specify new C<T>(); instead of just new C();. I was using a static method inside of C ( C.makeC(Params...)) to instantiate the object which I think caused the error. So I guess it was a type erasure issue that caused this. Thanks for the all the help!

    -Niru

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

Sidebar

Related Questions

I'm using a java class which is written by someone else but I have
I have Java class configuration which is serializable. I want to create an instance
I have a JAVA class in which I have implemented parsing of XML using
I have written a Spring MVC application which displays report of Test cases and
I have a Java JUnit 4 test and a generic class which creates a
My Question is: I have a test.java class which is the main class. There
I have a Java class which handles both single valued and multi-valued data. Therefore,
If I have a java class which is package-private (declared with class, not public
I'm new to learning JSPs and Servlets. I have a Java class which calls
I have a simple Java class in which I invoke a call to a

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.