Monday, April 29, 2019

JAXRS client with Jersey

As usual we start from the excellent Baeldung https://www.baeldung.com/jersey-jax-rs-client

The working solution is in https://github.com/vernetto/jerseyrest and the client is in the test directory (Jersey is provided with "test" scope, while the "main" can be built with maven and deployed to WebLogic for instance)

The project is to turn the Service in a set of services with different types of payloads (JSON, XML, binary) and different marshaling/unmarshaling frameworks (Jexson, GSON...) , then run some performance test (using junit5) under different load conditions.





Swagger for Java EE reasteasy or jersey

Making Swagger work in Spring is very easy.

You can use it also in Java EE (Wildfly, WebLogic, even Tomcat!!! )

but all the documentation I have found is a bit outdated:

I have tried APIEE https://dzone.com/articles/apiee-an-easy-way-to-get-swagger-on-java-ee and https://github.com/phillip-kruger/apiee but it's not showing my services and I see no error.

Some other outdated articles:

https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-2.X-Project-Setup-1.5



https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-RESTEasy-2.X-Project-Setup-1.5

I have no time now, but if I need to write REST services in Java EE I would not live without Swagger...

Gradle deploy to Nexus

mkdir /home/centos/gitclones/gradletest
cd /home/centos/gitclones/gradletest
gradle init --type java-application

gradle build

vi build.gradle
add to plugins:
id 'maven'

maven Plugin for Gradle is documented here https://docs.gradle.org/current/userguide/maven_plugin.html

gradle install

ls -ltra /home/centos/.m2/repository/gradletest/unspecified/
total 4956
-rw-r--r-- 1 centos docker 2371522 Apr 29 13:23 gradletest-unspecified.zip
-rw-r--r-- 1 centos docker 2693120 Apr 29 13:23 gradletest-unspecified.tar
-rw-r--r-- 1 centos docker     752 Apr 29 13:23 gradletest-unspecified.jar
-rw-r--r-- 1 centos docker     756 Apr 29 13:23 gradletest-unspecified.pom


cat /home/centos/.m2/repository/gradletest/unspecified/gradletest-unspecified.pom

  <groupId></groupId>
  <artifactId>gradletest</artifactId>
  <version>unspecified</version>


group and version are missing!

then you can follow the steps here https://medium.com/dot-debug/deploying-artifacts-to-maven-using-gradle-b669acc1b6f8

you define the group and version in your projects' build.gradle, you define nexus username/password/url in ~/.gradle/gradle.properties and you use the maven-publish plugin to publish to Nexus