Tuesday Jan 03, 2012

Java EE 6 using WebLogic 12c, NetBeans, and MySQL (Screencast #39)

Oracle WebLogic Server 12c is now available and comes with a zip installer.

This video shows how to develop and deploy a Java EE 6 application on WebLogic 12c using NetBeans. It builds a simple application using Java Persistence API 2.0, Enterprise JavaBeans 3.1, Servlets 3.0, Java API for RESTful Web Services 1.1, Java Server Faces 2.0, and Contexts & Dependency Injection 1.0. The video also explains how to configure MySQL database in NetBeans and use it for accessing the database tables in the Java EE 6 applications.


You can also check out the sample code built in this application from here.

What kind of Java EE 6 applications are you deploying on WebLogic ?

What else would you like to see on this blog relating to Java EE 6 and WebLogic ?

Follow the complete series here.

Saturday Jul 02, 2011

FISL12 Trip Report - Special Appearance by "Javali" and "Code Monkey"

FISL is the biggest open source conference in Latin America and had about 7000 participants in the FISL 12 that concluded earlier this week. This was my third consecutive year (2010 and 2009) and as every year the conference was packed with lectures, workshops, demonstrations, booths, presentations, and lot more.

Anil Gaur, VP of Java EE Platform and GlassFish, gave a presentation on "Oracle GlassFish Server: A flexibly, light-weight, and production-ready Java EE 6". There were about 100 attendees in the theatre-style seating. The talk gave a great overview of the explosive growth happening in the GlassFish community on all fronts. It also gave an overview of how GlassFish is the first platform to provide clustering and high-availability for Java EE 6 applications with full commercial support from Oracle. The 2-instance session failover demo that I started to show in the talk did not work completely and my digging is still going on but here is a basic analysis so far.
  • The GlassFish High Availability depends on GMS which further relies on UDP Multicast (more details here). I've shown this demo on my previous machine (a Macbook) multiple times and in different configurations of with or without an IP address. But multicast is enabled by default on Macs. However Natty Narwhal does not seem to be configured that way, at least by default. And so even though I could create a cluster, the application with HA enabled could not be deployed. 
  • The GlassFish 3.1 Certification Matrix provides a complete list of supported platform and Ubutnu 10.10, not 11.04 (demo machine), is listed as a supported developer platform. There might be bugs in this newest release of Ubuntu or how Grizzly picks a network interface for binding when there is no bind interface address setup and the default interface (eth0) is not connected.
More details on how this will eventually get fixed in a later blog.

Other than that I gave two presentations on "The Java EE 7 Platform: Developing for the Cloud" and "Running your Java EE 6 Applications in the Cloud: and the slides are now available:

There were about 60+ attendees for the 9am talk on Java EE 7. Check out more details about the evolution of Java EE 7 at javaee-spec.java.net. All the component JSRs have their independent pages as well with the format: <component>-spec.java.net where <component> is "jpa", "ejb", "servlet" and "jsf".

The second preso turned out a lot more fun than originally planned with the two surprise co-speakers - "Javali" and "Code Monkey". The audience seem to enjoy the interesting conversation as part of the talk, pictures below. There is usual engaging with the community, talking to folks at the booth, explaining Oracle's open source strategy, and customer visits.

Also, check out Java Spotlight podcast #36 where Anil Gaur talks about GlassFish 3.1.

There were several other talks given by Oracle employees covering JDK 7, NetBeans, OpenJDK, MySQL and other open source offerings.

Check out some pictures from the event:

And, as always, the evolving album:

See you next year!

Now on to Sao Jose do Rio Preto ...

Wednesday Dec 08, 2010

Java One 2010 Brazil Day 2 Trip Report - Pics & Slides

JavaOne Latin America 2010 (Day 1 and 0) started in an exciting way where I found a nice multi-instance cluster installation of GlassFish. More on that later but enjoyed meeting colleagues from different groups within Oracle.

I gave a presentation on "Whats New in Enterprise Java Beans 3.1" and the slides are available:

The attendees seem to like simplified packaging (EJB-in-a-WAR and deployment descriptor-free), no-interface bean, cron-like syntax, and other features were well appreciated by the users. All other sessions were going pretty packed as well to the extent that some of the sessions are having a re-run today and some of today's sessions have moved to a much bigger hall. Make sure to note the changes.

After that, Alexandra and I presented at a MySQL Community Event on how Java EE 6, GlassFish, NetBeans, and MySQL present an ideal open-source stack for building Web applications very easily, the slides are available:

Vinicius Senger from GlobalCode arranged an impromptu discussion on Java-based Web Frameworks at end of the day. There were representations from Java EE 6, Wicket, GWT, VRaptor,  Spring MVC, ADF, and Demoiselles. It was a lively discussion where each framework was talking about the pros/cons of different frameworks and the community was asking questions. CDI got good appreciation from different folks and it indeed is one of the most powerful technologies introduced in the Java EE 6 platform.

Matt Raibles "Comparing JVM Web Frameworks" presentation was discussed as well. The consensus was that the chosen frameworks are not an apple-to-apple comparison. For example, while Rails and Grails are complete stack, JSF2, Wicket, and Vaadin are presentation layers only. I gave the same feedback to him at Rich Web Experience as well so hopefully the matrix will be updated appropriately.

Also found some great deployments of GlassFish in this part of the world. We are looking for partners (System Integrators, Independent Software Vendors/Developers, Consultants, Training Partners) who can help us spread the message of GlassFish in South America. Drop a comment on this blog if you are interested.

For tomorrow, there are couple of changes to the list of Java EE 6 & GlassFish sessions ...
  • "S320003 - Servlet 3.0 Extensible, Asynchronous and Easy to Use" moved from its original slot of (4:15 - 5pm) to (4pm - 4:45pm) and the location changes from Auditorio 1 to the Keynote Hall (on the ground floor).
  • "S313189 - Complete Tools Coverage for the Java EE 6 Platform" moved from Auditorio 1 to Keynote Hall (on the ground floor).
Rest of the schedule stays as is.
And now day 2 pictures from Oracle Open World and JavaOne 2010 in Brazil ...

And finally the evolving photo album so far:

On a personal front, somebody mentioned the landscape from Chili, food from Peru, and girls from Argentina (or Brazil depending upon who you ask) is the most fascinating threesome ;-) I've never been to Chili, Peru, and Argentina so will have to figure out how to experience that :-) Any Java conferences there ?

Also, its weird to experience Christmas in the hot weather of Sao Paulo. I wonder the white christmas here refers to white sand on the beach.  The malls certainly have huge christmas trees and even there is a Santa station but feels awkard without the cold weather. Tomorrow is the last day of JavaOne and I'm soooo looking forward to head back home and can only think of the following song ...

Technorati: conf glassfish mysql brazil javaone oracle oow

Tuesday Dec 07, 2010

Oracle Open World / Java One 2010 Brazil Day 1 Trip Report

Oracle Open World 2010 Latin America was kick started this morning by Oracle's President Mark Hurd. Later Adam Messinger's (Vice President in Fusion Middleware group at Oracle) keynote started JavaOne Brazil and gave a status update on the Java platform. In his talk, Staffan showed a demo of JRockit Mission Control. TIM (a local Brazilian telecom company) showed how they are using Java to serve multi-million users in Brazil. Java FX super fast rendering capabilities were shown in a video. I showed how a multi-instance GlassFish 3.1 cluster can be easily created using web-based administration console. The steps to reproduce the demo are explained in the video below:

I accidentally left my tweetdeck open before the demo machines were locked and so tweets were popping all through out the demo. The attendees seem to had a good laugh at that :-)

The three Technical General Sessions by Danny Coward, Jerome Dochez, and Greg Bollela dig deeper into Java SE, Java EE, and Mobile/Embedded platforms. Jerome's talk showed a typical 3-tier application that allows the user to monitor twitter trends for pre-defined hashtags. More details about the application and downloadable code are available here.

And now day 1 pictures from Oracle Open World, Oracle Develop, and JavaOne 2010 in Brazil ...

Come by and meet us at the Java EE 6 booth in the JavaOne exhibitor floor. I reached little bit late to the OTN party but the place was totally rocking with the community.

This is Brazil so here is a sample of "booth models" at the exhibitor floor ...

This is not meant to offend anybody but just to show culutral shift obvious due to the geography. And yes, I took permissions from each of the models before taking their picture :-)

Here is another fun activity performed on the exhibitor floor:

Looking forward to Java EE & GlassFish sessions tomorrow and day after. And don't forget to attend the FREE MySQL Community Event tomorrow!

I enjoyed meeting Vinicius Senger, Yara Senger, Daniel deOliveira, Sven Reimers, Eduardo Lima, and several other Java community members.

And finally the evolving photo album so far:

Technorati: conf glassfish mysql brazil javaone oracle oow

Monday Dec 06, 2010

Oracle Open World / Java One 2010 Brazil Day 0 Pictures

First set of pictures from Oracle Open World, Oracle Develop, and JavaOne 2010 in Brazil ...

And a picture from dinner with local Java champions and JUG leaders of Brazil ...

Looking forward to meet many others over the next 3 days.

And the evolving album so far:

JavaOne Brazil
starts in a few more hours and here are some pointers for you:
Technorati: conf glassfish mysql brazil javaone oracle oow

Wednesday Nov 17, 2010

TOTD #150: Collection of GlassFish, NetBeans, JPA, JSF, JAX-WS, EJB, Jersey, MySQL, Rails, Eclipse, and OSGi tips

This is the 150th tip published on this blog so decided to make it a collection of all the previous ones. Here is a tag cloud (created from wordle.net/create) from title of all the tips:

As expected GlassFish is the most prominent topic. And then there are several entries on NetBeans, JRuby/Rails, several Java EE 6 technologies like JPA, JAX-WS, JAX-RS, EJB, and JSF, and more entries on Eclipse, OSGi and some other tecnhologies too. Here is a complete collection of all the tips published so far:

Just for fun, here is another tag cloud:

You can access all the tips here. And keep those suggestions coming!

Technorati: totd glassfish netbeans jpa jsf jaxws jersey mysql rails osgi eclipse

Wednesday Sep 29, 2010

GlassFish scales and configures very quickly for Micello - the "indoor Google Maps" company

We all (at least majority of us) use some sort of maps to reach from one destination, say home, to another destination, say a shopping mall or a convention center. But once you've reached the mall then you switch to a different set of tools to navigate that is typically either a paper flyer or sign boards within the mall. Micello.com fills that gaps by providing maps for any indoor locations like airport, shopping malls, convention centers, retail centers, and college campus.

Their application is built using "scalable stack" of GlassFish and MySQL, uses RESTful Web services, and has given them a 99.9% uptime in the past few months - no wonder its used to create indoor maps for 50 malls in Singapore. Listen all the details on Micello from Prakash in the video below:

Micello has been talked about at readwriteweb.com, techcrunch.com, and mashable.

How are you using GlassFish today ?

Technorati: stories micello google maps glassfish mysql

Tuesday Feb 09, 2010

TOTD #122: Creating a JPA Persistence Unit using NetBeans 6.8

Taking TOTD #121 forward, this blog explains how to create a JPA Persistence Unit for a MySQL sample database and package it as a library. This JAR file can then be easily included in other web applications.

Lets get started!

  1. Configure GlassFish for using the MySQL sample database (sakila) as described in TOTD #121.
  2. Add the GlassFish instance in NetBeans IDE using "Services" panel.
  3. Create JPA entities using NetBeans IDE.
    1. Create a Java class library:

      Our ultimate goal is to create a reusable JAR file and that's why this project type is chosen.
    2. Specify the name of project as "SakilaPU":

    3. Right-click on the project and select "New", "Entity Classes from Database ..." to initiate the process of entity generation:

    4. Choose the database connection as:

      If not configured, then can be easily done by clicking on "New Database Connection ..." in the list box.
      1. Click on "Add All >>" to generate the mapped JPA entities for all tables and views.
      2. The views do not have primary keys and will need to be appropriately annotated (described later).
      3. Click on "Next >".
    5. Give the package name as:

      and specify the package name as "sakila". Click on "Create Persistence Unit ...".
    6. Change the default PU name from "SakilaPUPU" to "SakilaPU":

      and click on "Finish". Notice that "EclipseLink", the Reference Implementation of JPA 2.0, is used as the persistence library.
    7. Add "@javax.persistence.Id" annotation to the following class/field combination:
      Class Field
      sakila.SalesByFilmCategory category
      sakila.ActorInfo actorId
      sakila.FilmList fid
      sakila.CustomerList id
      sakila.NicerButSlowerFilmList fid
      sakila.StaffList id
      sakila.SalesByStore store

      This is required because none of the "views" are defined with a primary key.
    8. Right-click on the project and select "Clean & Build". This generates "dist/SakilaPU.jar" and the structure looks like:

This JAR file can now be included in any web application. The pre-built JAR file can also be downloaded here.

In order for this PU to be used in an application server (such as GlassFish) that is pre-configured with a JDBC resource, the "persistence.xml" needs to be changed to:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
 <persistence-unit name="SakilaPU" transaction-type="JTA">

The JDBC resource name is specified using <jta-data-source>.

The key items to note about this pre-built JAR:

  • Persistence Unit Name: "SakilaPU"
  • All classes are in "sakila.\*" package.
  • Each class has a pre-defined "<CLASS-NAME>.findAll" named query that returns all elements from the underlying view/table.

This JAR can be installed to your local Maven repository as:

mvn install:install-file -Dfile=SakilaPU.jar -DgroupId=org.glassfish.samples -DartifactId=sakilapu -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true

and then included in your "pom.xml" as:


Even though this blog uses a MySQL sample database, these steps can be easily followed for any other database such as Oracle or JavaDB.

Technorati: totd javaee glassfish v3 jpa eclipselink persistenceunit mysql sakila netbeans

Monday Feb 08, 2010

TOTD #121: JDBC resource for MySQL and Oracle sample database in GlassFish v3

This blog clearly explains how to configure the MySQL sample database (sakila) with GlassFish. Even though the instructions use a specific database but should work for other databases (such as Oracle, JavaDB, PostgreSQL, and others) as well. The second half of the blog provide specific syntax for the Oracle sample database.

  1. Download sakila sample database and unzip the archive.
  2. Install the database as described here - basically load and run "sakila-schema.sql" and "sakila-data.sql" extracted from the archive.
  3. Create a new MySQL user account using MySQL CLI Admin and assign the privileges
    1. Using "root" user (sudo mysql --user root)
      CREATE USER glassfish IDENTIFIED BY 'glassfish';
      GRANT ALL PRIVILEGES ON \*.\* TO 'glassfish'@'localhost' IDENTIFIED BY 'glassfish';
    2. Using "glassfish" user (sudo mysql --user glassfish)
      source sakila-schema.sql;
      source sakila-data.sql;
  4. Download Connector/J, unzip and copy "mysql-connector-java-5.x.x-bin.jar" to "glassfish/domains/domain1/lib/ext" directory.
  5. Start GlassFish server as:
    asadmin start-domain
  6. Create a JDBC resource
    1. Create JDBC connection pool as:
      asadmin create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource --restype javax.sql.DataSource --property "User=glassfish:Password=glassfish:URL=jdbc\\:mysql\\://localhost/sakila" jdbc/sakilaPool
    2. Test the JDBC connection pool as:
      asadmin ping-connection-pool jdbc/sakilaPool
    3. Create the JDBC resource as:
      asadmin create-jdbc-resource --connectionpoolid jdbc/sakilaPool jdbc/sakila

That's it!

Creating a JDBC resource for any other database requires the following updates to the steps mentioned above. Lets consider modifying these steps for the Oracle sample database.

  1. Use the client interface SQL\*PLus and connect as:
    sqlplus "/ as sysdba"

    create user and grant the privileges as:
    CREATE USER glassfish IDENTIFIED BY glassfish DEFAULT tablespace users TEMPORARY tablespace temp;
    GRANT CONNECT TO glassfish IDENTIFIED BY glassfish;
    GRANT CREATE TABLE TO glassfish;
  2. Copy the appropriate JDBC driver (ojdbc6.jar).
  3. Create the JDBC resource as:
    asadmin create-jdbc-connection-pool --datasourceclassname oracle.jdbc.pool.OracleDataSource --restype javax.sql.DataSource --property "User=hr:Password=hr:URL=jdbc\\:oracle\\:thin\\:@localhost\\:1521\\:orcl" jdbc/hr
    asadmin ping-connection-pool jdbc/hr
    asadmin create-jdbc-resource --connectionpoolid jdbc/hr jdbc/hr

    as explained in TOTD #108.

Here are a few other related entries:

Technorati: totd javaee glassfish v3 jpa mysql sakila oracle

Friday Oct 02, 2009

TOTD #109: How to convert a JSF managed bean to JSR 299 bean (Web Beans) ?

This entry is a follow up to TOTD #95 and shows how to use the recent integrations of JSR 299 in GlassFish v3 to convert a JSF managed bean to a JSR 299 bean (aka Web Beans). The TOTD #95 describes a simple Java EE 6 web application that uses Java Server Faces 2.0 components for displaying the results of a database query conducted by EJB 3.1 and JPA 2.0 classes.

The EJB class, which also acts as the JSF managed bean, looks like:

public class StateList {
  EntityManagerFactory emf;

  public List getStates() {
    return    emf.createEntityManager().createNamedQuery(”States.findAll”).getResultList();

Three changes are required to convert this class into a JSR 299 compliant bean (Web Bean) as listed below:

  1. Add an empty "beans.xml" to the WEB-INF directory.
  2. Replace "@ManagedBean" with "@javax.inject.Named annotation". "@javax.inject" annotations are defined by JSR 330.
  3. Resource injection does not work with JPA classes, yet, so populate EntityManager explicitly as explained below:
    1. Replace EntityManagerFactory resource injection:

      EntityManagerFactory emf;

      EntityManager emf = Persistence.createEntityManagerFactory("HelloEclipseLinkPU");
    2. Add the required entity classes explicitly to "persistence.xml". If the persistence unit is injected then the container automatically scans the web application root for any entity classes.
      1. Expand "Configuration Files" and edit "persistence.xml".
      2. Uncheck "Include All Entity Classes in ..." check box.
      3. Click on "Add Class...", select "state.States", and click on "OK".

That's it, re-deploy your application and now you are using the Web Beans integration in GlassFish v3 instead of JSF managed bean. The output is available at "http://localhost:8080/HelloEclipseLink/forwardToJSF.jsp" as shown:

This is the exact same output as shown in TOTD #95.

Now, one-by-one, JPA, EJB, Transactions and other components will start working. Read Roger's blog for another example of Web Beans in GlassFish.

A complete archive of all the tips is available here.

Technorati: totd glassfish v3 mysql javaee6 javaserverfaces webbeans jsr299 netbeans


profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.

Java EE 7 Samples

Stay Connected


« February 2017