Simple Blog System made for the Softuni Java EE Course.
MySql Server
Java EE Server(Wildfly)
Maven
Provision the Database
: Star MySql and execute 'provisioning/full_db_provisioning.sql' to create the initial 'blog' database and execute the queries in full_db_provisioning.sql fileConfigure Wildfly
: Create 'mysql' folder inside 'wildfly/modules/system/layers/base/'Configure Wildfly
: Create 'driver' folder inside 'wildfly/modules/system/layers/base/mysql/'Configure Wildfly
: Add JDBC driver to Wildfly. Download Mysql JDBC Driver and copy the jar file into 'wildfly/modules/system/layers/base/mysql/Configure WildFly
: Create module.xml configuration file in with the following commands:
C:\User\wildfly-10.1.0.Final\bin>jboss-cli.bat
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:9990 /] module add --name=com.mysql.driver --dependencies=javax.api,javax.transaction.api --resources=/PATH/TO/mysql-connector-java.jar
[standalone@localhost:9990 /] :reload
{
"outcome" => "success",
"result" => undefined
}
replace 'mysql-connector-java.jar' with the filename of the JDBC jar file.
Configure Wildfly
: Add your driver in Wildfly configuration in 'wildfly/standalone/configuration/standalone.xml' add inside the already existing 'drivers' tag the following datasource:
<driver name="mysql" module="com.mysql.driver">
<driver-class>com.mysql.jdbc.Driver</driver-class>
</driver>
Configure Wildfly
: Add your database as Datasource in Wildfly configuration in 'wildfly/standalone/configuration/standalone.xml' add inside the already existing 'datasources' tag the following datasource:
<datasource jta="true" jndi-name="java:/SoftUniDS" pool-name="SoftUniDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/blog?characterEncoding=utf8</connection-url>
<driver>mysql</driver>
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>30</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>root</user-name>
</security>
</datasource>
If you do not use the default mysql credentials edit the 'security' tag with the proper credentials
install required dependencies
: In the directory "provisioning/lib/" execute:
mvn install:install-file -DgroupId=javax.transaction -DartifactId=jta -Dversion=1.0.1B -Dpackaging=jar -Dfile=jta-1.0.1B.jar
Provision the Blog
: In the parent directory run 'mvn install' to provision the application using Maven.Add the Project to WildFly
: Copy the created 'SoftUniJEE/target/SoftUniJEE-0.0.1-SNAPSHOT.ear' into wildfly/standalone/deployments/Run Wildfly
: execute '/wildfly/bin/standalone.sh' scriptBrowse the App
: 'http://localhost:8080/'
Run with docker:
install required dependencies
: In the directory "provisioning/lib/" execute:
mvn install:install-file -DgroupId=javax.transaction -DartifactId=jta -Dversion=1.0.1B -Dpackaging=jar -Dfile=jta-1.0.1B.jar
Provision the Blog
: In the parent directory run 'mvn install' to provision the application using Maven.Setup the ear
: Copy the created 'SoftUniJEE/target/SoftUniJEE-0.0.1-SNAPSHOT.ear' into "provisioning/docker/customization"Build docker image
: execute "docker build . -t gapostolov/java-ee-blog" in "provisioning/docker/" directoryStart Application
: execute "docker-compose up -d" in "provisioning/docker/" directoryBrowse the App
: 'http://localhost:8080/'
Run with docker:
install required dependencies
: In the directory "provisioning/lib/" execute:
mvn install:install-file -DgroupId=javax.transaction -DartifactId=jta -Dversion=1.0.1B -Dpackaging=jar -Dfile=jta-1.0.1B.jar
Provision the Blog
: In the parent directory run 'mvn install' to provision the application using Maven.Setup the ear
: Copy the created 'SoftUniJEE/target/SoftUniJEE-0.0.1-SNAPSHOT.ear' into "provisioning/docker/customization"Build docker image
: execute "docker build . -t gapostolov/java-ee-blog" in "provisioning/docker/" directoryStart Application
: execute "docker-compose up -d" in "provisioning/docker/" directoryBrowse the App
: 'http://localhost:8080/'
Run on AWS:
Setup AWS EC2
: Create two ubuntu 16 Xenial machines with EIPs and install Python inside of them(required by ansible)Setup AWS RDS
: Create a new MySql instance with database name "blog" then provision it with provisioning scripts in "/provisioning/full_db_provisioning.sql"Edit Docker-Compose file
: Edit docker compose file with proper Database variables from RDS InstanceEdit Ansible Hosts file
: edit ansible hosts files with new EIPs of EC2 machines "host_vars/dev-docker-01.yml" and "host_vars/dev-docker-02.yml"Configure Machines
: execute "ansible-playbook docker-infrastructure.yml -i ./inventory/dev-docker --key-file="Deploy docker stack
: execute "docker stack deploy -c ./provisioning/docker/docker-compose-aws.yml blog"Browse the App
: browse dev-docker-02 ip on port 80
Setup AWS Infrastructure with CloudFormation and Ansible:
Configure Ansible inventory
: Setup aws region in /inventory/ec2.iniConfigure Ansible
: Setup ansible to use dynamic inventory executing "export ANSIBLE_HOSTS=./inventory/aws_dynamic.py" in "/ansible" directory
Helpfull commands: ws cloudformation create-stack --stack-name blog-ee-simpljdava3 --template-body file://../provisioning/cloudformation/infrastructure.yml ansible -m ping tag_Name_docker_master --key-file ../../../aws-SA/exploitx/Exploitx.pem ./inventory/aws_dynamic.py --refresh-cache
/opt/apache-maven-3.3.9 Java version: 1.8.0_65, vendor: Oracle Corporation
- Wildfly - The Java EE application server used(Wildfly 10.1.0 with Java 1.8)
- Maven - Dependency Management(Maven-3.3.9)
- MySql - The database used (MySql Ver 14.14 Distrib 5.6.30)
- Hibernate - Java persistence framework for powerful object relational mapping and query databases using HQL and SQL(version in maven dependencies)
- JSF - Java specification for building component-based user interfaces for web applications(JSF 2)
- PrimeFaces - User interface (UI) component library for JavaServer Faces (JSF) based applications.(version in maven dependencies)