complete tutorial to jboss as service on raspberry pi

Version 2

    JBOSS on raspberry pi

    Configuration jboss na raspiane


    • downloda jboss and extract to /usr/jboss


    sudo tar xzfC /usr/jboss/ [path/to/archive]/jboss-as-7.1.1.Final.tar.gz
    


    • install java openJDK


    sudo apt-get install openjdk-7-jre
    


    • Test java


    /usr/lib/jvm/java-1.7.0-openjdk-armhf/bin/java -version
    

     

    Output:

    java version "1.7.0_07"
    OpenJDK Runtime Environment (IcedTea7 2.3.2) (7u7-2.3.2a-1+rpi1)
    OpenJDK Zero VM (build 22.0-b10, mixed mode)
    


    • open bashrc and at end append
    vi ~/.bashrc
    export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-armhf
    export PATH=$JAVA_HOME/bin:$PATH
    export JBOSS_HOME=/usr/jboss/jboss-as-7.1.1.Final
    export PATH=$JBOSS_HOME/bin:$PATH
    


    • Restart console and test
    echo $JBOSS_HOME
    echo $JAVA_HOME
    vystup:
    /usr/jboss/jboss-as-7.1.1.Final
    /usr/lib/jvm/java-1.7.0-openjdk-armhf
    


    • We need to create new user and new group named  jboss. Make them owner of your JBoss stuff.
    addgroup jboss
    useradd -g jboss jboss
    chown -R jboss:jboss /usr/local/jboss-7.0.2/
    


    • standalone.xml or standalone-full.xml (jboss_home/standalone/configurations/)
    <interfaces>
    <interface name="management">
    <inet-address value="${jboss.bind.address.management:0.0.0.0}
    "/>
    </interface>
    <interface name="public">
    <inet-address value="${jboss.bind.address:0.0.0.0}"/>
    </interface>
    <interface name="unsecure">
    <inet-address value="${jboss.bind.address.unsecure:0.0.0.0}"/
    >
    </interface>
    </interfaces>
    


    • Datasource mysql
    <datasource jndi-name="java:jboss/datasources/MySqlDS" po
    ol-name="MySqlDS" enabled="true">
    <connection-url>jdbc:mysql://jbase.dyndns-free.com:33
    06/pers_test</connection-url>
    <driver>com.mysql</driver>
    <transaction-isolation>TRANSACTION_READ_COMMITTED</tr
    ansaction-isolation>
    <pool>
    <min-pool-size>10</min-pool-size>
    <max-pool-size>100</max-pool-size>
    <prefill>true</prefill>
    </pool>
    <security>
    <user-name>root</user-name>
    <password>satelit.01</password>
    </security>
    <statement>
    <prepared-statement-cache-size>32</prepared-state
    ment-cache-size>
    <share-prepared-statements>true</share-prepared-s
    tatements>
    </statement>
    </datasource>
    

     

    <xa-datasource jndi-name="java:jboss/datasources/MySqlXADS" pool-name="MySqlXADS" enabled="true" use-ccm="false">
    <xa-datasource-property name="ServerName">
    localhost
    </xa-datasource-property>
    <xa-datasource-property name="DatabaseName">
    easymenu
    </xa-datasource-property>
    <xa-datasource-property name="User">
    root
    </xa-datasource-property>
    <xa-datasource-property name="Password">
    satelit.01
    </xa-datasource-property>
    <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.My
    sqlXADataSource</xa-datasource-class>
    <driver>com.mysql</driver>
    <xa-pool>
    <is-same-rm-override>false</is-same-rm-override>
    <interleaving>false</interleaving>
    <pad-xid>false</pad-xid>
    <wrap-xa-resource>false</wrap-xa-resource>
    </xa-pool>
    <security>
    <user-name>root</user-name>
    <password>satelit.01</password>
    </security>
    <validation>
    <validate-on-match>false</validate-on-match>
    <background-validation>false</background-validati
    on>
    </validation>
    <statement>
    <share-prepared-statements>false</share-preparedstatements>
    </statement>
    </xa-datasource>
    

     

    <drivers>
    <driver name="com.mysql" module="com.mysql">
    <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
    </xa-datasource-class>
    </driver>
    <driver name="h2" module="com.h2database.h2">
    <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
    </driver>
    </drivers>
    


    • Create script, set up rights, make dirs and link /etc/init.d/jbossas7 to etc/rc.d....
    sudo touch /etc/init.d/jbossas7
    chmod +x /etc/rc.d/init.d/jbossas7
    sudo mkdir /etc/rc.d
    sudo mkdir /etc/rc.d/init.d
    sudo ln -s /etc/rc.d/init.d/jbossas7 /etc/init.d/jbossas7
    


    • To /etc/init.d/jbossas7 insert
    #!/bin/sh
    ### BEGIN INIT INFO
    # Provides: jboss
    # Required-Start: $local_fs $remote_fs $network $syslog
    # Required-Stop: $local_fs $remote_fs $network $syslog
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Management of JBoss AS v7.x
    ### END INIT INFO
    #Defining JBOSS_HOME
    JBOSS_HOME=/usr/jboss/jboss-as-7.1.1.Final/
    case "$1"
    in
    start)
    echo "Starting JBoss AS7..."
    sudo -u jboss sh ${JBOSS_HOME}/bin/standalone.sh &
    ;;
    stop)
    echo "Stopping JBoss AS7..."
    sudo sh ${JBOSS_HOME}/bin/jboss-cli.sh --connect command=:shutdown
    ;;
    log)
    echo "Showing server.log..."
    tail -1000f ${JBOSS_HOME}/standalone/log/server.log
    ;;
    *)
    echo "Usage: /etc/init.d/jboss {start|stop|log}"
    exit 1
    ;; esac
    exit 0
    

     

    • Create links to it from respective runlevel dirs
    sudo apt-get install chkconfig
    cd /etc/init.d/
    sudo chkconfig --add jbossas7
    



    • commands
    service jbossas7 start
    service jbossas7 stop
    service jbossas7 log
    

     

    help referencies (thanks)

     

    https://community.jboss.org/wiki/HowToInstallJBossAS7AsALinuxService
    
    http://alexander.holbreich.org/2011/11/jboss-7-setup-linux/
    
    http://blog.oliver-mueller.com/-135