Beans are not available from HandlerValidator

Viewed 23

The beans A, B are not redefined in this chain (null value). I need these beans for processing. In other class, everything is OK (the beans are defined in the configuration with the @Bean annotation). Tell me, please, is it possible to add something like embedding to xml? How is this possible to implement? What solutions can there be? Thank you in advance.

public class HandlerValidator implements SOAPHandler<SOAPMessageContext> {
    
        @Autowired
        A a;
    
        @Autowired
        B b;
    
        @Override
        public Set<QName> getHeaders() {
            return null;
        }
    
        @Override
        public boolean handleMessage(SOAPMessageContext context) {        
            return true;
        }
    
        @Override
        public boolean handleFault(SOAPMessageContext context) {
            return false;
        }
    
        @Override
        public void close(MessageContext context) {
    
        }
    }

and xml:

<?xml version="1.0" encoding="UTF-8"?>
<handler-chains xmlns="http://java.sun.com/xml/ns/javaee"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/javaee_web_services_metadata_handler_2_0.xsd">
    <handler-chain>
        <handler>
            <handler-class>/.../.validator.HandlerValidator</handler-class>
        </handler>
    </handler-chain>
</handler-chains>
1 Answers

The problem is HandlerValidator is not being scanned by spring for autowiring to happen, try to define this handler validator as bean by adding annnotations like @component so that autowiring happens or define this handler validator as spring bean too .

Related