Tampilkan postingan dengan label Websphere. Tampilkan semua postingan
Tampilkan postingan dengan label Websphere. Tampilkan semua postingan

Intalling Websphere AS for Developers on Centos via command line

WAS for Developers (the full version, not the liberty version) turns out to be not quite straightforward to install on Centos using only the command line (since my Centos installation is a minimal one). So I decided to wriote down my experience installing it.

Preparing Centos:

  1. yum install "Development Tools"
  2. If your Centos is 64 bit, you need to install some 32 bit libraries to make IBM Installation Manager works... yum provides \*/libgcc_s.so.1 then pick from the list the package for 32 bit and yum install it.
  3. Open 9080 and 9060 (the former application port, latter management port of WAS). firewall-cmd --zone=public --add-port=9080/tcp --permanent. Do that for 9060 too and then firewall-cmd --reload.
Installation of WAS
  1. Download IBM installation manager (IIM) for linux. As of this writing, the URL is: https://www-01.ibm.com/marketing/iwm/iwm/web/download.do?source=swerpws-wasdevdl85&S_PKG=500023135&S_TACT=109J84JW&S_CMP=web_opp_ibm_ws_appinfra_wasdev&lang=en_US&dlmethod=http
  2. Download WAS for Developers, Installation Managers Repository. Same URL as above. It comes in three zip files, each 1 GB.
  3. Unzip IIM, run userinstc -c. It will install IIM to a directory of your choice.
  4. When you finish installing IIM, it will ask whether to restart IIM. Choose cancel.
  5. Unzip all three WAS for Developers zip files to one folder. This folder is your repository.
  6. In order to install WAS without GUI, you need what IBM calls response file: https://www-01.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.installation.nd.doc/ae/cins_WASv85_nd_install_Win32.html
  7. My response file is in the end of this post.
  8. Go to IIM install folder, navigate to eclipse/tools subfolder. Run imcl. imcl input full-path-to-response-file -log logfile -acceptLicense
  9. After WAS is installed, go to WAS install directory and bin subdir and run manageprofiles. manageprofiles.sh -create will create default profile.
  10. Now, WAS can be started. startServer.sh server1.
This is my response.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE agent-input [
<!ENTITY home "USERHOMEDIR">
]>
<!--The "acceptLicense" attribute has been deprecated. Use "-acceptLicense" command line option to accept license agreements.-->
<agent-input acceptLicense="true">
<server>
<repository location="/code/was" />
</server>
<profile id="IBM WebSphere Application Server V8.5" installLocation="/code/IBM/WebSphere/AppServer" />
<install modify="false">
<offering id="com.ibm.websphere.DEVELOPERSILAN.v85" profile="IBM WebSphere Application Server V8.5" features="core.feature,ejbdeploy,thinclient,embeddablecontainer,com.ibm.sdk.6_64bit" installFixes="none" />
</install>
<preference name="com.ibm.cic.common.core.preferences.eclipseCache" value="/code/IBM/IMShared" />
<preference name="com.ibm.cic.common.core.preferences.connectTimeout" value="30" />
<preference name="com.ibm.cic.common.core.preferences.readTimeout" value="45" />
<preference name="com.ibm.cic.common.core.preferences.downloadAutoRetryCount" value="0" />
<preference name="offering.service.repositories.areUsed" value="true" />
<preference name="com.ibm.cic.common.core.preferences.ssl.nonsecureMode" value="false" />
<preference name="com.ibm.cic.common.core.preferences.http.disablePreemptiveAuthentication" value="false" />
<preference name="http.ntlm.auth.kind" value="NTLM" />
<preference name="http.ntlm.auth.enableIntegrated.win32" value="true" />
<preference name="com.ibm.cic.common.core.preferences.preserveDownloadedArtifacts" value="true" />
<preference name="com.ibm.cic.common.core.preferences.keepFetchedFiles" value="false" />
<preference name="PassportAdvantageIsEnabled" value="false" />
<preference name="com.ibm.cic.common.core.preferences.searchForUpdates" value="false" />
<preference name="com.ibm.cic.agent.ui.displayInternalVersion" value="false" />
<preference name="com.ibm.cic.common.sharedUI.showErrorLog" value="true" />
<preference name="com.ibm.cic.common.sharedUI.showWarningLog" value="true" />
<preference name="com.ibm.cic.common.sharedUI.showNoteLog" value="true" />
</agent-input>

Ant Tasks for Websphere Deployment

The following is my ant for websphere deployment, application start & stop, etc. The complete API doc can be found in IBM website: https://publib.boulder.ibm.com/infocenter/dmndhelp/v6rxmx/index.jsp?topic=/com.ibm.wsps.602.javadoc.doc/doc/index.html
For this tasks to run, you need to have the jar file com.ibm.ws.runtime.jar. This jar file can be found in plugins directory of your Websphere installation.

<property name="hostName" value="localhost" />
<property name="connType" value="SOAP" />
<property name="port" value="8880" />
<property name="deployEar.dir" value="C:\Users\firmanw\Documents\zw2\OSMS\build" />
<property name="deployEar" value="osms.war" />
<property name="wasHome.dir" value="C:\Program Files (x86)\IBM\TeamConcert\runtimes\base_v7" />
<property name="app.name" value="osms_war" />
<property name="profile.name" value="profilexfirman" />
<taskdef name="wsInstallApp" classname="com.ibm.websphere.ant.tasks.InstallApplication" classpath="com.ibm.ws.runtime.jar" />
<taskdef name="wsStartApplication" classname="com.ibm.websphere.ant.tasks.StartApplication" classpath="com.ibm.ws.runtime.jar" />
<taskdef name="wsStopApplication" classname="com.ibm.websphere.ant.tasks.StopApplication" classpath="com.ibm.ws.runtime.jar" />
<target name="installEar" depends="build.osms">
<echo message="Deployable EAR File found at: ${deployEar.dir}/${deployEar}" />
<wsInstallApp ear="${deployEar.dir}/${deployEar}" wasHome="${wasHome.dir}" conntype="${connType}" port="${port}" host="${hostName}" profilename="profilexfirman" options="-appname ${app.name} -usedefaultbindings -update" />
</target>
<target name="startInstallEar" depends="installEar">
<echo message="Mulai ngestart" />
<wsStartApplication wasHome="${wasHome.dir}" conntype="${connType}" port="${port}" host="${hostName}" profilename="${profile.name}" application="${app.name}" />
</target>
<target name="startEar">
<echo message="Mulai ngestart" />
<wsStartApplication wasHome="${wasHome.dir}" conntype="${connType}" port="${port}" host="${hostName}" profilename="${profile.name}" application="${app.name}" />
</target>
<target name="stopEar">
<echo message="Mulai nyetop" />
<wsStopApplication wasHome="${wasHome.dir}" conntype="${connType}" port="${port}" host="${hostName}" profilename="${profile.name}" application="${app.name}" />
</target>

<target name="restartEar" depends="stopEar, startEar"></target>

Websphere hot deployment and dynamic reloading

In the office we use Websphere AS and RAD as IDE. When you make changes to a Java class file, the changes are publised by the IDE to the AS, and the server restarts for the changes to take effect. This is in contrast to the changes done to JSP which do not require server restart to take effect. Actually there is a possibility of hot deployment and dynamic reloading (http://publib.boulder.ibm.com/infocenter/wsdoc400/v6r0/index.jsp?topic=/com.ibm.websphere.iseries.doc/info/ae/ae/trun_app_hotupgrade.html) which basically works like this: you replace the class file in the server with the new class file and the changes should take effect immediately without needing server restart. This is a very useful feature of WAS and it makes me wonder why the WAS plugin for RAD/Eclipse does not have a feature to enable this. I know there are limitations, like when you replace Hibernate entities or deployment descriptor, then you still need to restart the server but generally this feature is very useful during development.

So i decided to write an ant build file which runs when there is an automatic build. The job of this build file is basically to replace the class files in the server with the newly built class files in the workspace.

To do this, I first need to manually deploy the EAR via the WAS console. This is to make the exploded EAR file available in the server. Because when i deploy the ear by right clicking on the project -> run as -> run in the server, the exploded ear file is not there in the server! I dont know where, probably in one of the numerous plugin directories of the RAD/Eclipse installation.

After the ear file is manually deployed, then disable automatic publishing in the WAS plugin.


And then the ant build file:



Pretty obvious I guess. The src.osms is the workspace build directory while the des.osms is the WAS exploded ear directory. The most important part of the build file is the mnodified selector (https://ant.apache.org/manual/Types/selectors.html#modified) which selects only recently modified file (which is the file newly built by Eclipse automatic build) and copies these files to WAS.

Now, this ant build file needs to run everytime you modify a class file or anything, so enable automatic build on your project.

And then right click on your project -> properties -> builders -> new -> ant builders -> OK. You get this dialog
Choose your ant build file. Then click on the target tab and set the target for manual build and auto build. Done.


PS: if you have money, try JRebel.