Skip to content

Instantly share code, notes, and snippets.

@ejlp12
Last active November 23, 2015 03:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ejlp12/8c59befac8c3bae4277e to your computer and use it in GitHub Desktop.
Save ejlp12/8c59befac8c3bae4277e to your computer and use it in GitHub Desktop.
Create a simple Java EE Web App Sample and deploy to JBoss cluster

Create simple Java EE Web Application Maven project in directory ~/playground/

cd ~/playground

mvn archetype:generate -DgroupId=ejlp12.jee6 \
 -DartifactId=HelloWebApp \
 -DarchetypeArtifactId=maven-archetype-webapp \
 -DinteractiveMode=false \
 -Dmaven.repo.remote=https://repository.apache.org/content/groups/public/
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Batch mode
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-webapp:1.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: basedir, Value: /Users/ejlp12/playground
[INFO] Parameter: package, Value: ejlp12.jee6
[INFO] Parameter: groupId, Value: ejlp12.jee6
[INFO] Parameter: artifactId, Value: HelloWebApp
[INFO] Parameter: packageName, Value: ejlp12.jee6
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: /Users/ejlp12/playground/HelloWebApp
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 27.515 s
[INFO] Finished at: 2015-11-23T07:50:01+07:00
[INFO] Final Memory: 16M/220M
[INFO] ------------------------------------------------------------------------

Build and create a WAR file from the project.

cd HelloWebApp/
mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building HelloWebApp Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ HelloWebApp ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ HelloWebApp ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ HelloWebApp ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/ejlp12/playground/HelloWebApp/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ HelloWebApp ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ HelloWebApp ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) @ HelloWebApp ---
[INFO] Packaging webapp
[INFO] Assembling webapp [HelloWebApp] in [/Users/ejlp12/playground/HelloWebApp/target/HelloWebApp]
[INFO] Processing war project
[INFO] Copying webapp resources [/Users/ejlp12/playground/HelloWebApp/src/main/webapp]
[INFO] Webapp assembled in [165 msecs]
[INFO] Building war: /Users/ejlp12/playground/HelloWebApp/target/HelloWebApp.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.275 s
[INFO] Finished at: 2015-11-23T07:52:33+07:00
[INFO] Final Memory: 11M/155M
[INFO] ------------------------------------------------------------------------

Get info of all server group in the JBoss EAP domain. This command should be run in the Domain Contoller with management port is running on 9999 (Not the port used by web UI admin console):

/Servers/EAP-6.4/bin/jboss-cli.sh -c --controller=localhost:9999 "ls /server-group"
main-server-group
other-server-group

Deploy WAR to one of the server group e.g. other-server-group:

/Servers/EAP-6.4/bin/jboss-cli.sh -c --controller=localhost:9999 "deploy ~/playground/HelloWebApp/target/HelloWebApp.war --server-groups=other-server-group"

If you already setup an HTTP server with mod_cluster as a load balancer then access:

http://localhost/HelloWebApp/

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment