Skip to content

Instantly share code, notes, and snippets.

@AdamBien
Created October 6, 2020 06:15
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/c832d9c1226b84df5591d5bebc6e822b to your computer and use it in GitHub Desktop.
Save AdamBien/c832d9c1226b84df5591d5bebc6e822b to your computer and use it in GitHub Desktop.
80thAirhacksQ&A.md

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

Also checkout recent episode:

79th 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.

Upcoming airhacks.tv events are also going to be announced at meetup.com/airhacks

@beikov
Copy link

beikov commented Oct 6, 2020

Hey Adam,

you recently said something like "some people believe that using DTOs is the right way" and I would like to know why you hate DTOs so much 😆

I work on commercial applications that have entity models which cover multiplie use cases, not just CRUD. Depending on the use case, I need different parts of an entity, but never all information, so I use DTOs to reduce the amount of data that is fetched and exposed. What kind of magic would you use to approach something like that without DTOs?

I am the author of Blaze-Persistence Entity-Views which aims to reduce the necessary boilerplate to implement an efficient DTO approach. You define DTOs as annotated interfaces and can apply this projection onto a query i.e. a query is transformed to produce the DTO type efficiently. This works on top of JPA.

If your sole concern with DTOs is the boilerplate, what do you think about such an approach?

@AdamBien
Copy link
Author

Migrating 8 years old Java EE 6 code I hacked on stage at JDD 2012 conference to 2020 and JDK 15. Should be fun!

@djafaka
Copy link

djafaka commented Oct 19, 2020

Hi All
I use the Java EE 8 archetype https://github.com/AdamBien/javaee8-essentials-archetype which is very usefull but after generation, and launching the buildAndRun.sh script, it seem that the deployment failed for the Glassfish server inside the docker image generated as you can see:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
18c42376c946 com.demo/demo2 "/bin/sh -c 'asadmin…" 31 minutes ago Up 31 minutes 0.0.0.0:4848->4848/tcp, 8009/tcp, 0.0.0.0:8080->8080/tcp, 8181/tcp demo2
6ef4eca65719 registry:2 "/entrypoint.sh /etc…" 3 weeks ago Up 8 days 0.0.0.0:5000->5000/tcp registry
$ docker exec -it 18c42376c946 /bin/bash
bash-4.2$ ls
appclient appclient.js asadmin.bat capture-schema.1m jspc package-appclient schemagen startserv stopserv wscompile wsdeploy wsgen wsimport xjc
appclient.bat asadmin capture-schema capture-schema.bat jspc.bat package-appclient.bat schemagen.bat startserv.bat stopserv.bat wscompile.bat wsdeploy.bat wsgen.bat wsimport.bat xjc.bat
bash-4.2$ pwd
/opt/glassfish5/glassfish/bin
bash-4.2$ cd ..
bash-4.2$ ls
bin common config docs domains glassfish legal lib modules osgi
bash-4.2$ cd domains
bash-4.2$ ls
domain1
bash-4.2$ cd domain1/
bash-4.2$ ls
applications autodeploy bin config docroot generated init-info lib logs osgi-cache
bash-4.2$ cd autodeploy/
bash-4.2$ ls
bundles demo2.war demo2.war_deployFailed
bash-4.2$ ls -la
total 28
drwxrwxrwx 1 serveradmin serveradmin 4096 Oct 19 16:56 .
drwxrwxrwx 1 serveradmin serveradmin 4096 Oct 19 16:56 ..
drwxrwxrwx 1 serveradmin serveradmin 4096 Oct 19 16:56 .autodeploystatus
drwxrwxrwx 2 serveradmin serveradmin 4096 Sep 8 2017 bundles
-rw-r--r-- 1 root root 4066 Oct 19 16:56 demo2.war
-rw-r--r-- 1 serveradmin serveradmin 0 Oct 19 16:56 demo2.war_deployFailed

Many Thanks for the response and thanks for the wonderful work !
Karim

@AdamBien
Copy link
Author

Use Payara? :-)

@djafaka
Copy link

djafaka commented Oct 19, 2020

Use Payara? :-)

Yes, by default the server where my application is deployed is Payara as you can see in the admin console http://localhost:8080/

Do I have to change something in the config file generated ?
Here the content of the Dockerfile:
FROM airhacks/glassfish
COPY ./target/payara-jwt.war ${DEPLOYMENT_DIR}

And buildAndRun.sh

#!/bin/sh
mvn clean package && docker build -t com.eni.samples/payara-jwt .
docker rm -f payara-jwt || true && docker run -d -p 8080:8080 -p 4848:4848 --name payara-jwt com.eni.samples/payara-jwt

Thanks Adam.
Karim

@djafaka
Copy link

djafaka commented Oct 19, 2020

Ok I found the problem.
I have to change the content of the dockerfile generated:

FROM airhacks/payara-micro
ENV ARCHIVE_NAME demo2.war
COPY ./target/demo2.war ${DEPLOYMENT_DIR}

And I need to change the code of the PingResource generated, there is a compile problem if you don't change the code:

@GET
public String ping() {
    return  " Jakarta EE with MicroProfile 2+!";
}

I will adapt the archetype to those modifs...
Thank you
Karim

@AdamBien
Copy link
Author

Ok I found the problem.
I have to change the content of the dockerfile generated:

FROM airhacks/payara-micro

Use airhacks/payara

Payara fish is the server I used in projects, workshops and conferences and what my clients are using as well. Wildfly and Co. would work as well. Payara-micro was just a PoC.

ENV ARCHIVE_NAME demo2.war
COPY ./target/demo2.war ${DEPLOYMENT_DIR}

And I need to change the code of the PingResource generated, there is a compile problem if you don't change the code:

@GET
public String ping() {
    return  " Jakarta EE with MicroProfile 2+!";
}

I will adapt the archetype to those modifs...
Thank you
Karim

@dempile
Copy link

dempile commented Oct 29, 2020

Hi Adam,

I would like to centralize the authentication of all our enterprise applications in one place using Keycloak, We have several JSF-Jakarta EE applications and few apps that uses frontend libraries.
How can I use Keycloak with Soteria in order to secure the apps that have JSF pages since keycloak is oriented to secure endpoint resources. And if you can hack something to clarify how we could secure JSF pages and Rest Endpoint it would be very nice.

Thanks

@JosefMaderKreiner
Copy link

Hi Adam,

Microservices build with eclipse Microprofile / Jakarta EE are really efficient. State of the art implementations like Quarkus or Openliberty need just a view MBs to host a REST-service. Even though there are a lot of discussions about the right size of Microservices.

Actually there are still use-cases where you need a lot of resources.

What do you think are good technical limitations for Microservices written in Jakarta EE / Microprofile.
Is a Microservices which needs about 10 GB RAM and 4 Cores still micro? Do you restrict resources in your projects?

Thanks for your advice!

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