Yearly archives "2015"

Ninth Coimbra JUG Meeting – CDI: How do I?

posted by Roberto Cortez on

Last Thursday, 9 July 2015, the ninth meeting of Coimbra JUG was held at the Department of Informatics Engineering of the University of Coimbra, in Portugal. The attendance was great. We had around 30 persons and considering that July is a month where a lot of people go on vacations, we can’t complain. We had the pleasure to listen to António Gonçalves talking about CDI. A great opportunity to interact with one of the greatest experts in CDI and Java EE in general. The best of all: it was in Portuguese!

In my opinion, CDI is a specification with great potential. It will probably become one central piece of all the other specifications in the Java EE world if is not already. For that reason, it makes sense to dedicate sessions to CDI CDI. Even more, when a lot of developers don’t know it is out there and others use little bits, without knowing that they are using CDI. Not many people from the audience was using CDI. António, demonstrated some of the core features of the specification. With the help of JBoss Forge, António created a small web app and showcased Dependency Injection, Qualifiers, Producer, Scopes, Alternatives and Events.

Coimbra JUG Meeting 09

As always, we had surprises for the attendees. IntelliJ sponsored our event, by offering a free license to raffle among the attendees. Congratulations to Vitor Loureiro for winning the license. Develop with pleasure! We also handed a few Tomitribe and ZeroTurnaround t-shirts.

Here are the materials for the session:


Devoxx UK 2015 – The League of Extraordinary Developers

posted by Roberto Cortez on

The third edition of Devoxx UK 2015 was in London, between 17th and 19th June. This was my first conference since I joined Tomitribe. The dynamics were a little different for me this time. I actually had a triple role: attendee, speaker and exhibitor. Since Tomitribe was also sponsoring the event I had to spend some time at our booth to interact with other developers using TomEE and to promote to the ones that don’t know it yet. During that time, we also worked to push out the latest release of TomEE with most of the Java EE 7 support!


Devoxx UK 2015 VenueDevoxx UK was held at the same location as last year: The Business Design Centre. This year, more rooms were available, since the number of attendees was also higher. I don’t have the exact number, but I guess that close to 1 thousand might have attended the event. The Exhibition Hall was more or less the same, but I was surprised to see that some usual sponsors didn’t make it this time. The Community Hall pretty much had a non-stop Hackergarten well managed by Heather VanCura. By the way, what is wrong with the picture? I rule as a photographer, right? 🙂


The program was interesting enough, a lot of diverse subjects and you had five options to attend on each scheduling bracket. I was not always into sessions, since I also needed to spend some time in the Exhibition and Community Halls. Not a problem, because all the sessions were recorded and are going to be available on Parleys, which is cool. These are my top 3 sessions (from the ones I have attended):

You should get the first two sessions on Parleys. But the third one is already available:

Also, have a quick look to this awesome Ignite Session by Tonya Rae Moore:

My Session

I’ve got to speak about the Five Ways to Not Suck at Being a Java Freelancer. It may sound a little strange, since I’ve put the Freelancer life on hold. I’ve submitted the session before that event and I think it’s still valid to provide some of my experience during my Freelancer life. Here is a session about it:

vJUG Reading Club

This is not exactly related to the conference itself, but since I was in London I’ve met with my good friend Simon Maple to conduct our second Book Reading session. If you are not aware, vJUG started a new initiative: the Book Reading Club. The idea is for the attendees to gather around a book, read it and discuss it. We started with the awesome book Effective Java by Joshua Bloch. We had our second meeting around the book and it was fun to hear Josh explain some of the decisions made around the development of the Collections API, Generics and For each statement. A must see:


The Community was awesome as always! This time I had the pleasure to have with me some very good friends from Portugal:

Devoxx UK 2015 PT Community


When thinking of stuff to do in the Hackergarten, I had the idea to write a small piece of code to perform Method Caching using the new JCache API. I’ve soon discovered that I’ve gotten beaten by Andy Gee (no hard feelings). Anyway, we had some interesting discussions about it with Bruno Baptista and Sebastian Daschner. Check the result: JCacheExamples.

Java EE BoF

Also on the Java EE BoF we had the usual discussion between Java EE and Spring. In my honest opinion, I think this discussion is pointless. Both technologies can be used together and everyone is free to pick the parts that fit their project more. On the other hand, I think that Spring has done a fantastic job with website. Java EE has a lot of information, but it’s all spread around the Internet. I believe that this causes a bad impression to new developers and in the end they may end up favouring Spring more.

Also, the adoption of Java EE 7 has been slow in the organizations. There is no Application Server support yet and companies are lacking the resources to perform the migration. I’ve personally been working in a Java EE 5 to 7 migration and I intent to make a session about it.

20 Years of Java

Do you have any idea what was going on when Java was born?

Devoxx UK 2015 Java 20 Years

During the event, there was a lady taking polaroid pictures of developers. These pictures went into a wall and organized by the year you wrote the first line of Java code. I remember that it was in 1996 for me. I was writing an HTML website, but was unhappy that I couldn’t do any kind of dynamic behaviour. Searching on the web, I’ve found the solution: Java Applets! I bought a book called “Learn Java in 30 Days” and I wrote my first line of Java in the Notepad. I wondered where was IntelliJ at that time!

Final Thoughts

That’s all! Hope you enjoyed this report. Cya next year!

Codenvy setup to demo applications using Docker: Java EE 7 with Angular

posted by Roberto Cortez on

Development tools have been evolving over the last few years. Github revolutionized the way we share and contribute code between projects. Docker made distributions of applications much easier by allowing you to provide an environment for your application to run. Both these technologies simplified the distributions of your applications, but there is still a pain point. Developers that want to tap into your source, edit and build it still have a hard time to set up all the tools. I believe that Codenvy might be the tool to fill this gap.

CodenvyWhat is Codenvy? Codenvy is an IDE in the cloud. You can use it to view, edit, build and deploy code. All of this with just a browser. Codenvy integrates closely with Github and Docker and here is when things become interesting. This allows you to set up an environment that you can share with anyone. Why is this interesting? I already had a few readers asking me for help to set up their environments because they struggle to do it themselves. Several combinations of IDE’s and Operating Systems make the task difficult. Maybe there is another way.

My application about Java EE 7 and Angular is probably the most popular I have. I’ve decided to provide it in Codenvy to hopefully make it easier for all of you that want to try the application out.


After you signed up for Codenvy, you can easily create a new project by pointing your working sources to a git repository. In this case we are going to use, of course the Java EE 7 with Angular Github repository. You might need to specify to Codenvy that this is a Maven project. If everything was setup properly, you should get something similar to this:

Codenvy - JavaEE 7 Angular Project

In the IDE window, you can browse the code with syntax highlighting and basic code completion. You can also build the project with maven, if you use the Build menu.


Checking the code is nice, but we are more interested in actually running the code. Codenvy uses a preset of Docker containers to cover a large number of application servers and environments. There can be found in the Runners tab. Unfortunately, there is no Runner provided for Wildfly and the Glassfish one, doesn’t come with the required database. I’ve ended up by writing my own Docker container to provide a custom made Runner for the Java EE 7 Angular sample application. Here are the Dockerfiles:

Codenvy Wildfly Dockerfile

This Dockerfile is just to set up the environment needed to run the application. Add Java and Wildfly to the base Codenvy container.

Codenvy JavaEE 7 Angular Application Dockerfile

This Dockerfile is to map the source code available in Codenvy to a folder in the Docker container. In this way, we can then deploy the code to an application server.

Don’t bother too much about this. Codenvy will import into the project the Dockerfiles that are stored at the project structure in .codenvy/runners/environments/[NAME]. Since I added my runner to the project sources, this will be imported automatically.

Run the Application

To run the application, just press the Play button in the top right corner. You should see the log of the container starting up and also an url at the bottom. This url is the one you need to use to access the application.

Codenvy - JavaEE 7 Angular Runner

And that’s it! You can now play with the application! You even have a Terminal at your disposal.

Sharing the environment

It was easy to set up the environment here, but wouldn’t it be cool if we could just share it with other people? You could do that by using Factories. Just import your Codenvy project into a Factory and you have available an url to share, which will set up everything for you. So, to access the Java EE 7 Angular application, please use:

A few problems

Unfortunately, I’ve also encountered a few problems when I was setting up the environment.

  • The code does not get updated in the mapped folder of the running container. If you make changes to the code, you need to restart the container. Even if they are just HTML or Javascript changes for instance.
  • In Safari the Runner buttons are not visible, but they are clickable.
  • In Firefox I couldn’t type a dash or other special characters in the terminal.
  • Terminal sometimes is not visible.

The code not updating is a real pain. Other things are minors. I hope that this could be fixed soon.


Codenvy is a very impressive tool, if we take into account that we are talking about a cloud browser base IDE. I don’t think that Codenvy is going to replace conventional IDE’s. Although it’s a great alternative to distribute your applications and give the chance for other developers to try them out with minimal effort. Again, here is the link for the JavaEE 7 with Angular application:

Check the related posts:

Java EE 7 with Angular JS – Part 1
Java EE 7 with Angular JS – CRUD, REST, Validations – Part 2

Joining the Tribe

posted by Roberto Cortez on

TomitribeToday, I’m officially part of Tomitribe. I’m very excited to work with all the amazing tribers working hard to make TomEE a compelling Java EE server.

Some of my readers follow me because I work as a Freelancer and this move may confuse you. Let me assure you, that I’m not joining Tomitribe because I was unhappy with my Freelancer career. In fact, when I’ve started as a Freelancer a couple of year ago, I had no idea how things were going to turn out. Today, I can say that it was the right move. I had the chance to work on my own stuff, travel to conferences around the world, met a lot of different people and have fun in general.

In Tomitribe, I believe I will be able to do all the things that I love as a Freelancer and many more. Until now, I only developed or built applications that sit and run on a server. From now on, I have the chance to work on the server itself. Tomitribe is still a startup, a small one, but with incredible potential. After working for a few major corporations, I’m eager to help and grow something from the ground up. This was just an opportunity that I couldn’t refuse.

I have to say thank you to Decare Systems Ireland and Anthem for two wonderful years. They always understood my needs and gave me the freedom to explore my own things.

Moving forward, a big thanks to David and Amelia for believing in me and bringing me to Tomitribe. I hope I can full fill your expectations. Cheers!

Tomitribe Team

I’m sorry you are missing Andy, but I couldn’t find a better picture 🙁

Anyway, you can expect me to keep the blog running with awesome and independent content. Thank you for reading!

Wildfly, Apache CXF and @SchemaValidation

posted by Roberto Cortez on
tags: , ,

Over the last few days, I have been working on an application migration from JBoss 4 to Wildfly 8. The application is using different technologies, but we are going to focus here on XML Web Services, JAX-WS. Yeah, I know that they are not trendy anymore, but these were developed a long time ago and need to be maintained for compatibility issues.

Anyway, the path to migrate these services was not so easy. I’m sharing some of the problems and fixes with the hope that these could help other developers out there stuck with the same problems.

Sample Definition

Here is a sample of a Web Service definition in the old system, JBoss 4:

Luckily, most of the definition is using standard Java EE annotations. Only and are from the old JBossWS libraries.

We can easily get rid of since we are not going to need it in the new application. For reference, it’s used to set up extra configuration data to be predefined with an endpoint. Check the documentation Predefined client and endpoint configurations.

We want to keep For reference, this annotation validates incoming and outgoing SOAP messages against the relevant schema in the endpoint wsdl contract. Since the annotation no longer exists in JBossWS we have to use Apache CXF, which is the underlying implementation for JAX-WS on Wildfly.


Here are a few of the problems I’ve faced:

SchemaValidation Annotation

The annotation doesn’t exist anymore. You have to use the annotation org.apache.cxf.annotations.SchemaValidation from Apache CXF.

Add the following Maven dependency to use the Apache CXF annotation:

Also, notice that in the original annotation we could define an errorHandler property. The old application used a custom error handler to set a custom error message on schema validation errors. There is no equivalent in the new annotation, so we need to do it in another way. To replicate the old behaviour I’ve used Apache CXF Interceptors. Create an interceptor class and extend AbstractPhaseInterceptor. Here is a sample:

And you can use it like this:

Interceptors are used by both CXF clients and CXF servers. There are incoming and outgoing interceptor chains being executed for regular processing and also when an error occurs. In this case, we want to override the Schema Validation message, so we need to bind our interceptor in the error outgoing interceptor chain. You can use the annotation @OutFaultInterceptors for that behaviour. Each chain is split into phases. You define the phase where you want the interceptor to run by passing the Phase.MARSHAL in the constructor. There are other phases, but since we want to change the error message we do it in the MARSHAL phase.

Different WSDL

The old Web Services had the WSDL file being auto generated on deploy time. Unfortunately, in some situations, the WSDL generated by JBoss 4 and Wildfly 8 are different. This can cause problems with your external callers. In this case the main problem was in the Schema Validation. Requests that were valid in JBoss 4 were not valid anymore when being executed in Wildfly 8.

The reason for this behaviour was in the target namespaces. If you are using annotated @XmlRootElement pojos in your Web Service parameters, without defining the namespace property in the annotation, JBoss 4 WS generated the target WSDL element with a black namespace. Apache CXF will use the Web Service default namespace to bind the WSDL elements if they are blank. For reference, this is done in CXF code:

This could be fixed by changing the CXF code, but we opted to place the old generated WSDL file in the migrated application sources and include it in the distribution. It’s not auto generated anymore, meaning that we need to manually generate the WSDL if we change the API. We need to be careful to make sure that we are not breaking anything in the WSDL. This approach seemed better than having to maintain our own CXF version. We could probably submit a fix for this as well, but we believe that JBoss 4 behaviour was not intended.

Start CXF

To use specific API’s from CXF, is not enough to have a project dependency for it. In fact, the first few times I’ve tried the changes, nothing related with CXF seemed to work. This happens because Wildfly it’s only looking for the standard Java EE JAX-WS annotations. To have all the CXF behaviour working, we need to tell Wildfly that our application depends on CXF, even if the libs are already on the server. Yeah, it’s a bit confusing.

The application is deployed in a EAR file. So you need to create a jboss-deployment-structure.xml and add the following content:

Using a MANIFEST.MF in the WAR file apparently doesn’t work if it’s deployed inside an EAR file. For more information, please check Class Loading in WildFly.

If you want to use other CXF features, especially the ones linked with Spring, thing might be a bit trickier. Have a look into this post: Assorted facts about JBoss. Fact 6: JBoss and CXF: match made in heaven.

Final Definition

This should be our final definition for our Web Service:

As you can see, the required changes to migrate a Web Service from JBoss 4 to Wildfly are just a few. However, there are a few minor details that can block you for a long time if you don’t know the details. Maybe you have a different setup and the problems that you face are different. This can also help if you are just trying to setup CXF with Wildfly Anyway, I hope that this post can be useful to you.