本文介紹如何利用eclipse插件weblogic plugin在eclipse中的使用。 
  eclipse是目前非常流行的開發平臺,開放擴展的架構讓很多程序員找到了自己個性化的工作環境。
  問題提出: 
  weblogic目前是使用比較多的應用服務器之一,eclipse是流行的ide,如何集成起來開發使用呢?
  解決方法: 
  采用bea提供的weblogic plugin來進行集成開發。
  安裝 
  jdk:1.4.2或1.5.0 從http://java.sun.com上去下載安裝,如果是weblogic 8.x.x系列的版本,應當選用jdk 1.4.2的版本。
   eclipse:3.1.2 從http://www.eclipse.org 上去下載解壓
   weblogic plugin 從https://eclipse-plugin.projects.dev2dev.bea.com/下載
  技巧 eclipse使用技巧之插件管理 
  提示:新下載的插件plugin一定不要都放在原始的eclipse目錄下去,一大堆,累死你。


配置weblogic plugin
 
 


  可以看到weblogic分類下面有weblogic servers菜單項,選擇并打開它。
  這樣可以在這里進行啟動、停止weblogic server等操作。
  project added to the end of the classpath,通過add按鈕,可以選擇你所要加載的項目,這樣所選中的項目里所有的類庫量也會自動地加進來的,不過它的加載順序是在classpath的最后面。
啟動weblogic服務器 

  在控制臺會有如下的啟動信息顯示:
  顯示啟動成功。
  在這里也可以進行增加其它weblogic server的配置,如下:
  修改weblogic server的配置
  刪除weblogic server的配置
  也可以查看相應的幫助文檔,如下:
  打開weblogic plugin的幫助文檔進行查閱,可惜沒有看到。
  停止weblogic服務器 

  在控制臺會有如下的停止信息顯示:
  部署、重新啟動、停止應用程序 
  部署應用:只能通過瀏覽器去部署新的應用,沒有找到這里可以直接進行部署的地方。
  重新啟動:假如我們通過瀏覽器或其它控制端部署了一個web application上去了。
  這時,通過插件停止weblogic,再啟動它后,雙擊展現web appplication modules,可以在下面看我們部署上去的應用了。不過,而慢進行停止再啟動。
  可以直接通過插件提供的刷新功能就會把部署上去的模塊展現出來,如下:
  這時,要重新啟動應用程序的話,只要在應用名稱上面右鍵,在彈出的菜單中選擇redeploy即可重新部署應用了,速度很快的。
  刪除應用程序的話,只要在應用名稱上面右鍵,在彈出的菜單中選擇undeploy即可刪除應用了,模塊名稱立馬消失,速度很快的,要重新部署又得通過瀏覽器或其它控制端來完成了。
  總結 
  此插件的功能給予我們方便地集成eclipse與weblogic的開發使用,提高了效率。
  bug一個,大家要注意。
  關閉eclipse之后重新啟動eclipse后,這時要啟動weblogic會發現以下錯誤而啟動不了,郁悶了吧:)
<critical>
<security>
<bea-090402>
<authentication denied: boot identity not valid;
the user name and/or password from the boot identity file
(boot.properties) is not valid. the boot identity may have been changed
since the boot identity file was created. please edit and update
the boot identity file with the proper values of username and password.
the first time the updated boot identity file is used to start the server,
these new values are encrypted.> *************************************************************************** the weblogic server did not start up properly. reason: weblogic.security.securityinitializationexception:
authentication denied: boot identity not valid;
the user name and/or password from the boot identity file (boot.properties) is not valid.
the boot identity may have been changed since the boot identity file was created.
please edit and update the boot identity
file with the proper values of username and password.
the first time the updated boot identity file is used to start the server,
these new values are encrypted. ***************************************************************************
  不過解決的辦法也簡單,看到下圖的信息了吧,這個插件在對用戶進行存取的時候出了問題,導致錯誤的,你每次重新啟動eclipse后,要修改一下weblogic的配置文件,把里面的用戶名用密碼再保存后才行的。
后記 
  文章寫完后,我又修復了上述的bug,這里重點再闡述一下解決過程:解壓、反編譯、替換加密方法、編譯、重打包、關閉eclipse、覆蓋、重啟:)
/**   * 將 source 進行 base64 編碼   *    * @param source   * @return   */ public static string buildbase64(string source) {   if(source == null)   {    return null;   }   return (new sun.misc.base64encoder()).encode(source.getbytes()); } /**   * 將 base64 編碼的字符串 base65code 進行解碼   *    * @param base65code   * @return   */ public static string getfrombase64(string base65code) {   if(base65code == null)   {    return null;   }   base64decoder base64decoder = new base64decoder();   try   {    byte[] b = base64decoder.decodebuffer(base65code);    return new string(b);   }   catch(exception e)   {    e.printstacktrace();    return null;   } } cserverinstall.setusername(cryptoutil.getdefault().decrypt(new string(base64util.base64tobytearray(getnodevalue(celement))),id)); 為 cserverinstall.setusername(getfrombase64(getnodevalue(celement))); 修改 cserverinstall.setpassword(cryptoutil.getdefault().decrypt(new string(base64util.base64tobytearray(getnodevalue(celement))),id)); 為 cserverinstall.setpassword(getfrombase64(getnodevalue(celement)));
org.w3c.dom.text usernametext = doc.createtextnode(base64util.bytearraytobase64(cryptoutil.getdefault().encrypt(cserver.getusername(),cserver.getid()).getbytes())); 為 org.w3c.dom.text usernametext = doc.createtextnode(buildbase64(cserver.getusername())); 修改 org.w3c.dom.text passwordtext = doc.createtextnode(base64util.bytearraytobase64(cryptoutil.getdefault().encrypt(cserver.getpassword(),cserver.getid()).getbytes())); 為 org.w3c.dom.text passwordtext = doc.createtextnode(buildbase64(cserver.getpassword()));
新聞熱點
疑難解答