Instantly share code, notes, and snippets.

What would you like to do?

This comment has been minimized.

kullmanp commented Feb 15, 2018

What's the best way to serialize/deserialize objects of a hierarchy to/from json using json-b? Eg, if there are many different vehicles like
class Car extends Vehicle {} and given the right json I would like to have that
jsonb.fromJson("{... }", Vehicle.class) will actually be a Car.

I can't see how to use a static factory with @JsonbCreator for this.


This comment has been minimized.

vernetto commented Feb 24, 2018

good morning Adam and thank you for all the helpful answers.
We have a mixture of scripting languages: bash and ksh scripts, perl, Python, and we are currently adopting Jenkins Pipelines with Blueocean, which is based on Groovy. Ideally I would like to rely only on 1 single language, possibly with full integration with Java libraries for easy integration with JIRA, Openshift, Jenkins via their JAVA APIs. IMHO bash and ksh are horrendous. What is your experience with Groovy compared with Python, especially when it comes to XML/Json parsing and REST calls? Would you entirely replace Python with Groovy?


This comment has been minimized.

archenroot commented Feb 25, 2018

Hi Adam,

following light4j suggestion for your java missions. What this framework offer is not only the best in class performance api development, but more is complete event driven platform for microservices. This means it provides base implementations of CQRS, Event Sourcing and Sagas patterns. In general it means there exists central event store which is central point of truth. I started actually using postgres/mongodb instance for business services embeded directly in JVM process:

This gives you the capability of minimal maintainance of bussiness data store, you can simply destory any bussiness service and just redeploy where the business store get reconstructed by replaying sequence of events. this is the capabilty of event store of course. This is handy when you need to do change in domain objects or extends some domains in READ model, if the data are already inside the events, you just redeploy/replay new domain model along with service and end of story.

There is much more behind these ideas, originally behind light4j is famous Richardson with his own implementation based on Spring:

Guys from light4j just return back to pure Java to get best performance, so recreated the whole solution.

Not only the databases are in scope, but internal/external messaging subsystem, which suggest to use Kafka, but I plan(if not other priorities in my way) to implement even faster messaging system based on OpenHFT Chronicle Queue:

Chronicle is deadly messaging and I am brainstorming so called brokerless system with that, or embedded messaging as part of service.

Anyway thank you for your work on Java field and good luck in your mission!



This comment has been minimized.

kelsas commented Mar 1, 2018

Say you’ve 40k rows of data that you want to use in JSF autocomplete component how best can you handle the data retrieval to enhance performance?


This comment has been minimized.

kelsas commented Mar 1, 2018

Oops my bad Hi Adams forgot to say hi thanks for the awesome posts and solutions you always make my coding life easier


This comment has been minimized.

vernetto commented Mar 2, 2018

good morning Adam. Logging and Diagnostic Context... one of the biggest operational pains is when your application fails with an error (e.g. "Socket Timeout") and you can't find in the logs any context information (like: destination hostname, port, proxy settings... ). Sadly also some core Java libraries are really horrible to debug. Normally one blames the Developer for providing anonymous error messages, but I feel that technology should help with built in flags to - for example - dump in case of exception also all the values of local variables, method parameters etc. Particularly nasty is the case of a developer catching an exception and not logging it, or throwing a different exception and forgetting to link the original exception... in JRockit there was a flag -Xverbose:exceptions to log to stderr all exceptions even if they are caught... but it was not incorporated in other JVMs I believe.... What are your thoughts on this topic?


This comment has been minimized.

mistrz7 commented Mar 2, 2018


I have questions about monitoring ejb transactions. Is it possible to list current active transactions with information when it was started and what class, method fireup it?
Additionally in this days I'm look for free tool to monitor (especially jms queues) wildfly and tomcat servers. I found hawtio, rhq and activemq web console (the best for jms). What is your opinion about it? Mayby you know better tool?



This comment has been minimized.

VAGGELIS commented Mar 2, 2018

Hi Adam,

after using your wonderful code in afterburner, i whould like to ask you a question about javafx .
It's about tableview in javafx.

I'm trying to implement a solution for a tableview holding till 1000-2000 columns.
In the top of tableview i have a TableHeader in every column which holds a TextField and a Label if showFilters is enabled.
And only a label if showFilters is disabled.

The textfield works as a filter for the column data.
I 'm inserting in table.getColumns.addAll(...)
all the columns in the initialization of the table. (If showFilters enabled show with the textfields...)

When switching to disableFilters i clear the columns and put them again without the textfields.

This way it paints well the table, after adding and removing the textfields.

This design works nice till 100 columns. In 500 columns it has really bad performance , in 2000 it crashes....

Any suggestion?



This comment has been minimized.

alibttb commented Mar 3, 2018

Hello Adam, thanks for all things you do,

  1. What is your opinion on using REST web service to authenticate and authorize users in multiple web apps on an intranet?
  2. Is there any way to marshal Java objects to JSON object in a similar manner to JAX-B, let's say I have a POJO annotated with @XmlRootElement and I need a JsonObject jo = SomeBuilder.buildFrom(POJO)?

Thank you again.


This comment has been minimized.

felipe-alves-moraes commented Mar 4, 2018

Hi Adam,

recently I decided to give it a try on ECB(Entity-Control-Boundary) pattern and I have some doubts:

  1. Where do I put my exceptions and exception mappers if I have to create them?
  2. If I need a repository or some utility class, where it goes?
  3. How would a large application with several modules be organized in this pattern?

Thanks. Keep up the good work!


This comment has been minimized.

Eng-Fouad commented Mar 5, 2018

Hi Adam,

Do you think that JSF is going to be deprecated any time soon? I see that the trends to use js frameworks (such as React or Angular) on the client side and expose the backend services through REST endpoints.



This comment has been minimized.

cbustamantem commented Mar 5, 2018

Hi Adam,
Recently I have to migrate two projects, JSF 1.2 to CDI Bean and I make some tricks with java Roaster, but in this another project I have to migrate an EJB 2.0 to 3.0, this is a Java standard project and is no more supported by any Wildfly 8+, WFLYEJB0450: Entity Beans are no longer supported, what is your suggestions about this specific kind of migration process, I found some migration tools, but finally no one works well.

Thanks again
Carlos Bustamante


This comment has been minimized.

instantiationexception commented Mar 5, 2018

Hi Adam,

How should I use JDBC DataSource given by container? I call getConnection(). Do I have to close it? Do I have to close only Connection or also PreparedStatement and ResultSet? Are SQL queries invoked in current JTA transaction? Throwing exception rollbacks transaction?


This comment has been minimized.

arjantijms commented Mar 5, 2018

@ Eng-Fouad

Do you think that JSF is going to be deprecated any time soon?

Speaking ahead of Adam (he can still give his own opinion, of course ;)), but as JSF EG member and Mojarra committer I can assure you that we have no plans whatsoever to deprecate JSF any time soon. Instead, we have lots of plans to modernise JSF, basically moving whatever we can to CDI, removing the really deprecated stuff, and perhaps make some features optional (move them to separate jars). All of this of course depending on how the new Eclipse process exactly will be and whether the other committers agree with these plans etc.

In my personal opinion, both server side frameworks such as JSF, Spring MVC, Ruby on Rails, etc have their place, as well as client side frameworks like Angular. Both have their own advantages and disadvantages.


This comment has been minimized.

vanuatoo commented Mar 5, 2018

Could you please take a look at the project

I want to achieve the following:
From the managed bean invoke the business method of EJB and if the person exists throw business exception which is caught and appropriate error message is displayed.

I have several questions:

  1. Is this is a good approach when developing JSF applications?
  2. If I don't call EntityManager.flush() business exception is not thrown. Is calling flush a correct way? If not please propose the better one.

This comment has been minimized.

betxaburu commented Mar 11, 2018

Hello Adam,

I've done some of your great courses and have seen lots of your videos, normally just listening. Today I come with my first question, hope I make myself understandable.

I've been able to work really well with JsonB in "simple" objects and also Collections of "simple" objects. But... ¿Is there any way to serialize/deserialize "complex" objects (I add an example of what I mean with complex)? I've been trying and I don't see the way. I imagine it should be achiveable, but my first impresion is JsonB extrugles to map objects with properties of another type of objects. An example of what I'd like to map:

class CarDTO {
private String model;
private EngineDTO engine;
private BrakeSystemDTO brakes;

Thanks Adam and continue doing as always a really great job,


This comment has been minimized.

tmulle commented Mar 16, 2018

Hi Adam,

Just want to say thanks for all your videos! They are awesome and I recommend them to all my colleagues as well as your books.
I’m a long time viewer.

I was wondering if you could help me debug something. I was trying to replicate your code from your youtube video:

And when I run the code and hit http://localhost:8080/async/resources/answers in the browser it just hangs.

When I try to debug the code I can see the event being fired but the CDI observer never kicks in and receives the event.
When I print out the “consumer” variable to the console right after firing the event it shows something like:


I thought maybe that somehow the event listener is waiting for a Consumer and in reality Consumer is being fired? Just a wild guess..

Here is the link to all my code. I think you should be able to get it.

Is there anything you see wrong? Maybe something simple and I overlooked something?

I’ve run this on both WildFly 10 and Glassfish 4.1.1 and they both hang right after they fire the event.

UPDATE: I've just tested this same code on WildFly 12 and it still hangs.


  • Tim


This comment has been minimized.

eyalyatir commented Mar 26, 2018

Hi Adam,

Do you know of any Java EE frameworks that add client (service provider) support for SAML 2.0 SSO profiles, something like spring SAML framework but for Java EE? For example, a framework that uses the Java EE Security API.
I need to create a project that can use different 3rd party identity providers for the authentication\authorization process and I don't want to add spring just for that.
I heard about keycloak but it looks that it's for creating an identity provider and not just a service provider. Am I wrong?



This comment has been minimized.

frifle commented Mar 26, 2018

Moin Adam,

thanks for your approach using plain standard javascript only. I really appreciate that and I think it is very helpful in long term support applications.
In my projects we are visualizing machine data in an ui. We are currently using javaFX and have to provide a web-ui in near future, for which we want to build a javascript-application. For us the main benefit of FX is databinding, esp because we have to deal with complex model objects. What do you think, how do you implement a two-way-databinding using plain javascript?

In practice a machine has a name, some main data and a set of sensors with number and data. An example json of a machine might be


The machine has a rest service to read and change main data, to read, add and remove sensors and to change some of sensor values. It also offers a web socket that pushes messages whenever sensors change (add, remove, change value).
The js-app visualizes that machine. It shows gauges with current sensor values and their variation in time. Even some meta-gauges that show calculated values. Further it offers input fields and submit-buttons to change the main and some sensor data.
In js-code we would like to have a single model-var with the machine data. We would like to bind that model with the web-socket,
the rest-calls and the several ui-dom objects.

How do you do that in plain standard js without ending up in a event-listener-hell?

Thanks, and greetings from Hamburg!

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