Resteasy rest responses of quarkus app ignore jackson config quarkus.jackson.write-dates-as-timestamps=true - jackson

in the process of migrating a java app to quarkus, we have encountered that resteasy responses which include a java.util.Date object, are being converted to a Date String instead of a long timestamp in milliseconds.
According to the quarkus documentation, this default behavior is normal and can be disabled by putting quarkus.jackson.write-dates-as-timestamps=true in the application.properties file, but it seems to be ignored as the result stays a string date instead of a timestamp regardless of this config being set to true.
We also tried to set this config property explicitly via an ObjectMapperCustomizer, but that didn't work out either.
Quarkus version: 2.9.0
Any ideas how we can force timestamps for any resteasy response?
Affected Code: https://github.com/labsai/EDDI
EDIT:
I have added a resteasy endpoint with a test response containing a date to more easily reproduce the issue:
https://github.com/labsai/EDDI/blob/master/src/main/java/ai/labs/eddi/configs/Test.java
Start app with ./mvnw compile quarkus:dev (docker needs to be enabled, otherwise you need a mongodb up and running)
Then GET http://localhost:7070/test which results in {"date":"2022-05-16T07:49:13.001Z[UTC]"}

The reason you are seeing this behavior is because Jackson is not being used to serialize JSON.
Instead, JSON-B is handling that task.
quarkus-jsonb is getting included from the following tree:
[INFO] ├─ io.quarkiverse.microprofile:quarkus-microprofile-deployment:jar:2.7.2.Final (compile)
[INFO] │ ├─ io.quarkiverse.microprofile:quarkus-microprofile:jar:2.7.2.Final (compile)
[INFO] │ │ ├─ io.quarkus:quarkus-resteasy-jsonb:jar:2.9.0.Final (compile)
[INFO] │ │ │ ├─ io.quarkus:quarkus-jsonb:jar:2.9.0.Final (compile)
You can use one of Quarkus' ability to "hide" certain classpath resources.
quarkus.class-loading.removed-resources."org.jboss.resteasy\:resteasy-json-binding-provider"=org/jboss/resteasy/plugins/providers/jsonb/JsonBindingProvider.class
See this for more details.

Related

problems with PyPlot on Jupyter-lab

I am starting getting this message when using PyPlot in Jupyter lab, tried Pkg.resolve() but it didn't help, does anyone knows how to fix this?
many thanks!!
using PyPlot
┌ Info: Precompiling PyPlot [d330b81b-6aea-500a-939a-2ce795aea3ee]
└ # Base loading.jl:1278
┌ Warning: Package FixedPointNumbers does not have Statistics in its dependencies:
│ - If you have FixedPointNumbers checked out for development and have
│ added Statistics as a dependency but haven't updated your primary
│ environment's manifest file, try `Pkg.resolve()`.
│ - Otherwise you may need to report an issue with FixedPointNumbers
└ Loading Statistics into FixedPointNumbers from project dependency, future warnings for FixedPointNumbers are suppressed.
well, running Pkg.resolve() from the jupyter workbook fixed it, I had been trying from the REPL, as I thought it was equivalent, and it wasn't forking bu now is fine.

Chrome launching twice when running a Cucumber feature

I have a problem where Chrome driver is launching twice when I run a feature file.
I'm using Cucumber with Selenium Java using IntelliJ.
The problem came about when I created a new stepdef file for a new area of functionality that I'm working on. So I'm pretty sure this is something to do with how the features are linked to step defs. I'm still learning the ropes here so this is an area I haven't had much experience in.
My Step Defs each come with #Before code to run before every stepdef method and the #Before code contains a
driver.get("https://mywebsite_under_test");
This website URL is different for each of the two StepDef files.
When I launch my test I can see that the two chrome sessions it starts are the ones mentioned in the #Before of each Step Def file. I'm launching from the IDE where I just run the feature.
My project structure is as follows:
├───main
│ ├───java
│ └───resources
└───test
├───java
│ ├───Database
│ ├───Pages
│ └───stepdefs
│ ├───MOPStepDefs
│ └───MOSStepDefs
└───Resources
├───MOP Features
└───MOS Features
I'm out of ideas here. I've messed about with Glue value in the Config but not getting any luck.
With your before tag add the scenario tag so it only runs when you run that scenario i.e. #Before("#MOP") where #MOP is a tag of your feature or scenario. In your instance the syntax should be #Before("#Automated, #MOP")

loading spring-{env}.properties in IntelliJ 2016.3

I have a Spring Boot properties with three properties files:
I have a class that uses values defined in application-local.properties file, which I thought would get used because application-properties has `spring.profiles.active=local
When I start up in IntelliJ, I see this in the console logs:
Loaded config file 'file:.../build/resources/main/application.properties' (classpath:/application.properties)
2016-12-18 20:10:17.596 DEBUG 29999 --- [ restartedMain] o.s.b.c.c.ConfigFileApplicationListener : Loaded config file 'file:.../build/resources/main/application-local.properties' (classpath:/application-local.properties)`
Skipped (empty) config file 'file:...build/resources/main/application-local.properties' (classpath:/application-local.properties) for profile local
It says it skipped the empty config file, but when I inspect 'build/resources/main/application-local.properties' then I see the values in there.
However, the following class does not have the properties when I run it from within IntelliJ as a Spring Boot Application. It throws a null pointer because these are null:
#Value("${myapp.ApiKey}")
private String apiKey;
#Value("${myapp.ApiSecret}")
private String apiSecret;
#Value("${myapp.user}")
private String user;
In the Application Configuration I tried using Active Profiles, Program Arguments, and Environment Variables.
However, if I run from the command line as:
java -jar -Dspring.active.profiles=local build/libs/myjar-0.0.1-SNAPSHOT.jar
then it works just fine. I am sure this was working previously, but not sure if the IntelliJ version was the same. Any tips on how to make the correct version of my application.properties get used?
Which spring boot version are you using? If you're using the latest this should be
-Dspring.profiles.active=local
http://docs.spring.io/spring-boot/docs/current/reference/html/howto-properties-and-configuration.html#howto-set-active-spring-profiles

Gradle TestListener logging

I've written a GradleTestListener (implements org.gradle.api.tasks.testing.TestListener) and registered this in build.gradle:
test { addTestListener(new com.abcd.GradleTestAdaptor()) }
This test listener uses a third party library which is printing a warning + stacktrace via Slf4J to the console. This is causing a lot of noise in the test output so I would like to suppress it. I have configured Slf4j & Log4J as dependencies on my project and placed log4j.xml with root level error in src/test/resources. The warning is still being printed so it appears my logging configuration is not being picked up.
I'm wondering, as the TestListener is part of the build (akin to a plugin), will it pick up my logging configuration? If not, make it so?

How can I retrieve snapshot dependencies from Nexus using SBT?

I have a maven2 repository from which I'm trying to fetch an snapshot artifact with an appended timestamp. I'm (unsurprisingly) able to retrieve it fine when building with maven2 but when building with simple-build-tool (sbt), much preferred by me, I can't pull it down.
I can see from this question about snapshots in Ivy that it is possible to configure Ivy to get snapshot artifacts but I don't know how to tell sbt to do it.
The relevant bits of my current configuration:
val snapshotsName = "Snapshots Repository"
val snapshotsUrl = new java.net.URL("http://host:port/path/to/root")
val snapshotsPattern = "[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"
val snapshots = Resolver.url(snapshotsName, snapshotsUrl)(Patterns(snapshotsPattern))
Credentials(Path.userHome / ".ivy2" / ".credentials", log)
Update: After some more tinkering it looks like I can get it to point at the correct artifact url with the following pattern.
val snapshotsPattern = "[organisation]/[module]/[revision]-SNAPSHOT/[artifact]-[revision](-[timestamp]).[ext]"
With that I still need to specify the timestamp extra in the dependency
val dep = "group" % "artifact" % "0.0.1" extra("timestamp" -> "20101202.195418-3")
but it does pull the artifact. However it does NOT pull the artifact's dependencies. So it seems I've still got something wrong.
Alright, I got this sorted out but it wasn't actually an SBT problem it was 100% user error.
The Nexus I was using required authentication. I didn't have the authentication credentials set up correctly (see my authentication question) and because it wasn't properly authenticating it wasn't finding the metadata pom files and so SBT printed out the error message that it was failing I, incorrectly, assumed it was authenticating but not resolving. So I started messing with the patterns as evidenced in the actual question.
However, now that I have authentication setup correctly I changed back to just a regular repository declaration like so:
val snapshotsRepo = "Snapshots Repository" at "http://host:port/path/to/snapshots/root/"
and everything works. Artifacts are retrieved and dependencies resolved.