总结一下ws_ant自动编译、部署WebSphere的方法

使用IBM自带的console在页面中部署ear想必初学者糊弄两下都能会。

近期因为要求使用ant编译并且自动部署到websphere,本来就不太懂怎麽使用ant,一直到解决问题花了很长很长的时间,期间遇到不少问题,CSDN上面讨论websphere的不多,问个问题几乎一问三不知,把异常代码往google上一贴,出来的很多结果都只有问题,没有解决方案,这里把遇到的问题的解决方法总结一下,希望可以帮助到目前或者将来遇到同样问题的朋友。

首先build.xml就不罗列了,参照sample打包成.ear文件应该不是难事。

  • 编译过程中或许因为Java源代码中含有中文,使用javac编译的时候在命令行中出现乱码情况,因而导致中文後面的符号被错误解析,解决方法是在<javac 中加入一个 encoding="utf-8″的属性,这样就OK了。这个utf-8应该与java源代码所保存的文件编码格式一致。
  • 可能在本机测试,部署到本机websphere中并无报错,可是一旦上传到远端伺服器的时候却报错了,异常: WSProfileNameException: profileName=AppSrv01,假设部署到本机时是这麽写的

<wsInstallApp

options=" -cell ${cell} -node ${node} -server ${server} -appname ${application} -usedefaultbindings"

profileName="${profilename}" host="${deployserver}"

ear="${build}/${deploy.ear.file}" port="${SOAP.Port}" conntype="SOAP" wasHome="${was.home}"

failonerror="true" />

出现这个异常的原因在於profileName,因为远端伺服器采用集群(Cluster)配置方式,因而不能指定profileName,要改写成

<wsInstallApp

options=" -cluster ${cluster} -usedefaultbindings"

host="${deployserver}"

ear="${build}/${deploy.ear.file}" port="${SOAP.Port}" conntype="SOAP" wasHome="${was.home}"

failonerror="true" />

对比下橙色的字体。

  • 异常情况:“The application management service is not running. Application management commands will not run.”,检查SOAP的端口号是否正确,正确的SOAP端口号应该对应着:"System Administration 系统管理" → “部署管理程式" 中的SOAP端口号,而不是 “Application Servers应用程式服务器" 中所对应的SOAP端口号。
  • 异常情况:[wsadmin] Exception in thread “main" java.lang.NoClassDefFoundError: org.eclipse.core.launcher.Main[wsadmin] at com.ibm.wsspi.bootstrap.WSPreLauncher.launcherEclipse(WSPreLauncher.java:263)[wsadmin] at com.ibm.wsspi.bootstrap.WSPreLauncher.main(WSPreLauncher.java:75)

缺少org.eclipse.core.launcher.Main这个类,发现在org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar这个里面,可是已经复制进plugins

了,但仍然找不到该类,後来发现原来是wasHome的问题,因为部署到远端伺服器的原因,我把wasHome改成了伺服器上的was路径 /opt/IBM/WebSphere/AppServer ,wasHome改回本地的路径就OK了

  • 异常情况:  /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/config/temp/upload/app23432(5个随机数).ear not exists  这个问题尚未解决。我的方法是直接放弃了这一方式,改用ftp上传文件到server上然後远程调用server上的命令执行wsadmin.sh操作进行安装、启动application

官方解释如下:

Remote .ear files cannot be installed remotely using wsadmin on a Base node that is not part of a WebSphere cell. A non-federated Base application server does not provide the file transfer capability for wsadmin. The Web console works fine because it does not use the file transfer application and has implemented another file transfer mechanism to browse and transfer .ear files between different machines.

The file transfer application is functional only in a Network Deployment managed cell environment. You can use either the Web console to install .ear files remotely, or install Network Deployment Edition and use the WebSphere Deployment manager to install .ear files through the cell manager using wsadmin after federating the Base node.

The following error was noticed in one of the customer

com.ibm.websphere.management.exception.AdminException: ADMA0043E:

C:\Documents and Settings\tsimon\Local Settings\Temp\NSA_NBP_WebModule.ear does not exist for installation.

要麽用console部署,要麽在伺服器上安装 Network Deployment Edition

發表迴響

這個網站採用 Akismet 服務減少垃圾留言。進一步瞭解 Akismet 如何處理網站訪客的留言資料