web-dev-qa-db-ja.com

java.lang.LinkageError:ローダー制約違反:メソッド "org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executorを解決するとき

JSFWebアプリケーションはJava EEWebサービスからリソースを取得しようとします。JSFWebアプリは正常に機能します。Webサービスリソースを取得するためにHttpクライアントソースを追加したため、JBossインスタンスは次のように主張します。

15:29:47,689 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (http--0.0.0.0-443-1) Error Rendering View[/index.xhtml]: javax.el.ELException: /surfaceParts/sideBarLeft.xhtml @14,79 value="#{categories.cats}": Java.lang.LinkageError: loader constraint violation: when resolving method "org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor.<init>(Lorg/Apache/http/client/HttpClient;Lorg/Apache/http/protocol/HttpContext;)V" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, at/fhj/ase/ssl/SSLClientHelper, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for resolved class, org/jboss/resteasy/client/core/executors/ApacheHttpClient4Executor, have different Class objects for the type xecutors.ApacheHttpClient4Executor.<init>(Lorg/Apache/http/client/HttpClient;Lorg/Apache/http/protocol/HttpContext;)V used in the signature
    at com.Sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.Java:114) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.Java:194) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.Java:182) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at javax.faces.component.UIData.getValue(UIData.Java:731) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at javax.faces.component.UIData.getDataModel(UIData.Java:1798) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at javax.faces.component.UIData.setRowIndexWithoutRowStatePreserved(UIData.Java:484) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at javax.faces.component.UIData.setRowIndex(UIData.Java:473) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at com.Sun.faces.renderkit.html_basic.TableRenderer.encodeBegin(TableRenderer.Java:81) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.Java:820) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at javax.faces.component.UIData.encodeBegin(UIData.Java:1118) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.Java:1777) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at javax.faces.render.Renderer.encodeChildren(Renderer.Java:168) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.Java:845) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.Java:1779) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.Java:1782) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.Java:1782) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.Java:1782) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at com.Sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.Java:402) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at com.Sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.Java:125) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at com.Sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.Java:121) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at com.Sun.faces.lifecycle.Phase.doPhase(Phase.Java:101) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at com.Sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.Java:139) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at javax.faces.webapp.FacesServlet.service(FacesServlet.Java:594) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at org.Apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.Java:329) [jbossweb-7.0.13.Final.jar:]
    at org.Apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.Java:248) [jbossweb-7.0.13.Final.jar:]
    at org.Apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.Java:275) [jbossweb-7.0.13.Final.jar:]
    at org.Apache.catalina.core.StandardContextValve.invoke(StandardContextValve.Java:161) [jbossweb-7.0.13.Final.jar:]
    at org.Apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.Java:489) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.Java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.Apache.catalina.core.StandardHostValve.invoke(StandardHostValve.Java:155) [jbossweb-7.0.13.Final.jar:]
    at org.Apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.Java:102) [jbossweb-7.0.13.Final.jar:]
    at org.Apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.Java:109) [jbossweb-7.0.13.Final.jar:]
    at org.Apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.Java:368) [jbossweb-7.0.13.Final.jar:]
    at org.Apache.coyote.http11.Http11Processor.process(Http11Processor.Java:877) [jbossweb-7.0.13.Final.jar:]
    at org.Apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.Java:671) [jbossweb-7.0.13.Final.jar:]
    at org.Apache.Tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.Java:930) [jbossweb-7.0.13.Final.jar:]
    at Java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_25]
Caused by: Java.lang.LinkageError: loader constraint violation: when resolving method "org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor.<init>(Lorg/Apache/http/client/HttpClient;Lorg/Apache/http/protocol/HttpContext;)V" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, at/fhj/ase/ssl/SSLClientHelper, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for resolved class, org/jboss/resteasy/client/core/executors/ApacheHttpClient4Executor, have different Class objects for the type xecutors.ApacheHttpClient4Executor.<init>(Lorg/Apache/http/client/HttpClient;Lorg/Apache/http/protocol/HttpContext;)V used in the signature
    at at.fhj.ase.ssl.SSLClientHelper.getSSLClientRequest(SSLClientHelper.Java:71) [classes:]
    at at.fhj.ase.beans.Categories.getCats(Categories.Java:39) [classes:]
    at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_25]
    at Sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
    at Sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_25]
    at Java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_25]
    at javax.el.BeanELResolver.getValue(BeanELResolver.Java:302) [jboss-el-api_2.2_spec-1.0.0.Final.jar:1.0.0.Final]
    at com.Sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.Java:176) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at com.Sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.Java:203) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at org.Apache.el.parser.AstValue.getValue(AstValue.Java:169) [jbossweb-7.0.13.Final.jar:]
    at org.Apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.Java:189) [jbossweb-7.0.13.Final.jar:]
    at com.Sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.Java:109) [jsf-impl-2.1.7-jbossorg-2.jar:]
    ... 36 more

JUnitテストのWebサービス側で使用されているものと同じであるため、HttpClientソースは問題ないと確信しています。

ProjectSetup: WebサービスはJBossAS7.1にデプロイされます(これまでのところ正常に動作します)JSFWebクライアントは同じJBossインスタンス。どちらもEclipseを介して開始されます。 JSFWebクライアントのDeploymentAssemblyは次のようになります。 JSF web client DeploymentAssembly

リンケージエラーは、外部(BuildPath&DeploymentAssembly)に追加されたApachehttpクライアントライブラリが原因であると想定しています。しかし、どうすればこれを解決できますか?

詳細が必要な場合は教えてください。助けてくれてとても感謝しています!

6
My-Name-Is

エラーが表示される理由は、RestEasyがjbossモジュールとして提供されるhttpclientjarに依存しているためです。指定したバージョンがJBossによって提供されたバージョンと競合しています。

なぜHTTPClientjarをWebアプリと一緒にパッケージ化する必要があるのですか?残りのクライアントコール用ですか?その場合、JBossAS7のデフォルトのJAX-RS実装であるRestEasyを使用する必要があります。その目的のために使用する方が良いフレームワークになります。

もう1つのオプションは、org.Apache.httpcomponentsWEB-INF\jboss-deployment-structure.xmlモジュールへの依存関係を追加し、WEB-INF\libからhttp-clientjarを削除することです。

10
CoolBeans