0

I am trying to setup AWS for a JBoss WildFly 31.0.0.Final to get a demo webapp up and running. So I found this tutorial:

https://kamalmeet.com/cloud-computing/amazon-ec2-step-by-step-guide-to-setup-a-java-application/

I created a ubuntu instance, along with a keypair set to read-only and manually changed some properties for the PEM file on my local Windows 11 machine. I then connected to my Ubuntu instance with my SSH shell as AWS default user named ubuntu.

I ended up with:


enter image description here


(I know it might not be the smartest move to post this screenshot, but for the sake of this question, I will repeat the whole process once this gets solved...)

So, I then pretty much copy-pasted the commands listed in the tutorial, with some "minor" adjustments like apt upgrade and the installation of Java 17 + JDK 17:

sudo apt update
sudo apt upgrade

sudo apt install openjdk-17-jdk openjdk-17-jre

Here I issued java -version saying:

openjdk version "17.0.9" 2023-10-17
OpenJDK Runtime Environment (build 17.0.9+9-Ubuntu-122.04)
OpenJDK 64-Bit Server VM (build 17.0.9+9-Ubuntu-122.04, mixed mode, sharing)

Now add user and group wildfly:

sudo groupadd -r wildfly
sudo useradd -r -g wildfly -d /opt/wildfly -s /sbin/nologin wildfly

Grab the latest WildFly, unzip/untar it, put it into /opt/ and create a symlink into /opt/wildfly/ to point to the actual dir.

wget https://github.com/wildfly/wildfly/releases/download/31.0.0.Final/wildfly-31.0.0.Final.tar.gz -P /tmp
sudo tar xf /tmp/wildfly-31.0.0.Final.tar.gz -C /opt/
sudo ln -s /opt/wildfly-31.0.0.Final /opt/wildfly
sudo chown -RH wildfly: /opt/wildfly

Now create a dir where the WildFly config wildfly.conf is placed:

sudo mkdir -p /etc/wildfly

sudo cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.conf /etc/wildfly/
sudo nano /etc/wildfly/wildfly.conf

The file wildfly.conf you never needed or even noticed during development on your local machine looks like this:

# The configuration you want to run
WILDFLY_CONFIG=standalone.xml

# The mode you want to run
WILDFLY_MODE=standalone

# The address to bind to
WILDFLY_BIND=0.0.0.0

I wondered what to edit here. I left it as is, making the standalone.xml being used. Bind address: IIRC 0.0.0.0 is the broadcast address, so WildFly accepts requests from anywhere in the world (??).

Now copy the file launch.sh to the WildFly bin dir and make all *.sh scripts there executable:

sudo cp /opt/wildfly/docs/contrib/scripts/systemd/launch.sh /opt/wildfly/bin/
sudo sh -c "chmod +x /opt/wildfly/bin/*.sh"

The file launch.sh looks like this:

if [ "x$WILDFLY_HOME" = "x" ]; then
    WILDFLY_HOME="/opt/wildfly"
fi

if [[ "$1" == "domain" ]]; then
    $WILDFLY_HOME/bin/domain.sh -c $2 -b $3
else
    $WILDFLY_HOME/bin/standalone.sh -c $2 -b $3
fi

That WildFly contrib script pretty much looks for the WILDFLY_HOME env var and if it is not set, assume /opt/wildfly as home, resulting in /opt/wildfly/bin/standalone.sh being executed when launch.sh is.

Now config the launcher (note, I have absolutely basic Ubuntu knowledge). From what I read, the dir /etc/systemd/system/ in Ubuntu is a more modern approach where to manage the services and sessions (to get rid of the rather old-fashioned init.d stuff AFAI understand). So we copy another WildFly contrib script to /etc/systemd/system/:

sudo cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.service /etc/systemd/system/

The wildfly.service looks like this:

[Unit]
Description=The WildFly Application Server
After=syslog.target network.target
Before=httpd.service

[Service]
Environment=LAUNCH_JBOSS_IN_BACKGROUND=1
EnvironmentFile=-/etc/wildfly/wildfly.conf
User=wildfly
LimitNOFILE=102642
PIDFile=/run/wildfly/wildfly.pid
ExecStart=/opt/wildfly/bin/launch.sh $WILDFLY_MODE $WILDFLY_CONFIG $WILDFLY_BIND
StandardOutput=null

[Install]
WantedBy=multi-user.target

So here you can see that this service file picks up the config from /etc/wildfly/wildfly.conf and that it actually executes /opt/wildfly/bin/launch.sh (this is where other env vars come into place that haven't been set at all).

The next command seem to tell Ubuntu to reload the service config (deamons) and start + enable JBoss WildFly:

sudo systemctl daemon-reload
sudo systemctl start wildfly
sudo systemctl enable wildfly

Issuing a final sudo systemctl status wildfly gives:

ubuntu@ip-172-31-19-16:~$ sudo systemctl daemon-reload
ubuntu@ip-172-31-19-16:~$ sudo systemctl start wildfly
ubuntu@ip-172-31-19-16:~$ sudo systemctl enable wildfly
ubuntu@ip-172-31-19-16:~$ sudo systemctl status wildfly
● wildfly.service - The WildFly Application Server
     Loaded: loaded (/etc/systemd/system/wildfly.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2024-02-05 10:19:39 UTC; 16s ago
   Main PID: 22971 (launch.sh)
      Tasks: 127 (limit: 1121)
     Memory: 386.1M
        CPU: 15.964s
     CGroup: /system.slice/wildfly.service
             ├─22971 /bin/bash /opt/wildfly/bin/launch.sh standalone standalone.xml 0.0.0.0
             ├─22972 /bin/sh /opt/wildfly/bin/standalone.sh -c standalone.xml -b 0.0.0.0
             └─23093 java "-D[Standalone]" "-Djdk.serialFilter=maxbytes=10485760;maxdepth=128;maxarray=100000;maxrefs=300000" -Xms64m -Xmx512m -XX:Metaspac>

The last command is:

sudo ufw allow 8080/tcp

It's called "Uncomplicated Firewall" and seems like it is installed on most Ubuntu and Debian systems. It obviously opens port 8080 to the outside world.

QUESTION:

Whatever I do after all this, opening a browser to the public IP given + port, I simply cannot access the WildFly I just set up:

enter image description here

The above error message means "The connection has timed out".

So, what am I doing wrong here? Is AWS blocking port 8080 from outside? Is using HTTP disallowed at all?

3
  • 2
    What do you need ufw for? Why noe to use AWS security group instead? Commented Feb 5, 2024 at 11:09
  • 1
    Hmm. I tried this. I noticed this in the AWS console, but the UI won't let me add 8080 as port. This didn't work, but does now. I feel really stupid. THANKS. Please post this as an answer: add port to Security Group -> tab Inbound rules -> Edit inbound rules -> and Add rule use Type Custom TCP + Port range 8080 + Anywhere IPv4 or use CIDR 0.0.0.0/0 and restart the instance. Commented Feb 5, 2024 at 11:27
  • AWS doesn't restrict protocols. Most likely you've got something not set up correctly. Common things would be a security group rule or NACL blocking access, no internet gateway, subnet not routed correctly, etc. Try connecting to port 8080 from the instance, if that works then it's AWS infrastructure rather than instance settings. You would have to post more detail for more help, security groups, NACLs, subnets, routing, etc. Commented Feb 5, 2024 at 21:19

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.