I am running a third party application that calls my class whenever a new record is inserted in a database. My classname is in a property file that this third party program is using. So this program is calling my class using reflection.
My class needs to access a SpringComponent called titleService. I can get the bean the following away.
ApplicationContext ctx = SpringContext.getApplicationContext();
Object titleServiceObject = ctx.getBean("titleService");
This works fine, but I have to use reflection to call the method I want since it is an Object and not a concrete class.
I have tried to cast it to a TitleService object but I get the error:
org.springframework.beans.factory.BeanNotOfRequiredTypeException:
Bean named 'titleService' is expected to be of type 'com.title.TitleService' but was actually of type 'com.title.TitleService'
I don't understand the error message since the class name for what is expected is the same as what it actually is.
I have also tried getting the bean this way:
TitleService titleService = ctx.getBean(TitleService.class)
but I get the same error.
The TitleService object has several autowired components so I cannot use "new" to create this object.
How can I get a TitleObject object?