最近一個項目在使用mina傳輸數據的時候,osgi客戶端總是報錯,ClassNotFoundException,參考下面的文檔:http://kangzye.blog.163.com/blog/static/3681922320105130314194/
最後解決了問題,代碼如下:
ClassLoader curThreadCls=Thread.currentThread().getContextClassLoader();
ClassLoader cls=Main.class.getClassLoader();
if(curThreadCls!=cls)
Thread.currentThread().setContextClassLoader(cls);