Glassfish サーバー内に BB プロキシを実装できませんでした。生成されたクラスを使用しようとすると、次のようにスローされます。
Grave: java.lang.IllegalStateException: Error invoking java.lang.ClassLoader#findClass
at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection$Dispatcher$Resolved.loadClass(ClassInjector.java:401)
at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection.inject(ClassInjector.java:210)
at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default$InjectionDispatcher.load(ClassLoadingStrategy.java:204)
at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default.load(ClassLoadingStrategy.java:119)
at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:4350)
at ar.gov.santafe.mpa.odbogm.proxy.ObjectProxyFactory.create(ObjectProxyFactory.java:77)
プロキシ オブジェクトを生成するメソッド クラスは次のとおりです。
public static <T> T create(T o, OrientElement oe, SessionManager sm ) {
T po = null;
try {
ObjectProxy bbi = new ObjectProxy(o,oe,sm);
po = (T) new ByteBuddy()
.subclass(o.getClass())
.implement(IObjectProxy.class)
// .method(isDeclaredBy(IObjectProxy.class))
.method(any())
.intercept(MethodDelegation.to(bbi))
.make()
.load(o.getClass().getClassLoader(), ClassLoadingStrategy.Default.INJECTION)
.getLoaded().newInstance();
bbi.___setProxyObject(po);
} catch (InstantiationException ex) {
Logger.getLogger(ObjectProxyFactory.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(ObjectProxyFactory.class.getName()).log(Level.SEVERE, null, ex);
}
return po;
}
完全なスタック トレースは次のとおりです。
注: コードは正常に動作し、スタンドアロン jvm ですべてのテストに合格します。
Glassfish のクラスローダです。WEB-INF/lib からクラスをロードできませんでした。