Proving ground for J2EE 7 RESTful web services. Jersey will provide grunt for REST. Jetty local development but Tomcat for Integration testing. Maven build framework with Jenkins organising. If that is not enough then SonarQube and Jacoco for code coverage.
-
If you just want to play with and extend the JAX-RS REST hello world example then install Developer Tools, download sources and go have fun
-
If you want to have fun with Jenkins 2.x Pipeline then install Deployment Pipeline tools.
-
If you want to have fun with Jenkins 2.x Pipeline Jenkinsfile or Zero-downtime Deployment (and Rollback) in Tomcat then you need:
- to fork this repository to edit your Jenkinsfile
- the Developer tools
- the Deployment tools
-
This plaground was setup in July 2016
-
Please do send me fixes for my stupid errors.
-
I did not automate the install of Deployment Pipeline tools. Vagrant and Puppet poc work has been covered in my other projects.
Once you have the sources downloaded and developer tools setup execute the follow to compile and run on Jetty for local development
mvn clean compile jetty:run
NOTE: For hot reload to work, Eclipse->Project->Build Automatically should be enabled
The helloworld REST service will be availabe on:
and the default index.jsp will respond on:
To do a SonarQube analysis use:
mvn clean test sonar:sonar
And to build a distribution package:
mvn clean package
- JDK 8u91
- Github Desktop
- Java Platform, Enterprise Edition (Java EE) 7 - RESTful Web Services with JAX-RS
- Jersey, 2.23.1
- Apache Maven, 3.3.9
- Eclipse - Java EE Developers, Neon
The following tools are used in my hello world deployment pipeline:
- JDK 8u91
- Git Client
- Apache Maven, 3.3.9
- Apache Tomcat, 8.5.4
- Jenkins, 2.15
- Nexus, 3.01
- SonarQube, 5.6.1
I use the following custom launcher scripts for the tools:
- F:\Apps\Nexus\NexusRunner.cmd
- F:\Apps\SonarQube\sonarqube-5.6.1\bin\windows-x86-64\StartSonar.bat
- F:\Apps\Tomcat\TomcatRunner.cmd
- F:\Apps\Jenkins\JenkinsRunner.cmd
Applications use their default ports hence are available on:
Applications are used as is except for Jenkins which needs to be informed of where tools are located:
- JDK
- Maven
- Use M3 as maven client name
- Git Client
You need to configure at least one job in jenkins! I have two. One for inline pipeline script and one reading pipeline script from source code control
Once everything is configured, build and deploy war files to tomcat via your jenkins job(s). The app will be available on:
And Jenkins jobs on:
- http://localhost:9090/job/HelloWorldJenkinsfile/workflow-stage
- http://localhost:9090/job/HelloWorldPipeline/workflow-stage
Jenkins Pipeline Syntax Snippet Generator
- http://martinfowler.com/articles/richardsonMaturityModel.html
- https://spring.io/understanding/HATEOAS
- http://restcookbook.com/Miscellaneous/rest-and-http
- http://restcookbook.com/Mediatypes/json
- https://www.ibm.com/developerworks/library/wa-aj-tomcat
- http://www.vogella.com/tutorials/REST/article.html
- https://jersey.java.net/documentation/latest/modules-and-dependencies.html
- https://jersey.java.net/documentation/latest/deployment.html#deployment.servlet
- https://github.com/jersey/jersey/tree/master/examples/servlet3-webapp
- https://github.com/jersey/jersey/blob/master/examples/java8-webapp
- https://philsturgeon.uk/api/2016/01/04/http-rest-api-file-uploads
- https://javatutorial.net/java-file-upload-rest-service
- https://jersey.java.net/documentation/latest/user-guide.html#multipart
- http://howtodoinjava.com/jersey/jersey-file-upload-example
- http://www.mkyong.com/webservices/jax-rs/file-upload-example-in-jersey
- https://jersey.java.net/documentation/latest/test-framework.html
- http://memorynotfound.com/test-jersey-rest-service-with-junit
- http://www.logicbig.com/tutorials/java-ee-tutorial/jax-rs
- http://www.logicbig.com/tutorials/java-ee-tutorial/jax-rs/jax-rs-unit-testing
- https://jersey.java.net/apidocs/2.23.1/jersey/org/glassfish/jersey/test/external/ExternalTestContainerFactory.html
- http://www.sonarqube.org/measure-coverage-by-integration-tests-with-sonar-updated
- http://www.eclemma.org/jacoco/trunk/doc/agent.html
- https://www.javacodegeeks.com/2011/06/zero-downtime-deployment-and-rollback.html
- http://maven.apache.org/guides/introduction/introduction-to-the-pom.html#Available_Variables
- https://wiki.jenkins-ci.org/display/JENKINS/Starting+and+Accessing+Jenkins
- https://jenkins.io/doc/pipeline
- https://jenkins.io/doc/pipeline/jenkinsfile
- https://jenkins.io/doc/pipeline/steps
- http://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Maven
- http://docs.sonarqube.org/display/PLUG/Code+Coverage+by+Integration+Tests+for+Java+Project
- http://www.eclemma.org/jacoco/trunk/doc/prepare-agent-integration-mojo.html
- https://aroundthecode.org/2014/07/07/unit-and-integration-tests-coverage-with-sonarqube-and-jacoco