Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@beikov 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

This comment has been minimized.

Copy link
Owner Author

@AdamBien AdamBien commented Oct 14, 2020

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

This comment has been minimized.

Copy link

@djafaka 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

This comment has been minimized.

Copy link
Owner Author

@AdamBien AdamBien commented Oct 19, 2020

Use Payara? :-)

@djafaka

This comment has been minimized.

Copy link

@djafaka 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

This comment has been minimized.

Copy link

@djafaka 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.