CGLib, NetBeans Modules and class loaders
My first try at using CGLib from a Netbeans RCP ended up in a ClassNotFoundException for net.sf.cglib.proxy.Factory I had two modules, MainModule and cglib and MainModule was depending on cglib. And the following snippet was raising the ClassNotFoundException. Enhancer enhancer = new Enhancer(); enhancer.setSuperclass(Graph.class); enhancer.setCallback(NoOp.INSTANCE); Graph g = (Graph) enhancer.create(new Class[]{FrameListener.class,InterpreterAbstraction.class},new Object[]{fl,ia}) ; As I later found out from Enhancer documentation and DevFaqClassLoaders it seems that Enhancer it taking the System class loader instead of taking the Module classloader. I explicitly set the classloader used by the Enhancer via the setClassLoader method and now it seems to work. ...