org.hibernate.proxy.ProxyConfiguration $ Interceptor является интерфейсом, и JAXB не может обрабатывать интерфейсы - PullRequest
0 голосов
/ 05 марта 2019

Я работаю над Spring5 Restful Api с JPA. Я столкнулся ниже с сообщением об ошибке для метода GET в контроллере. Я пытаюсь погуглить, но все равно не повезло.

com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
org.hibernate.proxy.ProxyConfiguration$Interceptor is an interface, and JAXB can't handle interfaces.
    this problem is related to the following location:
        at org.hibernate.proxy.ProxyConfiguration$Interceptor
        at private org.hibernate.proxy.ProxyConfiguration$Interceptor com.ocap.model.Merchant$HibernateProxy$D7xgB1fw.$$_hibernate_interceptor
        at com.ocap.model.Merchant$HibernateProxy$D7xgB1fw

Я попробовал некоторые решения, найденные в stackoverflow, например. положить аннотацию @XmlAccessorType (XmlAccessType.FIELD), но все еще сталкивается с той же ошибкой. Моя сущность выглядит так:

@Entity
@DynamicUpdate
@SelectBeforeUpdate
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Merchant extends CorporateEntity{
    @XmlElement(name = "mcc", required=true)
    private String mcc;
...} 

А сервис выглядит так:

public class MerchantService {
    private static final Logger logger = Logger.getLogger(MerchantService.class);
    @Autowired
    private MerchantRepository merchantRepository;

    public void setMerchantRepository(MerchantRepository merchantRepository) {
        this.merchantRepository = merchantRepository;
    }
    public Merchant getMerchant(String id) {
        Merchant merchant = merchantRepository.getOne(id);
        return merchant;
    }

} 

А конвертер сообщений выглядит так:

<!-- Configure to plugin XML as request and response in method handler -->
<beans:bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
    <beans:property name="messageConverters">
        <beans:list>
            <beans:ref bean="xmlMessageConverter"/>
        </beans:list>
    </beans:property>
</beans:bean>
<!-- Configure bean to convert XML to POJO and vice versa -->   
<beans:bean id="xmlMessageConverter" class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter">
</beans:bean>

Есть идеи, почему возникает эта ошибка? Очень признателен за помощь

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...