Category Archives: jboss

profile remote host jboss7 with jprofiler

local machine
– create ssh tunnel : ssh -L 8849:127.0.0.1:8849 remoteuser@remotehost
– launch jprofiler : e.g. /mnt/jprofiler7/bin/jprofiler
– new session -> remote host -> enter host 127.0.0.1 as port 8849 -> save session (don’t start session you must accomplish remote host configuration and restart server before)

remote host (linux x64)
– install(unzip) jprofiler in any folder in remote host file system : e.g. /opt/jprofiler
– edit $JBOSS_HOME/bin/standlaone.sh and add following (this will launch jprofiler agent uppon jboss server. jprofiler agent will listen on port 8849)

– restart jboss server

local machine
– start jprofiler saved session

That’s all

Jboss7 (jboss-cli) : how to redirect specified class log in specified file

Don’t edit standalone.xml and then restart jboss, just use jboss-cli commands. Only three steps are enough

1. Add a file log handler

/subsystem=logging/file-handler=HANDLER_NAME:add(file={“path”=>”FILE_NAME“,”relative-to”=>”jboss.server.log.dir”},level=”LEVEL“)

2. Add a log category

/subsystem=logging/logger=CATEGORY_NAME:add(level=”LEVEL“)

3. Add a log handlers to a log category

/subsystem=logging/logger=CATEGORY_NAME:assign-handler(name=”HANDLER_NAME“)

done…

By example : We have to redirect net.witr.MyClass info logs to witr.log file

Jboss7 : useful jboss-cli commands

jboss7 offer jboss-cli (command line interface) which makes live easier for administrators.

First of all connect to jboss-cli as following

connect to jboss-cli : connect

Then, here some useful jboss-cli commands

undeploy and redeploy artifacts : deploy/undeploy

list already deployed artifacts : deploy -l

handle log levels : /subsystem=logging

Add new log level “INFO” on class net.witr.home.Himmel

Change log level of class net.witr.home.Himmel to “DEBUG”

Remove log level of class net.witr.home.Himmel

handle system properties : /system-property
Add, read and remove system property witrActive

ajax displaying jboss server state

We aim to have web page which displays continually three jboss7 servers states.
For this we need the shell script (status.sh) to be found here.

environment requirement

    servers in same machine :
  • apache server
  • three jboss7 servers: jboss1, jboss2, jboss3

get result of status.sh in our php file

Following php code displays one jboss server state

For our example we need three php files containing the previous one line php code corresponding to each one of the three jboss server : state-jboss1.php, state-jboss2.php, and state-jboss3.php

ajax state display

We need here the load() method of jquery javascript framework.

continuous update of servers state

We’ll resort to javascript timer

deloyment

    root folder :
  • create folder jboss-state in apache server root www
    files :
  • www/jboss-state/status.sh
  • www/jboss-state/index.html
  • www/jboss-state/state-jboss1.php
  • www/jboss-state/state-jboss2.php
  • www/jboss-state/state-jboss3.php

full code

status.sh (myArtifactName string in code must be replaced by the right artifact name)

state-jboss1.php

state-jboss2.php

state-jboss3.php

index.html

get jboss7 server state with shell script

Shell script (status.sh) bellow returns three jboss server state :

  • STOPPED : jboss is stopped (script could not connect with jboss-cli)
  • STARTING : jboss is starting (its state is running but project is not deployed)
  • RUNNING : jboss is ready (its state is running and project is deployed successfully)

Use :


> ./status.sh /path/to/jbossHome

This script may be improved …
Also you need to replace in code myArtifactName fake value by your right value

secure jboss7 with ssl (https)

1. create keystore certificate for jboss user
> keytool -genkey -alias jboss -keyalg RSA

2. edit jboss configuration file standalone.xml:
– in interfaces : add new interface “local”

– in socket binding : add new socket binding “httpLocal” listening on localhost with http

– remove http connector :
<connector name=”http” protocol=”HTTP/1.1″ scheme=”http” socket-binding=”http”/>

– add local http connector (for modules having to communicate in http with each others)

<connector name=”http” protocol=”HTTP/1.1″ scheme=”http” socket-binding=”httpLocal”/>

– add new https connector

            <connector name=”https” protocol=”HTTP/1.1″ scheme=”https” socket-binding=”https” secure=”true”>
              <ssl password=”password typed in step 1″ />
            </connector>

in subsystem web we must finally have :

allow remote debug for jboss7


=========================================== 27/05/2013
allow remote debug for jboss7
(https://community.jboss.org/thread/175385)
1. Check the standalone.conf (or standalone.conf.bat for Windows OS) and uncomment the following line:
#JAVA_OPTS=”$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n”

setup hsqldb with jboss7

jboss7 comes with h2 already installed and setup.
For hsqldb, just take h2 setup as example.

Following steps helps to setup hsqldb with jboss7.

A. create new jboss7 module: hsqldb module

1. first create directory $JBOSS_HOME/modules/org/hsqldb/main

2. download hsqldb and put the hsqldb.jar into created directory main
3. create into main directory following module.xml file (assuming hsqldb jar is hsqldb-x.x.x.jar)

B. setup hsqldb datasource

1. add hsql driver by editing $JBOSS_HOME/standalone/configuration/standalone.xml (locate drivers in standalone.xml file)

2. finally add hsqldb datasource in $JBOSS_HOME/standalone/configuration/standalone.xml (locate datasources in the file)
we consider a file hsqldb database created into /home/hsqldb/data/witrHsqldb

jrebel/eclipse/remote jbossAS server step by step


April 19, 2013

install jrebel with eclipse:
– get licence from jrebel web site
– install jrebel eclipse plugin. Restart eclipse and activate you licence
– in jrebel config center : select one projet in projects panel, and enter in corresponding “deployment URL” field your jboss7 server url (example http://myserver:8080)
   you will have “Server responded with an error: null”, don’t worry, this because server was not yet configured to respond to remote requests
– now compile and package your project and then put it in your server jboss.

install jrebel under jboss7
– copy “C:UsersYOURHOME.jrebeljrebel.lic” et “C:UsersYOURHOME.jrebeljrebel.properties” to the home of your server user launching jboss : /home/user_launchig_jboss/.jrebel/
– get jrebel.jar from jrebel web site and put it in your host machine
– add following in the script launching jboss7 before call standalone.sh :
export JAVA_OPTS=”$JAVA_OPTS -javaagent:/path/to/jrebel.jar -Drebel.log.file=$JBOSS_HOME/standalone/log/jrebel.log -Drebel.remoting_plugin=true”
– start server jboss7
=============================
if you have following error : Server responded with an error: null ==> this because remoting is not enabled in jrebel java agent : add  -Drebel.remoting_plugin=true in java_opts
if you have following error : Server responded with an error: Remoting module’navco-module-delegal-postes-pm’ was not found ==> redeploy your project in jboss7 (jrebel remoting needs the rebel-remote.xml)