2016-11-11 59 views
0

我有這個架構部署在Wildfly的EAR:wildfly類加載器的問題

  • EAR:
    • ejbA.jar
    • ejbB.jar
    • LIB
      • LibInterfaceA.jar
      • LibInterfac eB.jar
    • WAR
      • LIB
        • LibInterfaceA.jar

LibInterfaceA.jar僅在使用的接口的庫ejb m模塊(A和B),並在WAR中注入ejb並在LibInterfaceB.jar中擴展。

問題是與Java反射,當我搜索定製註釋裏面LibInterfaceA:

public Annotation getAnnotazione(Method method, Class annotationType){ 
    Annotation annotazioni[] = method.getAnnotations(); 
    URL locationsearch = annotationType.getResource('/' + annotationType.getName().replace('.', '/') + ".class"); 
    for(Annotation a : annotazioni){ 
     Class klass = a.annotationType(); 
     URL location = klass.getResource('/' + klass.getName().replace('.', '/') + ".class"); 
     if(a.annotationType().getName().equals(annotationType.getName())){ 
      return a; 
     } 
    } 
    return null; 
} 

我把這種方法在一個類的WAR中找到註解annotationType = @定製。 @Custom是WAR/lib/LibInterfaceA.jar

如果我調用這個方法來查找一個實現LibInterfaceB接口的LibInterfaceB接口,它擴展了LibInterfeceA中的一個接口,該方法的註解@Custom是jar EAR/lib /LibInterfaceA.jar,所以類對於類加載問題是不同的。

我該如何解決這個問題?

+0

我有些困惑。兩個LibinterfaceA.jar在兩個不同的位置是否相同? –

回答

1

您可以從戰爭中移除LibInterfaceA.jar。默認情況下,sub的部署可以使用它的lib目錄(除非你在ear的jboss-depoyment-structure.xml中設置ear-subdeployments-isolated = true)

+0

解決標記在戰爭中的依賴關係提供,所以圖書館只包括廣告EAR級別 –