Pages

Wednesday, June 19, 2013

A Few JBoss 7 Snippets

Identify the Deployment Location

When the application is deployed , if we need to identify the location where the app is located on file system.

When the deployment is done ,we can see this sort of log at the bottom

14:31:39,759 INFO [org.jboss.as.repository] (HttpManagementService-threads - 4) JBAS014900: Content added at location /soa/jboss-eap-6.1/standalone/data/content/b2/1a30972ac24e7831f1c4c9c831605a60580120/content

Now the content of the deployed app is available at

/soa/jboss-eap-6.1/standalone/data/content/b2/1a30972ac24e7831f1c4c9c831605a60580120

In this location there will be a content directory which have the application contents


Encrypt a Password

To encypt a Password in JBoss 7 we can use

[root@vx111a jboss-eap-6.1]# java -cp $JBOSS_HOME/modules/system/layers/base/org/picketbox/main/picketbox-4.0.17.Final-redhat-1.jar:$JBOSS_HOME/modules/system/layers/base/org/picketbox/main/picketbox-commons-1.0.0.final-redhat-2.jar:$JBOSS_HOME/modules/system/layers/base/org/picketbox/main/picketbox-infinispan-4.0.17.Final-redhat-1.jar:$JBOSS_HOME/modules/system/layers/base/org/jboss/log4j/logmanager/main/log4j-jboss-logmanager-1.0.1.Final-redhat-2.jar org.picketbox.datasource.security.SecureIdentityLoginModule jagadesh

Encoded password: 7b228572f1d62ebcdf8592078de921bc

Remote Deployment Scanner

JBoss allows us to hot deploy a application when we copy the war file in the deployment directory.
The Deployment Scanner scans the deployment location and deploys new wars or any updates done to existing applications.

If we need to disable this , go to /standalone/configuration/standalone.xml file

Remove <extension module="org.jboss.as.deployment-scanner"/> and then remove the:

<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
<deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" auto-deploy-zipped="false" auto-deploy-exploded="false"/>
</subsystem>

If you don't want to remove the subsystem, add auto-deploy-zipped="false" and auto-deploy-exploded="false" to the <deployment-scanner/> tag.
If we need to add a external location we can add

<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.0">
<deployment-scanner scan-interval="5000" relative-to="jboss.server.base.dir" path="deployments" />
<deployment-scanner name="my-external-deployment-scanner" path="/home/jpai/as7/deployments" scan-interval="5000" />
</subsystem>


Precompile JSP Pages

We can precompile the jsp page by passing jsp_precompile=true in the parameter. For example if you want to precompile the abc.jsp running on localhost, you have to do http://localhost:80/abc.jsp?jsp_precompile=true this will only precompile the jsp and will not execute it.

JBoss CLI Batch Mode
We can use the batch command available with jboss-cli to perform batch mode commands like

[root@vx111a bin]# ./jboss-cli.sh
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /] connect
[standalone@localhost:9999 /] batch
[standalone@localhost:9999 / #] deploy /root/Downloads/NewFolder/myApp.war
#1 deploy /root/Downloads/NewFolder/myApp.war
[standalone@localhost:9999 / #] run-batch
The batch executed successfully

The commands that are entered after the “batch” command will be executed all at once we run the 'run-batch' command.

Exit the batch edit mode without losing your changes:

[standalone@localhost:9999 / #] holdback-batch
[standalone@localhost:9999 /]
Then activate it later on again:

[standalone@localhost:9999 /] batch
Re-activated batch
#1 deploy /root/Downloads/NewFolder/myApp.war

There are several other notable batch commands available like
clear-batch
edit-batch-line (e.g. edit-batch line 3 create-jms-topic name=mytopic)
remove-batch-line (e.g. remove-batch-line 3)
move-batch-line (e.g. move-batch-line 3 1)
discard-batch

Happy Learning :-)