Thursday Sep 05, 2013

Install Fusion Middleware Infrastructure on Oracle DB 12c

This week I had the opportunity to play a little with the new and recently released Oracle DB 12c. This version brings a new approach for databases, calledPluggable Databases. There are plenty of articles and YouTube videos already explaining this and I will not focus this article on it. Instead, I want to help you on How to Install Oracle Fusion Middleware Infrastructure on Oracle DB 12c.
There are a couple of steps and commands to be followed, and some very important observations. Starting with a simple one:

Do NOT execute the RCU installer on top of a CDB.
One more time: do NOT execute RCU on top of a CDB. 

If you do point the RCU tool to install over a CDB, you might get this message:

ORA-65096: invalid common user or role name

Now with this in mind, I believe you have understood that the first step is, obviously, to create a PDB. There are some options, but I will use pure SQL commands.

Step 0 - Use the correct encoding for your Database install

Make sure you have installed your DB with the AL32UTF8 encoding. 
This is recommended, but it might work in case you are using something else.

Step 1 - Create a PDB to hold the FMW Infrastructure Data

The following command will create a PDB called PDBFMW with a user "fmw" and password "welcome1".


Please make sure to adjust the values to your installation. 

Step 2 - Open the PDB for changes

After you have the PDB created, make sure you change its state to READ_WRITE


Step 3 - Fix user privileges

Now you must make sure the user "fmw" has all required privileges. As this is for Development, I will just give everything.


* Important note: I'm not a DBA expert and these might not be the correct privileges for production environment. So please make sure to give only the necessary privileges following the documentation.

Step 4 - Run the RCU tool

This step considers that you have correctly installed Fusion Middleware Infrastructure into your Middleware Home / WebLogic installation folder. In my case, I'm using the full WebLogic + JDeveloper installation package, which brings the FMW Infra bundled. Now go to your $MW_HOME folder and run the RCU tool:

$ cd $MW_HOME
$ cd oracle_common/bin
$ ./rcu

Make sure to use the correct properties to connect to your recently created Pluggable Database:
Database Type: Oracle Database
Host Name: db12c (change to your DB IP address)
Port: 1521
Service Name: pdbfmw (here you use the PDB name)
Username: fmw
Password: welcome1 (or whatever you defined)
Click "Next" and see if it worked. If you are not using AL32UTF8, it will ask you to Ignore. Just do it, but remember: it might not work properly.

Step 5 - Select components and create new prefix

I like to select everything, and use the "FMW" prefix. Click "Next", "Next", "Next", etc, etc, etc... Until it finishes.


You have successfuly created the right database structure for your Fusion Middleware Infrastructure, and now you can create a WebLogic domain with ADF and everything else, pointing to this PDB.

If you have any question, post a comment!

Friday Aug 23, 2013

Java EE 7 OTN Tour 2013 Trip Report - Part 1/2

OTN Tour 2013 is over, and after 7 countries, all I have to tell you is this: #JavaEE7 rocks and people loved it! It is quite coincidence that at the end, I went to 7 cities in Latin America to give my "What's new in Java EE 7" talk plus the Hands-on Lab and other talks like the one about WebLogic 12c and another about GlassFish 4.

In reality, I had also planned to go to Panama City, and San José in Costa Rica. Well, things sometimes don't always go as planned, and I couldn't go to Panama. And when I got to Costa Rica, I was sent back to Mexico because I was not with my Yellow Fever card. But I'm looking forward to Java EE 9, if you know what I mean. :-) In the end, I visited 7 cities:
  • Mexico City, Mexico
  • Guadalajara, Mexico
  • Santiago, Chile
  • Lima, Peru
  • Montevideo, Uruguay
  • Buenos Aires, Argentina
  • São Paulo, Brazil
Now, before I talk about each city, let me explain something to you really important: OTN Tour is organized by LAOUC, the Latin America Oracle Users Community. And at each participant city, local OUGs help to organize, set a venue, local partners as sponsors, and also work with the speakers' agenda. Oracle does sponsor these events, both by supporting the local event,  as well by sponsoring Oracle ACEDs to travel with the tour. If you want to become an Oracle ACE, all you need to do is to learn about the Oracle ACE program.

We all know how Database-driven Oracle has been for the past decades, and we understand that most off the Oracle User Groups are more interested on Database stuff. But this is changing. There was a lot of interest during the whole tour on Middleware and Development technologies such as Java EE, ADF, WebLogic, and GlassFish. Dana Singleterry joined me in this tour and brought with him a lot of information on ADF 12c and ADF Mobile. Don't forget to follow him on Twitter.

By the way, this tour was great to improve my Spanish. Yeah, you read it: Spaaaanish. I'm from Brazil, and we speak Portuguese there. And Brazil is the only country in Latin America that speaks Portuguese. To improve my learning, at every country I visited I tried to learn local slangs. So for each city, I did a special slide for Java EE 7. Really, you gotta learn local slangs to be cool with a 2nd/3rd language :-P Anyway, it all started on July 21st in the morning...

Mexico City (DF), Mexico - July 26th

Like I told before, I could not go to Panama nor Costa Rica, so I stayed in Mexico the first week, and worked with Oracle folks there, did customer meetings, worked from hotel, etc. On Friday I finally started. Great venue at Egade Business School as well a very nice setup with coffeebreaks and lunch for everyone. Kudos to ORAMEX, the local OUG. In Mexico, I gave my Java EE talk, and did the Hands-on.
Spanish Lesson Part 1
By the way, chingar is a word in Mexican Spanish that means a lot of things, both for good or bad contexts. It can be used so widely that there is even a "chingonary", or a dictionary on how to use it, that I had to buy one for me in a local bookstore. In this case, it means "Java EE 7 has so many new technologies inside", but of course using a slang, almost a swearing word :P

Pictures: Facebook or Google+

Guadalajara, Mexico - July 27th

Guadalajara was not part of the official OTN Tour. Actually, it was an Oracle Java Day organized by the local Oracle office, with people from the Oracle Curriculum Development Team and where some of the great content of Oracle Learning Library is coming from. This conference was led by Edgar Martinez and I can't say how thankful I am. Edgar and his team did a great job. Everything was perfect: the great staff team, pizza for lunch, the office, the setup, the trail, and last but not least, the happy hour! Edgar blogged about this as a guest at Java blog, so you may want to read more about this there. Here I gave my Java EE 7 talk, and the hands-on. A lot of people showed up!

More pictures of the event on Flicker, my Facebook, and my Google+
Also, all the registration fee for this event was donated to a local orphans institute. Later, perhaps the best moment of it all: when we were walking on the street after the event looking for a place to dinner, we met with the supporters of this institute.


Santiago, Chile - August 1st

Santiago is an incredible city. It holds about 30% of the entire population of Chile, and I would guess perhaps more than 50% of the entire economy there. It is one of the most modern city, with great infrastructure and easy access to several touristic places. It was where I could enjoy a tourist-like day, so expect to see regular pictures. :P

Spanish Lesson Part 2
The term bacán in Chilean Spanish means "cool". I had to change my slide here.
The conference here happened at a very nice university, close to a subway station, and here I gave my Java EE 7 talk the hands-on again, and then the GlassFish in Production Environments. I met with great people here both from Oracle User Groups as well some people from the local Java community. It was also where I first met and talked to Tim Hall, really great guy, Oracle ACED, an expert on Oracle Database. If you have any questions about OraDB, follow him on Twitter and check his website,

Pictures: Facebook or Google+

Lima, Peru - August 3rd

One day after Santiago, I was flying to Lima for the third country of my list. Lima has really nice areas, like Miraflores so if you plan to visit Peru one day, make sure you stay there to enjoy the best view of the Pacific Ocean. For night life, visit Barranco, full of bars, restaurants, and nightclubs.

Here I gave my traditional Java EE 7 session, catch up with local Oracle people, and had perhaps one of the crowdest room in the whole tour. The question I made to the attendees in the picture below was: "Did you like the new stuff in Java EE 7? Raise your hand if yes!!!"

Pictures: Facebook or Google+

Spanish Lesson Part 3
The term chévere in Peruvian Spanish means "awesome". It is similar to bacán from Santiago, Chile. But people here prefer to be different. :-) So I had to change my slide again.

More next week
I still have to talk about was this tour in Argentina, Montevideo, and finally Brazil. But I will leave that for the next post.

By the way, to keep posted on this, follow me on Twitter! Or Google+... Or Facebook... :-)

Thursday Jul 25, 2013

Como instalar o GlassFish 4.0 (ZIP) [pt_BR]

O jeito mais rápido e fácil de instalar o GlassFish 4 em servidores é utilizando a versão ZIP do instalador. O ZIP já vem com um domínio (domain1) configurado, e por isso o tamanho do arquivo é maior que o instalador nativo (onde um domínio será configurado durante a instalação).


  1. Entre em e clique no link abaixo de Zip (quick start). No momento deste post, a versão disponível é a 4.0.
  2. Descompacte o ZIP em um diretório de trabalho:
    $ mkdir ~/Work
    $ cd ~/Work
    $ unzip ~/Downloads/
  3. Entre no diretório bin do GlassFish:
    $ cd glassfish4/bin
  4. Execute o seguinte comando para inicializar o domínio domain1
    $ bash asadmin start-domain domain1
  5. Abra o seu navegador e vá para o endereço http://localhost:4848

Pronto! Servidor up and running!

Sunday Jul 21, 2013

OTN Tour 2013 in Latin America

The Oracle Technology Network Tour 2013 has already started, bringing several Oracle and non-Oracle speakers to OUGs (Oracle User Groups) to countries across Latin America. You can check the official OTN Tour 2013 page of the tour to follow up with agenda, dates, speakers and other information. Last year I participated giving talks in Uruguay and Argentina about Oracle WebLogic 12c. That time, I had recently joined Oracle and didn't know much about it. But this year though, I wanted to do more.

Some facts about Latin America
Latin America includes all countries between Mexico and Argentina, most of them who speak Spanish, and where Brazil the only country that speaks Portuguese (not exactly like the one from Portugal, and definitely not like Spanish), and there are other languages too, like French (in French Guiana). These are also know as Romance languages, derived from latin. Spanish is the predominant language and that's why one of the challenges for me as a Product Manager and Java Evangelist here is to communicate with these countries, and taking Spanish classes is just part of the solution. Knowing details about each country and Spanish variations is the "advanced" step. In Mexico for example, chingar is one of these advanced things :-) But it must be used carefuly, for obvious reasons

En Java EE 7, hay un chingo de nuevas APIs.

OUGs+JUGs = Bigger community working together
This tour is slightly different from previous years. There will be much more Java content than before, specially because of the Java EE 7 launch. And local JUGs were invited to join the OUGs that usually organize and coordinate each country. If you want to help, go to this post and provide contact information, for future events. OUGs and JUGs working together is quite a new thing, and I see it as a great thing!! 

Countries for OTN Tour 2013
Here is the full agenda , and in bold where I start.

  • Colombia, 07/12
  • Ecuador, 07/15
  • Guatemala, 07/17
  • Panama, 07/22
  • Costa Rica, 07/24
  • Mexico, 07/26
  • Chile,  08/01
  • Peru, 08/03
  • Uruguay, 08/05 - 08/06
  • Argentina, 08/07 - 08/08
  • Brazil, 08/10

Due to agenda and other conferences, I could not come to the first 3 countries, but I am already on the road to cover the rest, starting with Panama next Monday.

I proposed a few abstracts to OUGs/JUGs choose which could work best for each country, and here are the topics:

  • GlassFish in Production Environments
  • What WebLogic 12c Has To Offer to Boost Your Productivity
  • What's new in Java EE 7
  • Hands-on for Java EE 7

Photos and videos
I don't have a plan yet on how, when, or if even I will produce videos. But I brought my camera! Let's see how it goes.

If you want to follow my jorney, connect with my Twitter profile and/or the #OTNTour hashtag.

Join the Tour!!

PS: I will try to write a blog post per country, with pictures, and in the local language. :-) 


Tuesday Jun 04, 2013

Promote Java EE 7 and GlassFish on your Twitter

The launch of Java EE 7 is right ahead. On June 12th we will hear from Oracle executives and evangelists what's all about the new version of the platform. The Live Webcast "Introducing Java EE 7" will have two sessions, and all you need to do to join us and watch Arun Gupta and others, is to go to this webpage and sign up. Also, don't forget to check GlassFish's blog, you know, because it's the reference implementation of Java EE! :-)

But if you really, really love Java EE and really, really want people to join us, why don't you also promote the launch on your Twitter account? Use this background image that fits very nice on your profile, and also don't forget to set the background color to #517E9C.

Let's Make The Future Java... Together!

Friday May 10, 2013

Líderes de JUG de Latinoamérica, Oracle quiere ponerse en contacto

Hola Comunidad Java de América Latina! Dentro de un par de meses, voy a empezar una gira por América Latina para llevar a usted las nuevas características de la plataforma Java EE 7.

Esta gira comenzará en julio en Brasil, en el TDC - The Developers Conference, en São Paulo. Luego, después de eso, voy a empezar mi viaje a través de varios países. Pero para ayudar a terminar mi agenda, necesito tu ayuda!

Todo lo que necesitas hacer es compartir este artículo con alguien que usted conoce o en su red social. , y por supuesto, proporcionar la información que pido aquí. Esto me ayudará a ponerme en contacto con los líderes JUG locales en su país, y planear las reuniones.s.

Su ayuda es muy apreciada!


Thursday May 02, 2013

Integrating WebSockets and JMS with CDI Events in Java EE 7

UPDATE July 15th, 2013
I've updated this blog entry to clarify the issue of integration between WebSockets API 1.0 and other Java EE technologies, and also to link you to the bugs submitted in the WebSockets, JMS, and specially the CDI specification. I want to talk all spec leaders involved in this, specially JJ Snyder, Danny Coward, and Nigel Deakin.

This is a great reminder of how important is your participation during the specification definition process. Please read, test and report any issue you find in a specification before it becomes final. Join the Adopt a JSR program and work with us!


WebSocket is the new kid on the block when you think about Web Development these days. And it is expected that you want to integrate it with whatever is available in your hands. Java EE 7 is coming with cool things beyond this, for example JMS 2.0. And then you wonder: how can I send asynchronous messages to all WebSocket sessions connected to my website? Server push; no polling: for real!

The answer is quite simple: CDI. Also know as the Java EE magic glue. CDI enables a developer to build inter-communication between, apparently, distinct parts of your application. Let's go through all the steps to enable your WebSocket application to send and receive messages through JMS.

1 - Creating the WebSocket Server Endpoint

First we need to build the WebSocket server endpoint that will receive messages from clients, and to also notify clients asynchronously with a server push, with incoming JMS message payloads:

@ServerEndpoint("/websocket") public class WebSocketEndpoint implements Serializable { // this object will hold all WebSocket sessions connected to this WebSocket // server endpoint (per JVM) private static final Set<Session> sessions = Collections.synchronizedSet(new HashSet<Session>()); 

Now you must also add three key methods to this WebSocket: 

@OnOpen public void onOpen(final Session session) { sessions.add(session); } @OnMessage public void onMessage(final String message, final Session client) { ... } @OnClose public void onClose(final Session session) { sessions.remove(session); }

Notice that on onOpen and onClose, we manage all user sessions connected to this endpoint. We will see later how sessions will be used inside onMessage. For now, let's create a SessionBean to send messages to a JMS Queue.

2 - Creating the SessionBean to send JMS messages

Due to missing parts from the specifications, we cannot use @Inject JMSContext inside a @ServerEndpoint WebSocket, and we can't also set a server endpoint as a MessageListener to receive JMS messages. Simply put, integration between JMS and WebSockets (and probably other Java EE APIs) is not straightforward. You can follow the discussion in the following issues:


But fortunately, there are two ways to do this: 

  1. Create a stateless SessionBean that sends messages to a JMS queue
  2. Inject JMS resources inside WebSocket Server Endpoint, and create a JMSContext from the ConnectionFactory


Solution #2 can be achieved using the following snippet, thanks to Nigel Deakin, spec leader of JMS who helped me discovering this issue.

@Resource(lookup="java:comp/DefaultJMSConnectionFactory") ConnectionFactory cf;
@Resource(lookup = "jms/myQueue") Queue myQueue;
public void onMessage(final String message, final Session client) {
try (JMSContext context = cf.createContext();){
context.createProducer().send(myQueue, message);

We are going to use solution #1 and create a SessionBean to forward incoming WebSocket messages to a JMS queue. Create a class named QueueSenderSessionBean as it follows:

public class QueueSenderSessionBean { ... }

This is a simple @Stateless SessionBean. Now, let's add a business method to it, called sendMessage:

public void sendMessage(String message) { ... } 

Quite straight-forward, isn't? One of the great things about JMS 2.0 is its simplicity to send messages to a destination. To do that, we need to inject two objects:

@Resource(mappedName = "jms/myQueue")
private Queue myQueue;
@Inject private JMSContext jmsContext; 

JMSContext is one of the new classes added to JMS API, and is documented here. It encapsulates a Connection and a Session, and makes use of a default ConnectionFactory, now a required resource to be provided by all Java EE 7 certified application servers. Next, all you need is to add the logic to the previously added method:

jmsContext.createProducer().send(myQueue, message);

And you are done with the SessionBean. Next we will add some glue between the SessionBean and the WebSocket to send messages to the JMS destination.

3 - Forwarding an incoming WebSocket message to a JMS destination

All you need to do here is to inject the SessionBean into your WebSocket, and call the sendMessage method inside onMessage of your endpoint. Let's start with the injection first, but due to a bug, we must do constructor injection. Open your WebSocket server endpoint class WebSocketEndpoint, and add the following field:

private QueueSenderSessionBean senderBean;

Now add the following constructor to it:
  public WebSocketEndpoint(QueueSenderSessionBean sb) {
     this.senderBean = sb;

Next step is to simply call the method inside onMessage

We have finished the first part of this application. With this code, you are now able to send a message from a WebSocket client, to a JMS destination. Next, we will do the opposite. Let's push some data from a JMS queue to all WebSocket clients!

4 - Listening to a JMS Destination with a MessageDriven Bean

Funny fact: some developers have not realized yet, but the MessageDriven annotation is not specified by the JMS API. Instead, it is part of the EJB specification, and it can be used not only for JMS, but for many other things. David Blevins from the awesome Apache TomEE realized that, and proposed a small change to the EJB spec, where resource adapters required connectors to provide a messagelistener-type. His proposal though, suggests that you should be able to use an MDB to listen to different things, and the listener interface should be optional. One example is to listen to Telnet commands. Pretty awesome! But let's focus on our use case here, which is specific to JMS.

Now that we can publish messages into a Queue destination from a WebSocket client, we must process them to later forward to somewhere else. Let's start coding our JMS MDB (remember, not all MDBs are implicitly JMS-related!), implementing the MessageListener interface, required by JMS ResourceAdapter connectors:

  @MessageDriven(mappedName = "jms/myQueue")
  public class WebSocketMDB implements MessageListener {
    public void onMessage(Message msg) { ... }

This is the basic code to any JMS MDB. Now let's do some magic... 

5 - Firing CDI events with the JMS Message payload

Remember when I told that we cannot listen to JMS destinations directly from the WebSocket server endpoint due to specification restrictions? Well. We can actually, but using a different technique. If you haven't heard about CDI Events, you should read about it before continuing this tutorial. Done? Ok, let's go. First thing we need is an Event qualifier. Create the WSJMSMessage annotation inside your project:

  @Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE})
  public @interface WSJMSMessage {}

 With a defined qualifier, CDI will be able to connect the firing event with the observer object. Go back to the WebSocketMDB and add an Event dispatcher to it, with the qualifier we created above:

    @WSJMSMessage     Event<Message> jmsEvent; 

 Now let's add the logic to the onMessage method:;

6 - Listening to CDI events within the WebSocket server endpoint

This is the last server-side part of this article, then next you will see how to code Javascript on the client-side. Let's listen to CDI events fired by the MDB, with the Message payload. Open again your WebSocketEndpoint class, and add the following method to it:

public void onJMSMessage(@Observes @WSJMSMessage Message msg) {
        try {
            for (Session s : sessions) {
                s.getBasicRemote().sendText("message from JMS: " + msg.getBody(String.class));
        } catch (IOException | JMSException ex) {
            Logger.getLogger(WebSocketEndpoint.class.getName()).log(Level.SEVERE, null, ex);
        }     } 

Observe the @Observes and the qualifier @WSJMSMessage we defined previously. This is what tells CDI to listen to the fired events by the MDB.

7 - Client-side Javascript to connect with the WebSocket server endpoint

This has been floating around the Internet for a while as it is not Java nor Java EE specific, but anyway it is basically this:

// note the final path is the same defined inside WebSocketEndpoint class at @ServerEndpoint websocketSession = new WebSocket('ws://' + + '/your-app-context-root/websocket');

Here is the final Javascript used by this example, as well the HTML interface.


I hope you have found this article useful to begin your development with Java EE 7, and what are the possibilities of integrating CDI, WebSockets, JMS, and EJB. These are the main points about this article:

  • ability to asynchronously communicate with WebSocket clients (although you can also use session.getAsyncRemote() to send messages asynchronously)
  • ability to do a server push to WebSocket clients at any point in your application
  • ability to scale server-pushed communication to WebSocket client sessions across a cluster using JMS Topics
    This is perhaps one of the most interesting thing about this setup. If you use a Topic instead of a Queue, you will be able to push data to all WebSocket sessions connected to your application across a cluster. There's a know limit of roughly 64k client sessions per web server, and in this example we use a static synchronized Set to hold a reference to them. Imagine now a cluster. We change this to a Topic clustered subscriber, and we are able to scale up server pushed data :-)
The source code of this project is available at my GitHub repository javaee7-jms-websocket-example. I hope you liked the article!

Monday Apr 22, 2013

What's new in Java EE 7 at JUDCon Brazil 2013

This weekend I talked about Java EE 7 at JUDCon Brazil 2013, the session "What's new in Java EE 7? From HTML5 to JMS 2.0". What a great honour to be at JBoss Users and Developers Conference to share with attendees the great work that Oracle, Red Hat, and many others are doing for this platform. Room was packed, with people standing, and so much interest to hear all the cool stuff to come, such as WebSockets, JMS, JAX-RS, JSF and even more. To add some value to this talk, and as I'm a fan of Game of Thrones, I thought that a few images would fit right at this talk :-)

Slides here!

Wednesday Apr 10, 2013

Configure DataSources for Maven Embedded GlassFish


In my previous post I showed to you how to configure Maven and the Embedded GlassFish Plugin to be run with GlassFish 4.0 b83. A comment on that post raised the following question: Is it now possible to setup datasources with GlassFish embedded for testing purposes? The answer is yes! Not only DataSource but any resource. For now, I only tested DataSources but it's working fine. Follow these steps:

  1. Create a file called glassfish-resources.xml inside your WEB-INF webapplication directory with the connection pool and datasource configured, by either:
    1. Adding the content of this Gist into it and edit it with your database information, or ...
    2. Create it using NetBeans as described in this blog post by Arun. Move the file to the src/webapps/WEB-INF folder.
  2. Make sure the JNDI name is similar to this: java:app/jdbc/YourDataSourceName and that it is correctly mapped in your persistence.xml

The most important thing here is to keep the JNDI name with java:app/ prefix. I tried using just jdbc/MyDS on both persistence.xml and glassfish-resources.xml, but it didn't work, shoulting errors in the log related to the __pm suffix issue. So remember the prefix, as this is an application-scoped resource.

UPDATE Also, don't forget to add the following dependency for your Database JDBC Driver inside the <plugin> of Embedded GlassFish. For MySQL, add this:



Tuesday Apr 09, 2013

GlassFish 4 beta and Maven Embedded Plugin

Everyone is looking for an easy way to try out Java EE 7, even before the launch. Specially now where some JSRs just got Final, like JMS, Batch, JSON, and others. Arun already gave a great tip for anyone that want to try a Java EE 7 project with Maven, but the archetype offered by the Mojo project at Codehaus is missing one important thing: the Maven Plugin for GlassFish Embedded.


This plugin is great because developers don't even need to download, install and configure GlassFish locally. All they need to do is to have JDK and Maven installed. Then they can choose whatever IDE works best (I'm working right now with NetBeans, but I'm also a Sublime Text 2 big fan). It's a simple 3-step command:

  1. $ git clone http://myrepo/myproject
  2. $ cd myproject
  3. $ mvn embedded-glassfish:run
    ... then you wait until the Internet is being downloaded into your local repository ...

Done! Simple as that, a project that does not depend on any installation besides Maven and JDK (ok... Git too, in this case). Now how does the pom.xml must be set up with the Embedded plugin? Follow these steps:

  1. Create a project based on Codehaus archetype, like Arun mentioned in his blog. I'm copying the command line here for the sake of browser history:
    mvn -DarchetypeGroupId=org.codehaus.mojo.archetypes -DarchetypeArtifactId=webapp-javaee7 -DarchetypeVersion=0.3-SNAPSHOT -DarchetypeRepository= -DgroupId=org.glassfish -DartifactId=javaee7-sample -Dversion=1.0-SNAPSHOT -Dpackage=org.glassfish.javaee7-sample -Darchetype.interactive=false --batch-mode --update-snapshots archetype:generate 
  2. Now open pom.xml, and go to the end of the <plugins> section
  3. Add the following plugin to the <build><plugins> section
  4. UPDATE 04-10-2013: Don't forget to add the following pluginRepository configuration inside your POM
                <name> Repository for Maven</name>
               <name> Repository for Maven</name>
  5. Execute the following Maven command and then point your browser to http://localhost:8282/javaee7-sample
    $ mvn package embedded-glassfish:run

The reason you must modify the dependencies of the plugin is that there's no released yet of the Embedded Plugin pointing to the GlassFish 4 promoted builds, although some artifacts are already there (i.e. simple-glassfish-api for b79; version is different because until now, there's no release of b83). We hope that the plugin will be updated together with the official release, as soon as possible.

By the way, with this configuration of the Embedded Plugin, you can edit any JavaServer Faces page, and just hit refresh in the browser. The configuration is poiting to the exploded WAR in Maven's target directory. Great setup for designers. 

Happy Java EE 7 coding until the launch!



Thursday Mar 28, 2013

[pt_BR] Redeploy de aplicações em produção no WebLogic

O WebLogic oferece uma função que permite você atualizar aplicações em ambiente de produção, com zero-downtime. Funciona assim: usuários que estão conectados na sua aplicação, continuarão conectados na versão antiga, mas quem se conectar depois do deploy da nova versão, será direcionado para o novo deploy. Assim, nenhum usuário sofrerá com um erro 404 (conteúdo inexistente), ou será prejudicado no meio de um processo (por exemplo, consultas ou relatórios). Isso permite roll-out de novas versões em horário comercial, sem necessidade de uma janela de atualização, para por exemplo, corrigir falhas no sistema que afetam somente uma parte da aplicação.

Agora para que isso seja possível, é necessário configurar o que chamamos de Application Version Identifier. Esta informação pode ser passada de duas formas:

  1. Por linha de comando:
    java weblogic.Deployer -adminurl http://localhost:7001 -user weblogic
         -password weblogic -deploy -name myTestDeployment 
         -source /myDeployments/myApplication/91Beta
         -targets myCluster -stage -appversion .91Beta
  2. Configurado no MANIFEST.MF do pacote (EAR/WAR) da aplicação
    Manifest-Version: 1.0
         Created-By: 1.4.1_05-b01 (Sun Microsystems Inc.)
         Weblogic-Application-Version: v920.beta

Apache Maven
Se você utiliza Maven para criar o pacote da aplicação, basta configurar no plugin (war ou ear), o parâmetro do Manifest:


Deu erro na versão nova? Rollback!
Se aconteceu alguma coisa com a versão nova, é só reativar a versão antiga para que novos usuários sejam direcionados a ela. Em seguida remova a versão nova. 

Removendo a versão antiga
Depois de ter a versão nova no ar, o WebLogic vai monitorar as sessões ainda abertas na versão antiga. Quando todas as sessões finalizarem (via timeout), a aplicação irá para o status retired. Caso isso demore para acontecer devido a sessões longas (usuário que esqueceu o navegador aberto em uma tela com função auto-refresh), você pode forçar esta etapa pelo console administrativo.

Se precisar de maiores informações, consulte a documentação do WebLogic 12c.

Tuesday Mar 26, 2013

OHS and APK files

In case you are trying to provide users a download link to an APK file hosted in your server, remember to add the MIME Type to your OHS (Oracle HTTP Server) configuration. The steps to add a MIME Type are well documented, and all you need to do is to specify the correcty definition:

(step-by-step on OHS 11g)
Using Fusion Middleware Control to Configure MIME Types

To configure a MIME type using Fusion Middleware Control, do the following:

  1. Select Administration from the Oracle HTTP Server menu.

  2. Select MIME Configuration from the Administration menu. The MIME configuration page appears.

  3. Click Add Row in MIME Configuration region. A new, blank row is added to the list.

  4. Enter the MIME type. ---> application/

  5. Enter the file extension.

  6. Review the settings. If the settings are correct, click Apply to apply the changes. If the settings are incorrect, or you decide to not apply the changes, click Revert to return to the original settings.

  7. Restart Oracle HTTP Server, as described in Section 4.1.4.



That's all!

Friday Feb 22, 2013

[pt_BR] Encontro SouJava na Oracle do Brasil

No dia 21 de Fevereiro estreamos o novo escritório da Oracle abrindo as portas para o grupo de usuários do SouJava. Com a presença do Bruno Souza, Ricardo Ferreira, Edgar Silva, Vinicius Senger, Mauricio Leal e muitos outros, tivemos a participação ao todo de 26 pessoas.

Durante a reunião, apresentei As Novidades do JMS 2.0, parte importante do Java EE 7 e que teve votação do Public Review no dia 19/02. O SouJava votou a favor, não só pela qualidade mas também pela transparência da especificação.

A outra apresentação foi do Ricardo Ferreira, falando sobre Processamento de Dados em Memória usando Elastic Data Grid (In-Memory Computing), que demonstrou a importância do uso de cache distribuído em arquiteturas altamente escaláveis, com o Oracle Coherence.

No final, os participantes conheceram o novo escritório da Oracle e ainda foram muito bem recebidos com muita pizza.
Confira todas as fotos do evento!

 Obrigado a todos que participaram!

Monday Feb 04, 2013

Trip to Lima, Peru

Last week I was in Lima, Peru, for the Oracle Fusion Middleware Forum. It was a great opportunity to meet the local team and some customers, but also to talk about the Next Generation of Middleware Solutions. Many companies invest in Middleware but mistakenly assume that it is only about the application server.

Although the challenges to achieve good maintainability, and the true cost of developing software are well know, a lot of in-house development is done to offer management, security, SOA, and governance. But the solutions quite often don't offer the minimum requirements.

Middleware is much more than just running Java EE applications. We showed to our customers and partners the value of our Fusion Middleware products that leverages their environments and help to increase their Time to Market, as well reduce development costs.

JUG Meeting, Java EE 7, and pisco... a lot of pisco

Late that night, I met one of the biggest JUGs in Peru, ITP_Java, to present the recent upcoming and exciting Java EE 7 new features. The slide deck I used was the same I presented a while ago in a meeting for the SouJava JUG in São Paulo, Brazil. Good thing is that people had the opportunity to learn some Portuguese! :-)

The JUG was able to understand my poor Spanish (or... portuñol), but even more, they engaged into the presentation of Juan Pablo Guizado, my friend from Oracle Peru, who gave an excellent introduction to multi-tier and clusterable architectures, before I dived into Java EE 7. What I concluded from this meeting is that we need to give more to the hispanic Java community. Should we work on a JavaOne Hispanic Edition in Latin America? Let us know!


Here are some pictures of the meeting, thanks to José Diaz, who took me and my new Oracle Peru friend Juan Pablo Guizado to one of the oldest places in Lima, Altigua Taberna Quirolo, to drink the classic cocktail Pisco Sour.

I also uploaded some pictures of this trip on my Google+ page, in case you want to see. 

De Lima, Peru, January 30, 2013

Monday Dec 17, 2012

WebFX: Running JavaFX as web page

This weekend I wanted to learn JavaFX, so I decided to code an idea I had a few years ago when I first saw JavaFX Script. So I started coding a web browser that runs HTML with the awesome, HTML5 supported WebView. But this browser also offers one extra feature: it loads FXML files as if they were HTML. So instead of defining your web page with HTML and running with WebKit, you can define a web page with FXML+CSS+JS and run as a JavaFX application.

The project is called WebFX and already has a prototype on GitHub. I also uploaded a video on YouTube demonstrating the idea.

What do you think about using JavaFX in the future for web pages, instead of HTML?


Bruno has been having fun working with Java since 2000 and now helps Oracle on sharing the technology accross all Latin America. Also plays videogames, does trekking and loves beer.

Follow me on Twitter! @brunoborges


« April 2014