背景: ant在本地(windows)部署远程(linux)上的was,出现一些连接上的问题,或者说用wsadmin部署websphere出现的各种让人崩溃的异常,小子经过多天努力,终于成功安装。
这个远程可以是在vmware上,也可以是实体机上
########################################
ant task如下
<target name="wsInstallApp">
<wsAdmin
wasHome="${WAS_HOME}"
command="$AdminApp install ${ear} {-nopreCompileJSPs -distributeApp -nouseMetaDataFromBinary -nodeployejb
-createMBeansForResources -noreloadEnabled -nodeployws -validateinstall warn -noprocessEmbeddedConfig
-filepermission .*\.dll=755#.*\.so=755#.*\.a=755#.*\.sl=755 -noallowDispatchRemoteInclude -noallowServiceRemoteInclude -asyncRequestDispatchType DISABLED
-nouseAutoLink -node localhostNode01 -cell localhostNode01Cell -server server1 -appname HelloWorld -contextroot HelloWorld -MapWebModToVH {{HelloWorld.war HelloWorld.war,WEB-INF/web.xml default_host}}}"
profileName="${profileName}"
conntype="${remoteConnType}"
host="${remoteHostName}"
port="${remotePort}"
user="${username}"
password="${password}"
failοnerrοr="true"
/>
</target>
其实command没必要这些复杂,简化下就是
<target name="wsInstallApp">
<wsAdmin
wasHome="${WAS_HOME}"
command="$AdminApp install ${ear} {-node localhostNode01 -cell localhostNode01Cell -server server1 -appname HelloWorld -contextroot HelloWorld -MapWebModToVH {{HelloWorld.war HelloWorld.war,WEB-INF/web.xml default_host}}}"
profileName="${profileName}"
conntype="${remoteConnType}"
host="${remoteHostName}"
port="${remotePort}"
user="${username}"
password="${password}"
failοnerrοr="true"
/>
</target>
其中
WAS_HOME就是C:/Program Files (x86)/IBM/WebSphere/AppServer
host:就是远程主机名,或者IP
port是8880,不一定一样,看每个服务的wsadmin.properties文件,里面有写
conntype就是soap啦
profilename就是AppSrv01 看你服务
下面这个应该也行
<wsInstallApp
wasHome="${WAS_HOME}"
ear="${ear}"
profileName="${profileName}"
conntype="${remoteConnType}"
host="${remoteHostName}"
port="${remotePort}"
user="${username}"
password="${password}"
failοnerrοr="true"
/>
</target>
-----------------------------------------------------------------------------------------------------------------------
如果是wsadmin命令的话就是
一、wsadmin -host xx port 8880 -user wasadmin -password password (-lang jython 这个默认是jacl)
二、$AdminApp install "E:/code/HelloWorld.war" {-node fbdbNode01 -cell fbdbNode01Cell -server server1 -appname HelloWorld -contextroot HelloWorld -MapWebModToVH {{HelloWorld.war HelloWorld.war,WEB-INF/web.xml default_host}}}
$AdminApp save
################################################
异常如下:
[13-5-20 19:41:34:422 CST] 00000000 wtp W org.eclipse.jst.j2ee.commonarchivecore.internal.impl.ContainerImpl getFiles No load strategy is available for [ C:\Users\Administrator\AppData\Local\Temp\app31996.war ]
[13-5-20 19:41:48:047 CST] 00000000 FileTransferC E ADFS0112E: 文件传输失败,带有下列消息:Upload retry limit exceeded for file C:\Users\Administrator\AppData\Local\Temp\HelloWorld_war13ec1be998b.ear. Exception: java.net.ConnectException: Connection refused: connect.[13-5-20 19:41:48:062 CST] 00000000 AbstractShell E WASX7120E: 来自有文本“com.ibm.websphere.management.filetransfer.client.TransferFailedException
java.net.ConnectException: java.net.ConnectException: Connection refused: connect
”的异常的诊断信息如下:
com.ibm.websphere.management.filetransfer.client.TransferFailedException: Upload retry limit exceeded for file C:\Users\Administrator\AppData\Local\Temp\HelloWorld_war13ec1be998b.ear. Exception: java.net.ConnectException: Connection refused: connect
还有一个不知主机,好像是unKnownHostException
两个问题实际上是一个问题
如果出现以上问题,那么命令行下ping 192.168.1.103(IP), 可以通,再ping远程主机名,如 ping xxHostName,这时应该是不通的
对了,记得把linux的防火墙关闭。
可以用命令service iptables status查看防火墙状态,service iptables stop关闭,chkconfig iptables off永久关闭
而本地远程部署websphere是需要用到远程hostName的,所以在C:\Windows\System32\drivers\etc目录下,修改hosts文件,把你的远程主机名和ip加上去
例如:192.168.1.103 xxHostName
如果你是部署vmware虚拟机上的,并且虚拟机名字是localhost,那么你暂时把127.0.0.1 localhost 这个删除就可以了。
注意主机名localhost.localdomain也是localhost,因为.后面是域名。
修改完全之后,再次Ping xxhostname,通了。
那么再次运行ant或wsadmin命令。
如果你启动了was的安全性,你可能遇到下面的问题
[13-4-22 14:46:53:595 CST] 00000000 AbstractShell A WASX7093I: 发出消息:“WASX7023E: 创建与主机“192.168.88.130”的“SOAP”连接时发生错误;异常信息:com.ibm.websphere.management.exception.ConnectorNotAvailableException: [SOAPException: faultCode=SOAP-ENV:Client; msg=Error opening socket: javax.net.ssl.SSLHandshakeException: com.ibm.jsse2.util.g: PKIX path building failed: java.security.cert.CertPathBuilderException: PKIXCertPathBuilderImpl could not build a valid CertPath.; internal cause is:
java.security.cert.CertPathValidatorException: The certificate issued by CN=localhost.localdomain, OU=Root Certificate, OU=localhostNode01Cell, OU=localhostNode01, O=IBM, C=US is not trusted; internal cause is:
java.security.cert.CertPathValidatorException: Certificate chaining error; targetException=java.lang.IllegalArgumentException: Error opening socket: javax.net.ssl.SSLHandshakeException: com.ibm.jsse2.util.g: PKIX path building failed: java.security.cert.CertPathBuilderException: PKIXCertPathBuilderImpl could not build a valid CertPath.; internal cause is:
java.security.cert.CertPathValidatorException: The certificate issued by CN=localhost.localdomain, OU=Root Certificate, OU=localhostNode01Cell, OU=localhostNode01, O=IBM, C=US is not trusted; internal cause is:
java.security.cert.CertPathValidatorException: Certificate chaining error]”
这时把命令行的东西全部关掉重新打开,再不行重启was。 上面的问题应该是在运行ant或was的过程中,会弹出一个证书让你选择,选择y即可。
完毕