我有這個架構部署在Wildfly的EAR:wildfly類加載器的問題
- EAR:
- ejbA.jar
- ejbB.jar
- LIB
- LibInterfaceA.jar
- LibInterfac eB.jar
- WAR
- LIB
- LibInterfaceA.jar
- LIB
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,所以類對於類加載問題是不同的。
我該如何解決這個問題?
我有些困惑。兩個LibinterfaceA.jar在兩個不同的位置是否相同? –