我无法在玻璃鱼服务器中实现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中的所有测试。
这是玻璃鱼的装载机!我无法让它从WEB/lib加载类。
发布于 2016-05-30 15:37:18
o.getClass()的类加载器看不到IObjectProxy,所遇到的错误类似于调用:
Class.forName(IObjectProxy.class.getName(),
false,
o.getClass().getClassLoader());似乎不可能在你的玻璃鱼设置。你有不同的解决方案:
IObjectProxy对o.getClass().getClassLoader()是可见的。IObjectProxy.class.getClassLoader()是o.getClass().getClassLoader()的子级,则使用这个类加载器。MultipleParentClassLoader (Buddy的一部分),它是两个类加载器的子类,用于加载被检测的类。您可以通过调用:
新MultipleParentClassLoader.Builder() .append(IObjectProxy.class,o.getClass()) .build();https://stackoverflow.com/questions/37264607
复制相似问题