Websphere Classes沖突診斷
作者:tacy lee
由于大量開源框架的采用,Classes沖突的問題在我們的項目中越來越常見,下面寫了一個簡單的jsp,用來查找當前使用類的位置:
<%@page contentType="text/html; charset=gb2312" %> <html> <head> <title>Class conflict</title> </head> <body> Example input: com.primeton.tp.web.driver.webdriver.PageDriver<br> <form action="<%=request.getRequestURI()%> " method="post"> <input type="text" name="className" size="50" ><br> <input type="submit" value="submit"> </form> <% String classLocation = null; String className =request.getParameter("className"); if ((className != null) && ((className = className.trim()).length() != 0)) { try{ classLocation = Class.forName(className).getProtectionDomain().getCodeSource().toString(); }catch(Throwable e){ log("error=" + e, e); } if (classLocation != null) { out.println("Class " + className + " found in <br>" + classLocation ); } else { out.println("Class '" + className + "' not found" ); } } %> </body> <html>
通過這個jsp頁面可以輸入需要查詢的類
-----------------------------------------------------------------------------------------------------------------------------------------------------
另外,websphere可以通過下面兩個方法來改變類的加載:
1、在"Applications" >"Enterprise Applications" >" yourear ">" Class Loading and File Update Detection"
修改:"Class loader mode" 為 "Parent Last",這樣應用類可以覆蓋父裝載器的類
當然但如果你混合使用了被覆蓋的類和沒有被覆蓋的類,則此操作有可能會導致 ClassCastException 或 LinkageErrors
2、在"Servers" > "Application servers" > "yourserver" > "Process Definition" > "Java Virtual Machine"
添加CLASSPATH,讓你的類先加載
posted on 2007-12-21 18:05 tacy lee 閱讀(1349) 評論(0) 編輯 收藏 所屬分類: 測試相關