Skip to content

Instantly share code, notes, and snippets.

@AdamBien
Created February 7, 2020 18:13
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 AdamBien/40fa453cb15b2e897024294a7fc3623a to your computer and use it in GitHub Desktop.
Save AdamBien/40fa453cb15b2e897024294a7fc3623a to your computer and use it in GitHub Desktop.
72ndAirhacksQ&A.md

Ask questions and see you at March, 2nd, 8.PM. CET: https://vimeo.com/event/19368

Also checkout recent episode:

71st airhacks.tv

Please keep the questions Jakarta EE-stic. Means: as short and as concise as only possible. Feel free to ask several, shorter questions.

@WassimAkachi
Copy link

Hi Adam,

Thank you for your effort and time for trying to support the community (Thumbs up).

Is it possible to response with a json body and not with html when the response status-code isn't in the 2xx-range?
Is the behaviour Runtime/Implementation/App-Server specific to Jakarta EE 8 + MicroProfile 3.0?
Here is an illustration of an example: One can't create two entities in the data store with the same slug.

@Path("cafe")
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
@Tag(name = "CafeResource")
public class CafeResource {

    @POST
    @Operation(description = "Creates a new cafe.", summary = "Create cafe")
    @APIResponse(
            description = "cafe successfully created",
            responseCode = "201",
            content = @Content(schema = @Schema(implementation = CafeWebModel.class))
    )
    @APIResponse(
        description = "When another cafe exists with the same slug, returns null",
        responseCode = "412",
        content = @Content(example = "null", schema = @Schema(nullable = true))
    )
    public Response create(@RequestBody CafeCreationModel cafeCreationModel) {
        Cafe entity = doSomeStuff(cafeCreationModel);
        // ...
        if (entity != null) {
            return Response.status(Response.Status.CREATED).entity(entity).build();
        } else {
            return Response.status(Response.Status.PRECONDITION_FAILED)
                .header(HEADER_X_REASON, "Cafe with same slug exists already.")
                .build();
        }
    }
}
# request nr. 1
$ curl -i -X POST "http://localhost:8080/cafe-manager-app/api/v1/cafes" \
        -H  "accept: application/json" \
        -H  "Content-Type: application/json" \
        -d "{\"visibleName\":\"Cafe AG\",\"slug\":\"cafe-ag\"}"

# response nr. 1 => ok as expected



# request nr. 2
$ curl -i -X POST "http://localhost:8080/cafe-manager-app/api/v1/cafes" \
        -H  "accept: application/json" \
        -H  "Content-Type: application/json" \
        -d "{\"visibleName\":\"Cafe AG\",\"slug\":\"cafe-ag\"}"

# response nr. 2 => not as expected (body is html)

HTTP/1.1 412 Precondition Failed
Server: Payara Server  5.194 #badassfish
X-Powered-By: Servlet/4.0 JSP/2.3 (Payara Server  5.194 #badassfish Java/Azul Systems, Inc./1.8)
X-Reason: Cafe with same slug exists already
Content-Language:
Content-Type: text/html
Content-Length: 1095
X-Frame-Options: SAMEORIGIN

<!DOCTYPE html PUB...>...</html>

---
# expected response nr. 2

HTTP/1.1 412 Precondition Failed
Server: Payara Server  5.194 #badassfish
X-Powered-By: Servlet/4.0 JSP/2.3 (Payara Server  5.194 #badassfish Java/Azul Systems, Inc./1.8)
X-Reason: Cafe with same slug exists already
Content-Language:
Content-Type: application/json
Content-Length: 1095
X-Frame-Options: SAMEORIGIN

null or {}

I would be happy to hear from you about this topic.

Kind Regards,
Wassim

@kovica
Copy link

kovica commented Feb 23, 2020

You have done a lot of videos on Quarkus. Why do you prefer it over Helidon (https://helidon.io), Micronaut (https://micronaut.io), maybe some other products?

@dempile
Copy link

dempile commented Mar 2, 2020

Hi Adam,

  • Is there a way to integrate Liferay with java EE applications in order to do the SSO ?
  • Knowing that OKD is always late for making new releases "OKD 4 is not even Beta" , do you think using Skaffold and Jib with a kubernetes cluster can make a good alternative to Openshift S2I ?
    Thanks

@yeahservice
Copy link

Hi Adam

  1. We are currently migrating a Jakarta 8 Application to Quarkus and we are using JPA Entities directly for JSON Serialization in the endpoints. The resteasy jsonb extensions has a problem with serializing Fetchtype.LAZY, although the request has a transaction. The following exception is thrown:

    Caused by: org.hibernate.LazyInitializationException: Unable to perform requested lazy initialization [com.entity.Group.users] - no session and settings disallow loading outside the Session

    We already tried some workarounds with Hibernate.Initialize but they did not work. Is there a way to get the serialization working with lazy fetching?

  2. What is the best practice to develop two or more quarkus applications at the same time, since starting two instances at the same time does not seem possible. Is using a docker container for each quarkus application the recommended way and is there a good way to set it up with hot reload?

Thanks and greetings from Graz.

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