cancel
Showing results for 
Search instead for 
Did you mean: 

How to add dependency for flexiblesearchservice in a new extension?

Former Member
0 Kudos

Getting this error- Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'flexibleSearchService' of bean class [com.tisl.mpl.bin.daos.BinDao]: Bean property 'flexibleSearchService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

It seems that your class misses either a correct setter for that type or a correct annotation on the type; depending on the context.

But basically putting a @Autowired over the service declaration should solve the problem.

 public class MyClass {
   @Autowired
   private HybrisService hybrisService;
 
   public void myMethod() {
     // some stuff here
   }
 }

Answers (3)

Answers (3)

Former Member
0 Kudos

I reckon you are doing property injection. Hence it requires a public setter method in your java class file whose bean in which flexiblesearchservice property was used in spring.xml.

If you want to don't want to do property injection, simply remove the property in spring.xml and use @Resource or @Autowired annotations above your property declaration in your java class file, which have their own strategy of picking the right bean to be injected from the application context.

Former Member
0 Kudos

Did you add a setter method for it? I would assume from the exception that you have defined it as a bean property but are missing a public set method. Antoher possibility is that your DAO extends something else that has this dependecy but you have not configured this in your xml . You could add "parent" attribute to your bean definition and then you will get those dependencies.

Former Member
0 Kudos

It still did not work. Is it occuring because its a new extension? Do I need to add some dependencies? Can you please suggest?

Former Member
0 Kudos

Do you inject the flexibleSearchService with annotations, or via xml ? In the second case, the annotation won't help if you have a definition like that:

 <bean id="myClass" class="be.custom.MyClass">
   <property name="flexibleSearchService" ref="flexibleSearchService" />
 </bean>


In that case, you need then to update your class with a setter:

 public class MyClass {
   private FlexibleSearchService flexibleSearchService ;
 
   public void myMethod() {
     // some stuff here
   }
   public void setFlexibleSearchService(FlexibleSearchService flexibleSearchService) {
     this.flexibleSearchService = flexibleSearchService;
   }
  }