Setup WildFly 11.0 on the Pi


Install Java and WildFly

https://prabg.wordpress.com/2018/04/07/jboss-wildfly-as-setup-on-raspberry-pi-3/

You'll need
Linux ARM 32 Hard Float ABI (32 bit JDK 8)
and
WildFly 11.0

Considering that we're installing the server to run with JDK 8 32-bit, you should also develop your REST API with the 32-bit JDK 8

  1. Copy via FileZila the WildFly 11.0 zip and the ARM jdk 1.8.2 tar.gz to the Pi's desktop
  2. On the Pi, navigate to the Desktop and rename both files to wildfly_11.zip and jdk_1.8.2.tar.gz
  3. Extract both files to the /opt directory and check the contents of /opt:
        
    $ sudo unzip ~/Desktop/wildfly_11.zip -d /opt
    
    $ sudo tar -xzvf ~/Desktop/jdk_1.8.2.tar.gz -C /opt
    
    $ cd /opt
    $ ls
        
  4. Navigate to the /home directory and open .bashrc with gedit...
    
    $ cd ~    
    $ sudo gedit .bashrc    
        
    ...and add the following code to the end of the file:
    make sure the paths match the directories you just listed
    
    export JAVA_HOME=/opt/jdk1.8.0_221
    export JBOSS_HOME=/opt/wildfly-11.0.0.Final
    export PATH=$JAVA_HOME/bin:$PATH
        
  5. Save and close gedit
  6. Run the following command to refresh the PATH
    
    $ source ~/.bashrc 
        
  7. Test that Java was installed correctly by running the following command:
    
    $ java -version    
        
    It should display the following:
    
    Java(TM) SE Runtime Environment (build 1.8.0_221-bll)
    ...    
    
  8. Start the WildFly server by running this script:
    
    $ cd $JBOSS_HOME
    $ sudo ./bin/standalone.sh
        
  9. If you need to change the port that WildFly is using edit the
    $JBOSS_HOME/standalone/configuration/standalone.xml file
  10. Open your browser and navigate to localhost:8080 (or whichever port you specified)
    If the WildFly page opens, your server is running

Start the Server on Boot

Optional
  1. Create a shell script that starts the server:
    
    $ cd /etc/systemd/system
    
    $ sudo touch server_startup.sh
    
    $ sudo gedit server_startup.sh    
        
    ...and add the following:
    
    #!/bin/sh#
    source ~/.bashrc
    source $JAVA_HOME
    source $JBOSS_HOME
    
    # Start the WildFly server
    $JBOSS_HOME/bin/standalone.sh    
        
    Save the file and quit gedit
  2. Create a service that runs on boot:
    
    $ sudo touch server_startup.service
    
    $ sudo gedit server_startup.service
        
    ...and add the following:
    
    [Unit]Description=JBOSS startup script[Service]
    
    ExecStart=/usr/local/etc/server_startup.sh    
    
    [Install]
    
    WantedBy=multi-user.target
        

Add a User

You'll have to setup a user to be able to access the WildFly administration page

  1. Navigate to $JBOSS_HOME/bin and run the add-user.sh shell script:
    
    $ cd $JBOSS_HOME/bin
      
    $ sudo ./add-user.sh
        
  2. The script will prompt you for the type of user you'd like to create - Management or Application
    Choose Management User
  3. Choose a Username - we'll use admin
    though you'd probably want to choose something more secure
  4. Choose a Password and re-enter it
  5. The script will prompt you to join groups - simply hit Enter
  6. The script will ask for your confirmation - type yes to confirm
  7. The script will ask if the user will be used to connect accross the application server processes - type no
  8. Open your browser and navigate to localhost:8080 (or whichever port you specified)
    Click the link Administration Console and type in the user credentials you just set up
  9. From here you can Deploy Applications, Monitor the Server, Configure Settings, and Manage User Permissions

Enable Remote Access

By default, WildFly 11 is setup to only allow local access. To enable remote access, navigate to the configuration directory and edit the standalone.xml file:


$ cd $JBOSS_HOME/standalone/configuration

$ sudo gedit standalone.xml  
  
Locate the part of the file that defines the interface -> address and change it from this:

<interface name="management">
   	<inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
<interface />  
<interface name="public">
   	<inet-address value="${jboss.bind.address:0.0.0.0}"/>
<interface />    
...to this:

<interface name="management">
   	<any-address />
<interface />  
<interface name="public">
   	<any-address />
<interface />  
  

Save your changes and restart WildFly