Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
60thAirhacksQ&A.md

Ask questions and see you at March, 13th, 6.PM. CET: http://www.ustream.tv/channel/adambien

Also checkout recent episode:

60 airhacks.tv

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

@UlrichCech

This comment has been minimized.

Copy link

UlrichCech commented Feb 10, 2019

Hi Adam,

I would like to know, what is the best way to keep the WAR thin with dependent libraries. In a complete application, you have, for example, dependent libraries like MongoDB driver, MongoDB Morphia, Primefaces, Amazon SDK (or part of it), perhaps PrettyFaces for JSF-applications and so on... so, the resulting WAR of a full application grows fast to more then 30 MBs.
What is the best way to:

  1. where to put the libraries in the Payara Server (is the directory ../domains/domain1/libs/applibs the right one?)
  2. how to identify the necessary libraries and their transitive dependencies? Build the application and look into the /target//WEB-INF/lib/ folder and copy all jars to the directory from 1.), or is there a better/automatic/generic way to identify the necessary JAR-files?
  3. it seems, that with the way of copying/providing external libraries for every application server, you need some 'strategy' or configuration for each AppServer, where to put the external libs (and you have to provide that in the Dockerfiles as multiple COPY commands). And for every update of libraries, you need to change the JAR file(s) and Dockerfiles. Is this effort worth for saving same MBs? What are your experiences in real-life application setups?

Thank you very much for your response.
Ulrich

@Michael-xxxx

This comment has been minimized.

Copy link

Michael-xxxx commented Feb 12, 2019

Hi Adam,

I recognized that a programmatic EJB Timer in a Payara Cluster (4.1.2) runs on both nodes, even if the timer is persistent
@startup
@Scheduler
........
@PostConstruct
public void initialize() {
final ScheduleExpression expression = new ScheduleExpression();
expression.minute(tokens[0]).hour(tokens[1]).dayOfWeek(tokens[2]).dayOfMonth(tokens[3]).month(tokens[4]);
final TimerConfig tf = new TimerConfig();
tf.setPersistent(true);//must be true because of cluster, only one node should execute this code
timerService.createCalendarTimer(expression, tf);

EJB_TimerTable
OWNERID | STATE | PKHASHCODE | INTERVALDURATION | INITIALEXPIRATIONRAW | LASTEXPIRATIONRAW | SCHEDULE | APPLICATIONID
-- | -- | -- | -- | -- | -- | -- | --
node01 | 0 | 0 | 0 | 1,5499E+12 | 1,5499E+12 | 0 # * # 1 # * # * # * # * # null # null # null # false | 1,0157E+17 |  
node02 | 0 | 0 | 0 | 1,5499E+12 | 1,5499E+12 | 0 # * # 1 # * # * # * # * # null # null # null # false | 1,0157E+17 |  
server | 0 | 0 | 0 | 1,5499E+12 | 1,5499E+12 | 0 # * # 1 # * # * # * # * # null # null # null # false | 1,0157E+17 |  

The table shows that the LASTEXPIRATIONRAW is exactly the same time for node1 and node2. (By the way: What means the server row) The log files of the nodes confirms that the timerjob was runnig on both nodes.
I would expect that persistent timers are running only on one node
Thanks in advance,

Michael

@UlrichCech

This comment has been minimized.

@ylberkz

This comment has been minimized.

Copy link

ylberkz commented Feb 23, 2019

Hi Adam,

I am new in java ee, and im reading about beans, everywhere there is history about them (SOO CONFUSED)! What is bean class, local and remote bean? Why do you need them in this way (interface , implementation). difference between them? Are they still used in this way?
Do i really need to learn deeply about history of them, to do good in java ee?

Thanks

@Lucien23

This comment has been minimized.

Copy link

Lucien23 commented Feb 23, 2019

Hey Adam

My questions are on microservice architecture

  1. Are microservices good on cart applications? (Add to cart, Remove from cart items, and payment)?

  2. How to deal with "who is first" problem? E.g. booking room service, only 1 room available, and too many request in same time for booking? Which one to give the room? Implement this with JMS (if so can you please explain), or best way to achieve this!!

  3. Can you make a tutorial on how to secure rest resources with JWT token in JavaEE?

Thanks
--Lucien

@vaibhavkulkarni

This comment has been minimized.

Copy link

vaibhavkulkarni commented Feb 25, 2019

Hello Adam,

What are your thoughts on Unikernel? Simplistically speaking, given the size of the whole deployable including infrastructure shrinks considerably why isn't JEE not embracing it as yet?

Thanks,
Vaibhav

@afrimiii

This comment has been minimized.

Copy link

afrimiii commented Feb 25, 2019

Hi Adam,

In microservices how to organize UI and Auth?

Should UI be specified in each war OR create another server with app(plain html,css,js) to communicate with backend?

And auth: should you create a AuthService and for each rest resource request, first call the authService to check authentication and authorization?

How to use JWT in microservices

Thanks!

@filippkk

This comment has been minimized.

Copy link

filippkk commented Feb 27, 2019

Hey Adam, i've seen your sessions and tutorials in youtube, your netbeans is fast and also pc! In my windows netbeans laggy. Could you tell your netbeans version or laptop specs. Thanks

@ooscar1

This comment has been minimized.

Copy link

ooscar1 commented Feb 27, 2019

Hello

I'm trying to learn microservices using java!
I'm confused with a lot of terms, based on tutorials, developers talks and docs.

I've followed your online workshop and really liked BCE pattern! In microservices based on this pattern, does it mean that there should be "a BCE per service (per war)"?

What is service registry?
What really is microprofile and should or why should we use it?

Some developers really complicate too much pom.xml and I don't really understand it? Should you really complicate it that much in a microservice project?

Can you make a video on microservices using jpa interacting with mysql database?

Thanks a lot

@qnoid

This comment has been minimized.

Copy link

qnoid commented Feb 27, 2019

What's the recommended approach in Java EE 8 (or 7) under JAX-RS to serialise lazy JPA entities with JSON-B (or Jackson)?
Here are a few options to help with framing it.

Option 1: Inject the @PersistenceContext EntityManager in a @Stateful EJB and use type = PersistenceContextType.EXTENDED

Pros: You can freely use Lazy associations under JAX-RS
Cons:

  • It's a "global" solution to what might be a local (e.g. to a specific JAX-RS resource) problem
  • Having an extended PersistenceContext might not be compatible with the Transaction context for other resources (

Question: Any more considerations? e.g. anything more to be mindful of by changing from a Stateless to a Stateful EJB?

Option 2: Use a custom JSON-B Writer annotated with @Transactional and re-attach the JPA (aka JAX-RS entity) in the EntityManager

Pros: Fine grained to the JAX-RS resources.
Cons: There is a cost(?) to re-attaching entities on every response.
Question: More cons?

Option 3: Somehow(?) share the EntityManager across the service (request/response cycle) in a single transaction?
Question: Is that possible, supported, inline with the Java EE spec?

Option 4: Use a different EntityManagers (e.g. one injected in a @Stateless EJB and one in a @Stateful with PersistenceContextType.EXTENDED) injected in every request/response.

Pros: Fine grained to the service (request/response cycle) and/or resource
Question: Can you please share an example?

Thanks!

@nickscha

This comment has been minimized.

Copy link

nickscha commented Feb 27, 2019

Hi Adam,

how would you secure your vanilla js/html webapp with JEE backend considering the following requirements:

  • Form Authentication for login
  • Authorization per page (depending on the roles of the user elements/pages are restricted)

Thanks a lot.
Your web standard talks are awesome.

@avniba

This comment has been minimized.

Copy link

avniba commented Feb 28, 2019

Hi Adam

Is it possible to implement a ChatWithClients Microservice with websockets in java ee? If so how can you implement such thing?
Difference between @Gauge and @counted

Thank you

@t-shaguy

This comment has been minimized.

Copy link

t-shaguy commented Mar 2, 2019

Hello Adam,

Sure you are doing great.

  1. Please, what is the most effective way of checking database connection leaks in Java SE/ Java EE using a connection pool or plain JDBC? For JDBC I have used Apache DBCP and considering reviews which say DBCP has issues under heavy load, I am looking at hikari and Cp30. Please from experience what is the way to go.

  2. In what order should the following be closed. Connection, PreparedStatement, ResultSet?

  3. What are the most effective ways/ APIS, Libraries to test for connection/ connection pool leakages in java code?

  4. Does a high number of sleeping connections have a negative impact on Database/system performance?

Thank you very much.

@rieckpil

This comment has been minimized.

Copy link

rieckpil commented Mar 3, 2019

Hey Adam,

I have a question regarding websockets with Java EE within OpenShift/Kubernetes. If your service is deployed several times and each client (e.g. a SPA) gets connected to a different pod how do you make sure you notify all websocket clients when e.g. a message arrives via JMS or Kafka only to one instance (e.g. one consumer group for the whole application)?

Thanks,
Phil

@problemzebra

This comment has been minimized.

Copy link

problemzebra commented Mar 4, 2019

Hi Adam,

What is your opinion about Wildfly & Galleon?

  • Startup time & Heap size: Can the same goals be achieved with removing unused sub systems from the standalone.xml?
  • Image build time: Because of a smaller Wildfly building Docker images is likely a bit faster
  • Disk space: This should not be an issue in 2019
  • What is the use case for Thorntail anymore (if there ever was one)?
@JSamir

This comment has been minimized.

Copy link

JSamir commented Mar 4, 2019

Hi Adam,

my question is about Java EE Security (Java EE 8) best practices (for which somehow there are surprisingly little resources, did anyone use JASPIC/JAAS etc. before?).

How to handle authentication and authorization (the Java EE way) in a module A which is used by other modules running on the same application server? One of the responsibilities of this module A is authentication/authorization which can be used by other modules.

Which interfaces to implement? How does this work with EJBs, should any of the implementing classes be EJBs?

Most examples I found are just about web app authentication and not about a module which doesnt care where the caller has the credentials from.

I already listened to your podcast about this.

@dempile

This comment has been minimized.

Copy link

dempile commented Mar 5, 2019

Hi Adam,
I have a database cluster with three nodes and we want to distrubute the load such that we write on one note and read on the three nodes. Can I do that by making two connection pools one for write only and the other for read only, or there is another solution.
Thanks

@zak905

This comment has been minimized.

Copy link

zak905 commented Mar 11, 2019

Hi Adam,

I have two non related questions:

  • what is the future of Jersey ?
  • Based on the Web components tutorials you provide, you recommend using web components and writing the front end from the ground up without any framework, isn't that too time consuming? How about using Web components frameworks like Polymer or SkateJs ?
    Thanks
@deratzmann

This comment has been minimized.

Copy link

deratzmann commented Mar 11, 2019

Hi, Adam.
Nice to see you :)
What are your thoughts on quarkus (https://quarkus.io/)?
Thanks.

Bastian

@aledestasio

This comment has been minimized.

Copy link

aledestasio commented Mar 11, 2019

Hello Adam, nice questions for you :-)

*) I'm curious what's your opinion about the just released Quarkus project.
*) About your 2019 predictions, do you think the balance between SpringBoot and Java EE will change? Will Jakarta+Microprofile projects succeed in changing the current situation of Spring dominance?
*) I see a lot of interest on Java SE low latency/real time expecially in financial environment. Apart from GC optimisation, what kind of technical solution (or approach) can help to address this kind of requirement? There is some standard project/library on purpose?
*) Let's talk about project documentation. There is a sort of standard in the Jira+Confluence utilization. A lot of open source projects use them. There is also some interest in using git+asciidoc tools (documentation as code). What are your suggestions about this topic,
what the tools/methodology you utilize in your commercial projects for both issue tracking docs and wiki docs?

Thank you and greetings from Florence!

@LuisGalazM

This comment has been minimized.

Copy link

LuisGalazM commented Mar 13, 2019

Hello Adam,
We don't have the possibility to use Docker for our systems at the moment. We are using Puppet to configure, install and deploy. We are packaging our war and application server (Wildfly) in an RPM. Is there a more effienct way to install wildfly and deploy the application that you can recommend?
Thanks.
Kind regards, Luis

@beikov

This comment has been minimized.

Copy link

beikov commented Mar 16, 2019

@qnoid: Blaze-Persistence Entity Views might be of interest to you for your JSON serialization use case. You can create your JSON-DTOs as java classes i.e. entity views and provide the mapping back to the entity model based on JPQL. Behind the scenes, it will fetch only the data that you actually need.
Spring Data Projections is a similar but more limited technology of the Spring ecosystem.

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.