JavaOne LA 2016 – Part 2 – Being a Speaker

It’s been really really difficult to keep on posting here… I got to deal with this!

On the second part of the serie “JavaOne LA 2016”, now I will share some thoughts about the amazing experience of being a speaker in a big event like JavaOne.

Some people would ask: “why being a speaker?”, “why give a talk in a conference?”, “why expose yourself?“.

For me this is all about improving yourself and improving your career. That’s why I decided to give myself a try this year and submit papers to some of the most important IT events in Brazil and in the World.

To prepare yourself for this kind of task you should use some skills that maybe you don’t use in daily basis (specially if you are a developer/architect like me). You need to research, write, prepare presentation, and research again, build demos… you need even to smile when someone ask a question that you have absolute no idea of what he/she is talking about!

(This last part I do in daily basis…)

Being at JavaOne LA was even more interesting as it is probably one of the biggest IT events in Latin America (if not the biggest one). There you can find tons of people to share experience and interests. And, even better, I could find tons of people that know much more than me and are much better than me in so many ways (not that this is a hard work to accomplish…).

Oh… talking about my talk… here you can see the presentation! ūüėČ

Worthy of mention are my friend Bruno Souza and Andre Carvalho. Our partnership was key to have this task done.

Next September we all three will be at JavaOne US (San Francisco) giving another talk. Surely another great experience worthy of a couple of posts!

Leave a comment if you feel like too… ūüėČ


JavaOne LA 2016 – Part 1 – Best Talks

Wow! So much time without posting. This is bad… very very bad…

But that’s ok, let’s update the things¬†here.

In the end of June happened in Sao Paulo one more edition of JavaOne Latin America. The Brazilian community is so vibrant that this event keep alive thru the years, stronger than ever.

This year was really different for me as I was there as a speaker for the first time… but this part I’ll let for the second post in a few days! ūüėČ

In this post I’ll share the best session for me at each day. There were a plenty of awesome talks, but those were really outstanding.

Day One

Developing Scalable REST API’s with JAX-RS and Java 8 (Desenvolvendo¬†APIs REST¬†escal√°veis com¬†JAX-RS¬†e¬†Java 8″)

In this talk, F√°bio Velloso (Summa Technologies – @fabiovelloso) did an awesome job merging the most advanced and recent Java technologies in a very nifty way. If you would like to check it out, take a look here.

Day Two

IoT Surfing Service: a IoT microkernel (“IoT Surfing Service: um microkernel para Internet das Coisas”)

Here we had the “The Java Champion Couple”, Vinicius Senger (@vsenger) and Yara Senger (@yarasenger) showing what we programmers should be thinking about in daily basis. Their “IoT Surfing Service” and “IoT Surfing Board” maybe are the most advanced IoT projects in Brazil (even in the world) in this moment.

Check the project here.

Day Three

Java Community Keynote

Definitely the highest point in the whole event. The community leaders created a reality show called “The Coder” (based on the real “The Voice”), where 5 guys were at the finals and should present a project to win the contest.

The projects, in fact, were community tips of “what you should be doing in Java right now”. The areas was: Java 8, containers, IoT, machine learning and JUG engagement.


A really nice event and an excellent opportunity to meet people and invest in your network. You should definitely try to be there in the next year!

EJB Injection with JBoss 6 and Struts 1

Why the heck somebody would still use Struts 1? Well for a bunch of reasons… One of them could be a whole team already trained on it… another could be some company legacy systems using it.

And why would you use JBoss 6 with all brand new versions of this and another application servers? Worst: with all those application servers already certified for Java EE 7? The answer is: the customer has a whole environment based on it… and it is huge.

Ok, so let’s do it…

But you are a cool programmer and wanna use EJB 3 and get all its benefits. And being a cool programmer,of course you wanna just open your Action code and write:


Right? No easiest way to use an EJB to handle your action methods…

Wrong! Why?

  1. In a Struts Action the container is not handling the Action. The framework (Struts) is;
  2. So the Action instance were not created by the container;
  3. If the container didn’t created the Action instance it doesn’t get “involved” in the request cycle;
  4. The framework has no damn idea of what is the “@Inject” command. So it will ignore it;
  5. If the container is not involved and the framework doesn’t know what to do with it, how do you think you will get an EJB instance being injected if it is supposed to come from the container?

Well you probably already got the answer. The injection won’t happen! The “myEJB” will be null.

Please, please, please… don’t do it:

MyEJB myEJB = new MyEJB();

You will surely get a new instance, but it is not handled by the container. So you will need to do all the container duties (transaction management, pooling, security, concurrency, entity injection, etc) with your own hands. Not cool at all… (specially for a cool programmer…).

So what would you do? Answer in four classes!

The entity:

@NamedQuery(name=FooEntity.FOO_FIND_ALL, query="SELECT f FROM FooEntity f ")
public class FooEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	public static final String FOO_FIND_ALL = "FooEntity.findAll";

	private long fooId;

	private String fooName;

	public FooEntity() {


	public long getFooId() {
		return fooId;

	public void setFooId(long fooId) {
		this.fooId = fooId;

	public String getFooName() {
		return fooName;

	public void setFooName(String fooName) {
		this.fooName = fooName;

The EJB:

public class FooEJB {

	public static final String JNDI_NAME = "java:global/fooenv/ejb/foo";

	EntityManager em;

	public FooEJB() {

	public List<FooEntity> findFoo() {
		return em.createNamedQuery(FooEntity.FOO_FIND_ALL).getResultList();

The Service Locator:

public class ServiceLocator {

	public static <T> T getFromContainer(Class<T> clazz,String name) throws Exception {
		InitialContext ctx = new InitialContext();
		return (T) ctx.lookup(name);

The Struts Action:

public class FooAction extends DispatchAction {

	private FooEJB fooEJB;

	public FooAction() {

    	try {
			fooEJB = ServiceLocator.getFromContainer(FooEJB.class, FooEJB.JNDI_NAME);
		} catch (Exception e) {

    public ActionForward fooAction(ActionMapping actionMapping,
            ActionForm actionForm, HttpServletRequest request,
            HttpServletResponse response) {

    	request.setAttribute("findFoo", fooEJB.findFoo());
        return actionMapping.findForward("fooAction");




  • The entity: just a regular entity. Just one note to the static property
    FOO_FIND_ALL that I use to name the named query and use it across the project;
  • The EJB: pay attention to the¬†JNDI_NAME static property. It will used to registry the EJB in the container. See:¬†@EJB(name=FooEJB.JNDI_NAME). And will be used to reference the same JNDI name in the Service Locator;
  • The Service Locator: a regular one. Receive an EJB type and name, do its job and return the instance;
  • The Struts Action: on each instance it requests to the container an EJB instance thru JNDI. As the container give the instance all the cycle is handled by it, including the EntityManager injection (@PersistenceContext).

So you can have all the benefits from a managed bean with just a simple locator and can use it with your legacy environment!

Even better: no XML files, no interfaces, no complication at all.

Do you have another good solution? Feel ok to tell me in the comments bellow.

10 people/profiles to follow on Twitter

If you spend some time finding people from your working area to follow on Twitter you will probably spend many days doing this. But are they all worthy of following?

Narrowing down your options is key to keep your references really optimized. Here I will show you some of my favorite people and profiles to follow. Maybe it could help you with your searching!

Comments and impressions of each person/profile are my own. I could be wrong in some of them, so you can feel free the correct me at the comments!

Adam Bien – @AdamBien

If you are very interested in Java EE and Java in general you probably already heard about this guy. For those who don’t know him, he is maybe for Java what Eddie Van Halen is for guitar.

Beyond his Twitter account you will get a lot (tons) of resources from his blog and from his books. Google it!

Bruno Souza – @brjavaman

The “Brazilian Javaman”, Bruno had helped to organize dozens (maybe hundreds) of JUG’s around the world since the first days of Java. His passion and knowledge about Java world are inspiring.

Java – @java

Not a person itself (though it is managed by Yolande Poirier), this is the official Java account at Twitter. The coolest part of this profile is all the awesome articles shared on daily basis.

John Sonmez – @jsonmez

The guy who make me run this blog! Beyond his successful blogging course, John also shares many good career advices thru all his social media profiles.

Bill Gates – @BillGates

Old but gold (sorry, Bill…). Even if you don’t like Windows ecosystem or anything related, we can’t deny that Bill Gates is one of the most influencers of our recent history. In his Twitter account he shares mostly things about his foundation, so don’t expect to see IT things frequently (or even rarely).

Docker – @docker

If you love containers, you should be in love with Docker. And then you must follow its Twitter profile.

News and good articles daily. Even articles from mine already appeared there! ūüėČ

David Delabassee – @delabassee

I attended one talk from Delabassee on the last JavaOne LA and this guy made Java EE 8 sounds pretty easy even with his accent. So he is totally worthy of following.

Stephen Chin – @steveonjava

One of the best and funniest speaker I ever heard on Java community. If there are something happening with Java today, probably he is involved.

Simon Ritter – @speakjava

My first contact with lambdas and streams at Java 8 came from this guy (also on JavaOne LA 2015). Was like learning to read again (I love reading).

Andre Noel – @ProgramadorREAL

Some fun doesn’t hurt and Andre does it very well (funny, not hurting…). He is the cartoonist from “Vida de Programador” (“Developer Life”), a well known Brazilian site with cartoons talking about common things from a developer life with geniality and good humor.

A challenging solution needed

Some years ago I was presented to a project that needed a solution. No news at this point, that is the reality of any IT professional on daily basis.

But then they started talking about the requirements… well, let me show them:

  1. They had a web-based system running in that classical way: a new company pay for using, you install it in some server on their network and everybody inside the company access the system using a web browser (the damn IE);
  2. The system was built in Java 4 and there’s was no chance to upgrade¬†to Java 7 (the latest version that time);
  3. The system was deployed at Tomcat 4 and there’s was no chance to upgrade;
  4. They didn’t use connection pooling for database connection. Worst: each user opens a connection with database when login into the system and that connection was hold into the session. Here they would accept a refactoring, but the whole scenario won’t;
  5. They needed the system to be available online in a SAAS way:
    • Each new user would create its new account online and pay the signature with credit card;
    • The system couldn’t be refactored for avoiding users to see each others data. Talking in another words, a system built for running in one single company at time needed to be available in one single platform, for as many companies¬†as possible at time, protecting the users data as it was supposed to do, and COULD NOT be refactored for it.
  6. The budget for the project was almost zero (no news either);
  7. The deadline was almost instantaneous.

My first reaction was laughing, but then I realized they was talking serious… “Ok, let me think for a day…”

Well in fact it didn’t took me a long time to design the right solution. I have to be honest, it wasn’t the prettiest and neither the coolest solution I had ever did, but was fine for what they needed to do, in the way they wanted to do and spending the much they wanted to spend.

The big¬†challenge:¬†segregate the users data in the same environment with¬†a system that just was not built for it and couldn’t be deeply¬†refactored

(Big subtitle for a big problem)

To solve this challenge I did one thing that solved many challenges in this project: a facade application. The user could not see it, but he/she was in fact using two systems: one, the facade, was responsible for managing the users, grants, profiles, signature status and, more important, the authentication and database redirection; the other one, the old system.

Instead of keeping the database access tied to application configuration files, I moved it to a session variable. So when the facade application did the authentication and found the right database for that user/company, it passed those data to the system (cross context applications) and then it could open its connection and do whatever it needed to do as nothing different was happening.

When a new user registered at the company site, this same facade application started creating that user: registering account, authorizing the payment and… creating the database. Each new user won its own database in the system¬†database server.

So there was¬†a “model” database and each new database was created based on it.

To support it we created five database instances in the database server and created a “manual” round-robin that created each new user in the instance that was less loaded. The facade application was also able to do it in many servers if they were mapped.

So we did a “database load balancing” manually! ūüėČ


Now…¬†everything is just funny

The really big problem was to separate the users data. Once it was done in a skillful way, the rest of the project was the usual stuff: buttons here and there, popups, etc, etc, etc.

The system was deployed in a cloud solution that made the things moving even more faster and cheaper. We probably released the first version in less than a month after the first meeting…


So why the hell I am here sharing this little case. I think we could take some lessons here:

  1. Just because your client is very very very very very restrictive it doesn’t means you can’t find a solution for¬†his/hers problems (even if it sucks…);
  2. The right solution maybe can be the ugly one;
  3. Being creative could save you time, money and headache.


Any comments? Just leave it bellow!