Monday, June 29, 2009

Adding external jar to your CustomCodeAction

[Question]

In GUI mode, the installer launches and installs, and after the installation executes a PostInstall Action which runs a Script/Batch file. In this Script file we call another Java class which is interactive. (means it gets input and outputs messages on the same window or a separate window). The dependencies are added in the batch/script file using export Library Path

Now I want to emulate this in Console Mode. I want to call this class from Console Mode Custom Code execution action so that the input and output are done on the Console mode Installer. The class which is called in turn depends on a lot of 3rd party jars. As soon as I add dependencies for the 3rd party signed jars it always gives exception "no manifest section for signature file entry" .
Since the jars are 3rd party, I can't go back and modify the jar contents. Is there anyway to overcome this problem ?

[ANSWER]

If you are calling your java class from a script/batch file add the dependency of your 3rd party jar files in the script itself instead of adding dependency in the IA project. Since the java class file is called from a script which spawns a different process and into a new shell the dependencies added to the main project does not get resolved while loading the class file into the JRE when spawned through script/batch.
InstallAnywhere's feature of adding files into class path or adding dependencies only works correctly in case of custom code action.

To load the 3rd party jars when using with shell use the following java arguments in the shell script to execute it.

java -cp abc.jar;xerces.jar;ant.jar com.yourcompany.packagename.ClassName

Here -cp added to the Java command tells the JRE to load abc.jar, xerces.jar and ant.jar to be added in the class path for executing the com.yourcompany.packagename.ClassName class file.

Installing JBoss server and application using IA

[Question]

How can I modify the port number in JBoss server using InstallAnywhere. I install JBoss-3.2.7.zip with IA, I get a user input for the Port Number and I know that the port number has to be set in the file server.xml inside the JBoss-3.2.7.zip. Should I use the action 'Modify Text File in Archive' action to replace the port? I can use the variable  $PORT_NUMBER$ to replace the existing port number. But don't know how to use it in the action to search for the line
 
Connector port="8080" address="${jboss.bind.address}

[ANSWER]

If you are installing JBoss using InstallAnywhere  add action in your project modify files in Archive. In your case its a bundled archive so select installed archive then click configure, 
In the configure frame update  search for  "${jboss.bind.address}" and fill the replace with "<your desired port number>"

Once this activity is done add the extract archive action to actually install your JBoss server zip.

An alternative approach to this problem would be to deflate the archive and then add an action to modify ASCII file with the above data.
       If you want to deploy your application using InstallAynwhere go to the Organization -> Hosts tab of Advanced designer click on add host. Choose application server from the choice (there will be two hosts listed over there DataBase Host and Application Server host)
Once Application server host is added to the project in Host section, fill up the necessary details like in your case choose JBoss 4.0.5 or newer and then select "Server Path".
Once done go to the Install Section of the Advanced designer and add an Action to deploy war file.