1

我的项目结构就像有三个包,即 Rest(其中放置了 Rest API 及其实现类)、Service API(其中定义了服务接口)和 Service Impl(其中放置了 Service API 的实现)。我的代码PersonalInfoServiceImpl只是将PersonalInfoRequestBean值设置为PersonalInfoResponseBean(+几个属性)对象并返回PersonalInfoResponseBean. 它工作正常。但是在与更多的拦截器集成之后,现在我突然开始在这段代码中收到以下错误:

Caused by java.lang.LinkageError: loader constraint violation: when resolving 
interface method "personal.info.service.api.PersonalInfoService.getPersonalInfoDetails(Lcom//personal/info/model/PersonalInfoRequestBean;)Lpersonal/info/model/PersonalInfoResponseBean;" 
the class loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) 
of the current class, personal/info/rest/impl/PersonalInfoRESTServiceImpl, 
and the class loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) 
for the method's defining class, personal/info/service/api/PersonalInfoService, 
have different Class objects for the type personal/info/model/PersonalInfoRequestBean 
used in the signature at personal.info.rest.impl.PersonalInfoRESTServiceImpl.getPersonalInfoDetail(PersonalInfoRESTServiceImpl.java:112)

有人可以帮我解决这个问题吗?我们正在使用 Apache karaf 来部署我们的服务。因此,如果它与 karaf/delpoyment/maven 依赖项有关,那么调试此问题的方法是什么。

4

1 回答 1

1

此错误消息意味着,您有 2 个personal/info/model/PersonalInfoRequestBean具有不同类加载器的加载类。这些类加载器之一加载接口PersonalInfoService和其他加载实现PersonalInfoRESTServiceImpl。你应该避免这种情况,你的类personal/info/model/PersonalInfoRequestBean应该只由加载接口的类加载器定义。

于 2016-08-12T09:27:22.450 回答