Encountered a weird behavior when running my Spring Boot + JSF (PrimeFaces) application in Docker container (using java -jar xxx.jar as ENTRYPOINT). It keep complaining “xhtml Not Found in ExternalContext as a Resource” when I access the page, in fact that runs well either using java -jar command or mvn spring:run in host machine.
After some hard time, manage to figure out why…….. phew….
… it was caused by wrong jar packaging structure, and correct structure should look as below:
Nearly didn’t remember when was the last time I celebrate Merdeka (at least hoisting our national flag in front of house). But I feel a little special this year as many Merdeka celebration mtv shared around social media 🙂
~Happy Merdeka Malaysia~
Has been a while, I was thinking to blog this out but “lazy” bugs keep biting me 🙁 so I didn’t manage to do it. Until yesterday, I was looking for some related info but I hardly recall what I did previously. Phew… so decided to jot down here.
Typically software application should at least perform 2 types of automate tests which are unit test and integration test. For me… the distinction between these two are pretty straight forward:
Test on smallest unit of application such as method / function
Test on combination of few units in application to prove they run nicely with external resource (if there is any)
Cheap to run, fast to run (normally less than a minute)
Slower compared with unit test (normally few minutes or more)
NOT depends on external resources such as database, third party services, disk access
Normally involve database, disk access, other services
Report generated in <PROJECT>/target/surefire-reports
Report generated in <PROJECT>/target/failsafe-reports
By viewing the status report generated by surefire & failsafe plugin doesn’t create much insight, but we can make use of Jacoco plugin to create code coverage report as below. Here are minimal sample Maven configuration for Jacoco:
Jacoco coverage reports generated at <PROJECT>/target/site/* when we run mvn verify (bind to maven verify phase). To view the coverage reports, simply open <PROJECT>/target/site/jacoco/index.html with browser.
Yay ! we have now cover first part of test (automate unit + integration test), and if you notice, we done all steps manually (run maven command, open report from target folder) just to get the report display.
Moreover, we just able to view the coverage report locally, how if we want to share with other team members or to make it public accessible.
And…….. How can we automate the whole process ?
Da.. Dang !! We have Jenkins (Continuous Integration) + SonarQube (Continuous Code Quality Inspection) to help us 🙂
Setting up Jenkins is pretty straight forward, just follow steps from Jenkins Guided Tour or Installing Jenkins. We should able to see something as below if Jenkins setup successfully and launch in browser. Let’s continue with SonarQube setup by following “Get Started in Two Minutes” guide from it’s official site. And if nothing goes wrong, we should able to bring up SonarQube console via browser as below: Until this stage, you might feel a little tired or sleepy, it’s okie to refresh yourself with a cup of coffee 🙂
To allow Jenkins to work with SonarQube, we might need a little setup as below.
Generate authentication token from SonarQube and store it somewhere as steps below for subsequent Jenkins configuration use.
Goto Manage Jenkins –> Configure System, There should have SonarQube configuration module available.
Just configure it by click on AddSonarQube, and fill in necessary information (sample below), then Save it.