【问题标题】:java.lang.LinkageError: loader constraint violation; when resolving interface method (in service class)java.lang.LinkageError:加载程序约束违规;解析接口方法时(在服务类中)
【发布时间】:2016-08-10 06:48:23
【问题描述】:

我的项目结构就像是三个包,即 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依赖有关,那么调试这个问题的方法是什么。

【问题讨论】:

    标签: jakarta-ee jax-rs karaf linkageerror


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2013-08-18
      • 2013-09-01
      • 2014-09-30
      • 2018-01-14
      • 2011-12-23
      • 1970-01-01
      • 2013-11-20
      • 1970-01-01
      相关资源
      最近更新 更多