2008年7月9日 星期三

(轉貼)如何在Eclipse3.3中發布專案到local Websphere 6.1 AP Server

這是我在網路上找到的一篇文章,覺得很有用,已徵得作者的同意,因此轉貼至我的Blog!
文章出處為我的Java筆記 Blog,網址為http://myjavanote.blogspot.com/2008/05/eclipse33local-websphere-ap-server.html

以下為全文

即使網路上的消息是eclipse預計在2007Q3新增對Websphere AP server 6.1的支援 , 但直到現在在Eclipse中新增server時websphere都還是只有6.0可選擇。

經過Google神廟九十叩一百八十拜的努力後, 發現了下列連結文章:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=160220
https://bugs.eclipse.org/bugs/attachment.cgi?id=95764&action=diff

這裡將使用eclipse 3.3(2007Q4版,eclipse-jee-europa-winter-win32)作修改, 使之能支援publish 至WAS 6.1。

1. 首先打開 [eclipse目錄] \plugins\org.eclipse.jst.server.websphere.core_1.0.201.v20070608 目錄。
2. 將plugin.xml , plugin.properties, webspherecore.jar 三個檔案覆蓋到 該目錄中。(建議覆蓋前原本的三個檔案先作備份)
3. 將websphere.6.1.serverdef 放到該目錄下serverdef目錄, 將websphere.6.1.xml放到該目錄下serverdef \ scripts 目錄。
4. 開啟eclipse。
5.點選功能選單 window – preference , 點選 Server—installed Runtimes項目,如下圖:

6. 按下Add.. 按鈕 , 展開IBM項目, 你就會看到IBM WhebSphere V6.1
(
如果沒看到IBM Websphere V6.1項目,而你確定你相關檔案都已經放了,那麼請關閉eclipse , 使用指令 eclipse –clean 來開啟就可以看到了)
7. 按下Next> , IBM WebSphere Installation Directory填入你安裝websphere 6.1的目錄路徑,注意路徑中不可有空白,如果有包含空白字元路徑,可使用dos 8.3的方式填入,像我這就填入 C:/progra~1/IBM/WebSphere/AppServer
,
先不要按Finish,我們要設一下JRE,按下installed JRE preferencess。
8. 這邊我們要選擇Websphere內帶的JRE避免編譯出來的class版本與serverjdk版本不符而發生錯誤
9. 按下Add..按鈕, 如下圖,JRE name可自己取,JRE home Directory 則填入websphere內帶JDK的目錄路徑 , 這邊我是填C:\Program Files\IBM\WebSphere\AppServer\java , 按下 OK 再按一次oK
10. 回到了new server runtime視窗,JRE選擇我們剛新增的JRE,如下圖:
11. 切換到Java EE perspective ,點選 server View, 按下右鍵點選New—server

12. Server type一樣選IBM WebSphere V6.1,下面的 server runtime選我們剛新增好的IBM WebSphere V6.1 ,Next..
13. 接下來在 server profile directory填入你的server profile目錄, 我這是填入c:/progra~1/IBM/WebSphere/AppServer/profiles/AppSrv01 , 按下finish
14. 接著就可以在server view中看到我們新增的server, 在其上按下右鍵選Add and Remove projects,
將你的Ear專案加入後 , 就可以做publish的動作了 , publis成功的話你會在console perspective看到如下訊息:

Buildfile: C:\Users\Dolph\Desktop\eclipse\plugins\org.eclipse.jst.server.websphere.core_1.0.201.v20070608\serverdef\scripts\websphere.6.1.xml

deploy.j2ee.ear:

[jar] Building jar: C:\Users\Dolph\Desktop\eclipse\ws\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\xxxxEAR.ear

[wsadmin] WASX7209I: 已利用 SOAP 連接器來連接 PCNode01 節點中的 "server1" 程序;程序類型是:UnManagedProcess

[wsadmin] ADMA5017I: 已開始解除安裝 xxxxEAR

[wsadmin] ADMA5104I: 已順利更新 WebSphere:cell=xx-PCNode01Cell,node=xx-PCNode01 的伺服器索引項目。

[wsadmin] ADMA5102I: 已順利從配置儲存庫中刪除xxxxEAR的配置資料。

[wsadmin] ADMA5011I: xxxxEAR應用程式的 temp 目錄清理完成。

[wsadmin] ADMA5106I: 已順利解除安裝應用程式 xxxxEAR

[wsadmin] WASX7209I: 已利用 SOAP 連接器來連接 xx-PCNode01 節點中的 "server1" 程序;程序類型是:UnManagedProcess

[wsadmin] ADMA5016I: 已開始安裝 xxxxEAR

[wsadmin] ADMA5058I: 用部署目標的版本來驗證應用程式和模組版本。

[wsadmin] ADMA5018I: 正在執行 EJBDeploy 指令來處理企業保存檔 (EAR) C:\Users\Dolph\AppData\Local\Temp\app7121.ear

[wsadmin] Starting workbench.

........more

最後, 經過測試可正常發佈EAR project ,沒辦法直接發佈dynamic web project, 所以記得新增enterprise application project把相關的dynamic web project加入成web module後再發佈…………………….

15.
對了, 還有件重要的事, 記得把專案內容Java Compiler中的compiler compliance level設為5.0(因為websphere內帶使用的JDK1.5版的), 否則就算成功拋上server, 程式run 時還是會出錯喔。

16. 另外, 除了上列設定外, 在專案內容的Java Build Path中也要記得將IBM Websphere v6.1 server runtime加入libraries頁中喔, 不然也會導致編譯錯誤的問題喔。

沒有留言: