Instantly share code, notes, and snippets.

Embed
What would you like to do?
55thAirhacksQ&A.md
@AdamBien

This comment has been minimized.

Owner

AdamBien commented Sep 4, 2018

Overflow questions from the 55th episode:

Managing docker build with Maven?: http://adambien.blog/roller/abien/entry/simplest_possible_microprofile_maven_kickstarter

@AdamBien

This comment has been minimized.

Owner

AdamBien commented Sep 4, 2018

@AdamBien

This comment has been minimized.

Owner

AdamBien commented Sep 4, 2018

@AdamBien

This comment has been minimized.

Owner

AdamBien commented Sep 4, 2018

@AdamBien Hi, adam, Is there a way to externalize the calculation of a mathematics formula in a way that you can change it later. thanks

— omar Alvarez (@denpile) September 3, 2018
@jumarome

This comment has been minimized.

jumarome commented Sep 7, 2018

Hi Adam, first of all thank you for the great job you are doing for the java community. my questions are:

  1. If you are involved in a project in which you have to do a lot of CRUD operations, up to what point is acceptable to include the deltaspike jpa module dependency?

  2. How would be the best way to handle partial updates via PATCH on a JAX-RS resource(assuming that the client doesn't want to implement JSON PATCH spec), specifically how can I determine when the client sends null explicitly in a field or when is omitting a field? If I use a HashMap or a JsonObject on the request body the problem is that I lose the validation annotations that I put in the entity,enum converters and also LocalDate/LocalDateTime converters.

Thanks

@dempile

This comment has been minimized.

dempile commented Sep 12, 2018

Hi Adam
An Application for a large population have to be efficient I want to know the maximum operation by second ( in parallel ) my application could handle and the number of maximum users in parallel, , how can I perform a test like this ( Iam using Payara ) ?
I have never used Websphere or JBOSS AS, Is there really a great difference between these application servers and free ones like Payara, Open liberty or Wildfly.
Thanks

@avdiu

This comment has been minimized.

avdiu commented Sep 12, 2018

Hi Adam,

I have recently bought your online workshops (Bootstrap and Effective JavaEE) - currently at bootstrap section, I saw that you never mention servlets and in youtube in your videos you often use javascript to call java ee backend (jax-rs). Can you explain how can I make an application that make use of session (eg. HttpSession in Java), handle clients requests but also use Rest. Should I go for Client->Servlet->JAX-RS or what are best practices?

Or If you could explain a little bit more about how to build modern webapp, how are servlets used these days or are they dead?!
Sorry if questions are "outdated " 😄 Im kind of new in java ee!

Thanks

@mistifi01

This comment has been minimized.

mistifi01 commented Sep 16, 2018

Hello Adam

  1. I've read a little bit about javax.MVC lately and I really liked it (I think java ee missed a framework like this because everybody keep shouting at Spring MVC when comparing Java EE and Spring), but I am somehow confused with it! It says in spec that is built using jax-rs and if you start a mvc project you need to configure, and extends Application just as an JAX-RS app. Can I use JAX-RS resource in same project with mvc?!
    What I mean is for eg. I configured JAX-RS under path /api/ , so can I make an @controller class javax.Mvc and another one TestResource (restful)!!
    Or should I make another project just for REST Resources and call those api from my other mvc project
    I am confused!! Help me Adam 😆 😆

  2. Have you any knowledge about what's going on with this MVC framework, is there gonna be any update on it? Is it safe to create projects from scratch using

Thank you for all of this that you are doing (answering everybody questions and helping us for free)

@romankmq

This comment has been minimized.

romankmq commented Sep 16, 2018

Hi Adam

What do you think which is better, faster and more modern for today's web Apps : Servlets & JSP, JSF, Vaadin?
And can you tell me if there are any other good frameworks?
Thanks

@thearonbb

This comment has been minimized.

thearonbb commented Sep 16, 2018

Hey Adam,

  1. How do I handle concurrency in JPA, @Version (if you can explain little bit) or I saw some discussions that even JMS Queue is a good to go? What do you think or there is another better solution for this?

  2. Which JPA provider do you use Hibernate or EclipseLink?

Thanks

@mistifi01

This comment has been minimized.

mistifi01 commented Sep 17, 2018

Hi Adam

How to optimize Java EE with only jdbc (without JPA). For eg. if I have an SomethingDAO and in that class I have all Connection.class, methods that do inserts, deletes, updates and all work with database (with plain SQL queries, maybe calling stored procedures)! Should I inject that class in EJB, JAX-RS? How would EJB transaction deal with it?

And do you think that doing this is a good call (jdbc over jpa). I mean if you want full control over code because these frameworks have added so much features that maybe something is not necessary (and just losing time to do something that I don't really need it)??

Thanks

@varianti2

This comment has been minimized.

varianti2 commented Sep 19, 2018

Hi Adam
I am building an web app. using java ee and idea is based mainly to schedule some tasks that my app offer from different users! For eg. user select what to schedule and after button click I want to perform some database operations and call @singleton methods for scheduling.
How would be best solution if you have thousands to tens of thousands of users... Should you use only one singleton (would it be efficient? fast? not hardwork for application server etc) or what to do? And for database operations eg insert the data of schedule task into user history... is a good idead to do this as asynchronus ?
If you can tell me the best way to do this?

Thanks

@avdiu

This comment has been minimized.

avdiu commented Sep 23, 2018

Hi Adam
What are your thoughts on Java 9, 10? Do you use them in your projects?
Can you make a quick tutorial and put it on youtube? Securing JAX RS with OAuth2 on Java EE 8

Thank you

@gurukulkarni

This comment has been minimized.

gurukulkarni commented Sep 24, 2018

Hello Adam, I know you have used microprofile with payara and was wondering if you used microprofile config?
I can load properties from within the war from META-INF/microprofile-config.properties however I would like to load a properties file from outside the war, this is because there are some properties that I would not like to have in source control but just on the server.
Further I tried to mount a properties file over to META-INF/microprofile-config.properties inside the deploy folder but it just made the deployment fail. My Current two alternatives : either load from a JAX-RS endoint and keep in memory Or somehow load the properties in a db using maybe enhydrator. What do you think would be the best way? this is really an easy problem that has simple solutions in both spring and play but I could not find the solution for Java EE

@deratzmann

This comment has been minimized.

deratzmann commented Sep 27, 2018

Hi Adam. Nice to See you :)
Do you know any functionality in javaee to attach a specific http thread pool to a specific context path or ejb?
We have our payara5 in a docker environment, our Healthcheck is a Rest Service called by docker Healthcheck functionality. in times of many requests in production we sometimes see, that the Rest Services, which use some Data from a DB, have to wait for processing. Unfortunatly the Healthcheck request also waits and is sometimes not responding within the given time. then the Container gets unhealthy and our Container Manager docker Swarm tries to restart it, which should not be done. In my eyes we need 2 different http Thread pools,one for Healthcheck, one for other Rest Services. How would I solve this?

2nd question: how can a javaee Rest Service, which uses jpa and ejb for Communication with a db, return immediatly (!) with an error, e.g. Status Code 503, when the db is down without waiting for the connection pool (which will obviously run into connection timeouts) so that the thread is not blocked while waiting for the timeout?

Thanks and best regards.

Bastian

@noherczeg

This comment has been minimized.

noherczeg commented Sep 28, 2018

Hello Adam,

Not sure if you got my question on twitter, so I'll ask it here as well:

Usually you tend to work with in memory models in your demos. I'm interested if You could show us some examples on how you typically handle Database operations via JPA? What best practices do you recommend for seeding / bootstrapping databases and models? Do you prefer Flyway, or Liquibase (maybe something else)? I'm mainly interested in your approach since you are an active advocate for the platform. I'm hoping for a demo ;-)!

Thank you,

Norbert

@tonda100

This comment has been minimized.

tonda100 commented Sep 30, 2018

Hello Adam,

thank you for doing the airhacks.tv, I have two questions.

  1. Java EE 8 and Jigsaw - is it possible to develop web application with new Java (9, 10, 11)? Is there an example or do I have to wait for Jakarta EE release?
  2. Last episode there were question about LocalDate serialization for JAX-RS and JSON-B the proposed solution was JSONConfigurator class but using ECB design pattern where should I place this class. I would leave in project root package but sometimes there is more of them. Would you create jsonb package or serialization or leave in root?

Thank you,
Antonin

@omega09

This comment has been minimized.

omega09 commented Sep 30, 2018

Hi Adam,

I have a question about testing/mocking. I created a small and simple project for this: https://github.com/omega09/aTester
A few things to note about it: 1. It's an Eclipse project so it has Eclipse files you can ignore. 2. There are classes in the entities package which are not annotated with JPA because it's not important here. 3. The business logic doesn't make much sense but it's an example. 4. I added a Mockito dependency but you don't have to use it.

I would like you to show how you would write a test for the ActionExecutor.doAction method. I already created a class for this in the test source folder. The test can be whatever you want, I just want to see things like when you use new, when you mock, how you set the injections, how you set up the overall test (populate pre-existing relevant fields), choose a runner, etc.

On the same topic, how relevant is your vid A Note On Java EE Testing today?

Thank you and enjoy the homework assignment :)

@omega09

This comment has been minimized.

omega09 commented Sep 30, 2018

Another question if you have time, if not I can ask next month.

JavaEE 8 added SSE in JAX-RS 2.1. SseEventSource has reconnection support which tries to resend all missed events, but says

Note however, that this is a best-effort mechanism which does not provide any guaranty that all events would be delivered without a loss. You should therefore not rely on receiving every single event and design your client application code accordingly.

If I want to make sure that all the events were sent, and if not - to send those that weren't, how would you recommend to do that?

@jarryDk

This comment has been minimized.

jarryDk commented Oct 1, 2018

Dear Adam

avdiu asked "What are your thoughts on Java 9, 10?" - I like to hear about Java 11 and why stop there - that about Java 12 especially JEP 335: Deprecate the Nashorn JavaScript Engine

Thank you,

Michael

@franden

This comment has been minimized.

franden commented Oct 1, 2018

Hi Adam,

Thank you for your great job (blog, podcast, sessions...). I have a question to your recent post: http://adambien.blog/roller/abien/entry/what_is_dependent_scope

In an ECB/BCE application, the boundary is annotated with @Stateless and all other control instances come as vanilla POJOs without any annotations. They are dependent-objects

that would mean that the complete "web application" would have the same scope like the stateless bean and because the EJBs are pooled resources, all injected CDI beans would be injected and created only once per EJB. This approach can lead to unexpected behavior if you use CDI for instance variable injection because they will not be "reinjected" in this case e.g:

@Stateless
public class SomeRandomService
{
    @Inject
    @ConfigProperty(name = "endpoint.poll.interval")
    private Integer pollInterval;

    @Inject
    @ConfigProperty(name = "endpoint.poll.servername")
    private String pollUrl;

    ...
 }

In such case "pollInterval" and "pollUrl" are injected only once a EJB is created. If the configuration is changed afterwards, already created EJBs SomeRandomService will still use the old values.

To avoid such side effects, all our beans are ether annotated with @RequestScoped (especially on boundary package) or inject objects with getter to retrieve current state.

How do you deal with such problems? Are your really not using @RequestScoped bean in your ECB applications?

@t-shaguy

This comment has been minimized.

t-shaguy commented Oct 1, 2018

Hello Adam, a big thanks to this awesome gift of invaluable education. Please in trying to deal with the concerns of multiple integrations are ESBs the way to go in an enterprise environment ? Many thanks

@huxendupsel

This comment has been minimized.

huxendupsel commented Oct 1, 2018

Hello Adam,
short question about the CDI/EJB coexistence inside JEE. Over the last specifications of JEE CDI became more and more powerful. Nowadays you even have the transaction handling on board. So, what do you think about CDI, is it capable of replacing EJBs? Would you recommend the use of CDI over EJBs so you will not have to handle mixed forms, where you have to deal with eventual incompatible context scopes, or is it worth to stick on EJBs to do the job they where designed for?
Thanks a lot.

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