Java EE 7 Tutorial has been released!

The Java EE 7 Tutorial  is live and on this edition we feature the following:

  • Examples for Java API for WebSocket (JSR 356), Java API for JSON Processing (JSR 353), Batch Applications for the Java Platform (JSR 352), and Concurrency Utilities for Java EE (JSR 236)  – Basically all new Java EE 7 technologies.

  • Examples for the updated specs like Java Message Service 2.0 (JSR 343), Java API for RESTful Web Services 2.0 (JSR 339), Java Servlet 3.1 (JSR 340), JavaServer Faces 2.2 (JSR 344), and Contexts and Dependency Injection for Java EE 1.1 (JSR 346).

  •  The examples now are Maven based, so you can build, package and deploy to GlassFish 4.0 through Maven thanks to the brand new Cargo plugin.

Check it out!

My new article – WebLogic RESTful Management Services: From Command Line to JavaFX

Check it out:

Oracle WebLogic Server 12c is a major release and includes several new features, including Java EE 6, Maven integration, and JDK 7 support. This release also includes additional features that are important for administration and monitoring of an Oracle WebLogic domain. This article will focus on one such feature: RESTful Management Services

You can read the complete article on here -> http://www.oracle.com/technetwork/articles/soa/oliveira-wls-rest-javafx-1723982.html

New OTN Article – Oracle Enterprise Gateway: Integration with OSB and OWSM

OEG, OSB and OWSM - Integration example
Just published another article at Oracle Technology Network. This one shows the basics of Oracle Enterprise Gateway and a walk through example of how it can be integrated with Oracle Service Bus and Oracle Web Services Manager.  To read the complete article click here and feel free to give any feedback.

A great partnership with my pal Fabio Mazanatti to produce the article!

Java EE 6 – Complete Annotation Reference

Hi Folks,
It’s been a while since my last post but I expect to get back to blogging in the next month.

For now I’m sharing a complete reference for all annotations available in Java EE 6. As you already know, Java EE 6 is really changing the way to program for Java Enteprise platform and these annotations are responsible for hiding part of the complexity of EE development.

http://wikis.sun.com/display/GlassFish/Java+EE+6+Annotation+Reference

https://wikis.oracle.com/display/GlassFish/Java+EE+6+Annotation+Reference

The link above is broken, please or use the following:

http://www.physics.usyd.edu.au/~rennie/javaEE6ReferenceSheet.pdf

Enjoy!

Flashing Android Froyo in a Galaxy S with Ubuntu and Heimdall

As some of my friends know, I am now a happy Android user. In fact, for about 5 months already… But my phone shipped with ECLAIR version of Android (2.1) and since I’m an Ubuntu user, I would find a way to flash my device and update my firmware to FROYO without Window$ / VirtualBox traditional approach. For my surprise, there are some options to accomplish that and I’ll explain the one that worked for me.

Please Note: These steps worked for me but it’s possible that will not work for you. It’s a very stable procedure but $hit happens. Do follow the steps at your own risk.

UPDATE – The same procedure works with Android 2.3.3 (Gingerbread) firmware. Version I9000BVJJV3 – Jun 2011. Please check samfirmware website to download.

Heimdall

According to their website, here is a description:

Heimdall is a cross-platform open-source tool suite used to flash firmware (aka ROMs) onto Samsung Galaxy S devices.

It has ports for Mac OSX, Linux and even Windows, although most of the Windows users prefer to use Odin to flash their devices or even Samsung Kies.

You can grab heimdall packages for Ubuntu from their website -> http://www.glassechidna.com.au/products/heimdall/

For this tutorial I’m using Heimdall 1.1.1 command line tool. Using the GUI version I’ve got some strange behaviours and some times the GUI just said that Flash happened without any processing.

Android Froyo firmware download

To flash your device you must obtain the firmware version that you’ll apply. You have many options over the web to obtain different versions of Android. Some of them claims to be original ones from operators and some others modified/hacked versions with extra functionalities. I’ll stick with the “original” ones and since I’m in Brazil, my device has digital TV so I need to use a GT-I9000B firmware. Here are two options to download firmwares:

For this tutorial I’m using  Froyo 2.2 (Operator Free):

Procedure

  1. Install heimdall
  2. Uncompress the downloaded firmware package, in my case -> OK – 2.2 – FROYO – BRASIL SEM OPERADORA.rar
  3. Check if you have all the necessary files:

    -r--r--r-- 1 markito markito  13955072 2010-12-11 01:23 cache.rfs
    -r--r--r-- 1 markito markito   4833980 2010-12-11 02:04 zImage
    -r--r--r-- 1 markito markito    716800 2010-12-11 02:04 param.lfs
    -r--r--r-- 1 markito markito 254341120 2010-12-11 02:04 factoryfs.rfs
    -r--r--r-- 1 markito markito  12582912 2010-12-12 22:30 modem.bin

  4. Move or copy the PIT file (s1_odin_20100512.pit) to the same directory you uncompressed the firmware
  5. Put your device in download mode. On a Galaxy S you should hold -> home buttom + power buttom + volume downand wait until you see the Android logo with “Downloading” written below.
  6. Now that your phone is ready to receive a new firmware, plug the USB cable, wait a few seconds and type the following command in the same directory you have uncompressed all the files:

    heimdall flash --factoryfs factoryfs.rfs --cache cache.rfs  --param param.lfs --kernel zImage --modem modem.bin --pit s1_odin_20100512.pit

  7. Now you should wait a few minutes and expected for the best: successful messages. :-)
  8. Your device should boot and will stuck a few moments in the Samsung S logo. That’s normal because it’s the first boot of your new kernel. But your are ready to go now, firmeware updated!

If it worked for you, congratulations. If you had or still have some problems, please take a look at some of the sources that I’ve used to learn and apply to my device, maybe it will help.

Sources:

How to fix ‘$MFTMirr does not match $MFT (record 0)’

Sometimes, when you are executing a file transfer between your computer hard drive and an external drive and your computer shutdown for some reason (in my case, no battery/ac power) it’s pretty common to get some errors on external drives that uses NTFS as they file system.

The most common message is:

Error mounting: mount exited with exit code 13: $MFTMirr does not match $MFT (record 0).
Failed to mount ‘/dev/sdb3’: Input/output error
NTFS is either inconsistent, or there is a hardware fault, or it’s a
SoftRAID/FakeRAID hardware. In the first case run chkdsk /f on Windows
then reboot into Windows twice. The usage of the /f parameter is very
important! If the device is a SoftRAID/FakeRAID then first activate
it and mount a different device under the /dev/mapper/ directory, (e.g.
/dev/mapper/nvidia_eahaabcc1). Please see the ‘dmraid’ documentation
for more details.

One workaround for this issue is to do as the message says, boot on Windows and try to use the awesome NTFS tool that Windows offer. But a perfect solution for a Linux users is to use the ntfsprogs utility.

UPDATE: On some recent Linux releases, you need to install ntfs-3g utilties.  Try sudo apt-get install ntfs-3g or download from http://www.tuxera.com/community/ntfs-3g-download/

ntfsprogs is a suite of NTFS utilities based around a shared library. The tools are available for free and come with full source code.

  • mkntfs: Create an NTFS volume on a partition
  • ntfscat: Print a file on the standard output
  • ntfsclone: Efficiently backup/restore a volume at the sector level
  • ntfscluster: Given a cluster, or sector, find the file
  • ntfsfix: Forces Windows to check NTFS at boot time
  • ntfsinfo: Dump a file’s attributes, completely
  • ntfslabel: Display or set a volume’s label
  • ntfslib: Move all the common code into a shared library
  • ntfsls: List directory contents
  • ntfsresize: Resize an NTFS volume
  • ntfsundelete: Find files that have been deleted and recover them
  • ntfswipe: Write zeros over the unused parts of the disk
  • ntfsdefrag: Defragment files, directories and the MFT
  • ntfsck: Perform consistancy checks on a volume
  • nttools: Command-line tools to view/change an offline NTFS volume, e.g. ntfscp, ntfsgrep, ntfstouch, ntfsrm, ntfsrmdir, ntfsmkdir
  • ntfsdiskedit: Walk the tree of NTFS ondisk structures (and alter them)

Be careful with these utilities, they might damage the filesystem, or your hard disk !

With ntfsprogs installed (sudo apt-get install ntfsprogs) you should execute the following commands in a terminal:

sudo ntfsfix /dev/partitionName

After this command you should expect the following output:

~$ sudo ntfsfix /dev/sdb3
Mounting volume... FAILED
Attempting to correct errors...
Processing $MFT and $MFTMirr...
Reading $MFT... OK
Reading $MFTMirr... OK
Comparing $MFTMirr to $MFT... FAILED
Correcting differences in $MFTMirr record 0...OK
Processing of $MFT and $MFTMirr completed successfully.
Setting required flags on partition... OK
Going to empty the journal ($LogFile)... OK
NTFS volume version is 3.1.
NTFS partition /dev/sdb3 was processed successfully.

After this step you should be able to access your external drive partition as usual, mount or use nautilus to access your files.

Source:  http://gnuwin32.sourceforge.net/packages/ntfsprogs.htm

HTTP Status codes for RESTFul Services

A good understanding of the HTTP protocol is crucial for a successful RESTful implementation. Although I know that REST is not dependent of HTTP, we all know that it’s the most common implementation.

Below I made a quick overview of HTTP status codes and the intent is to help during the development and test of REST services.

General HTTP Codes

1xx – Informational: Request received, continuing process.

2xx – Success: Action successfully received, understood, and accepted.

3xx – Redirection: Client must take additional action to complete the request.

4xx – Client Error: Request contains bad syntax or cannot be fulfilled.

5xx – Server Error: Server failed to fulfil an apparently valid request.

In the table below you have the description of the most common response codes:

Code Meaning Description
200

201

202

204

206

OK

Created

Accepted

No Content

Partial Content

– Successful HTTP request.

– New resource created.

– Accepted for processing, but not yet completed.

– Successfully processed, but no return content.

– Only part of the resource returned.

300

301

303

304

Multiple Choices

Moved Permanently

See Other

Not Modified

– Multiple options for the resource that the client may follow.
– This and all future requests should be directed to the given URI. 

– Response can be found at URI using GET method.

– Resource has not been modified since last requested

400

401

403

404

405

406

409

410

412

415

417

418

Bad Request

Unauthorized

Forbidden

Not Found

Method Not Allowed

Not Acceptable

Conflict

Gone

Precondition Failed

Unsupported Media Type

Expectation Failed

I’m a teapot

– Request contains bad syntax or cannot be fulfilled.- Request refused, when authentication is possible but has failed or not yet been provided.

– Request was legal, but the server refuses to respond to it.

– Resource could not be found but may be available again in the future.

– Request made using method not supported by that resource.

– Resource can only generate content not acceptable given Accept headers sent in.

– Request could not be processed due to conflict in the request.

– Resource no longer available and will not be available again.

– Server does not meet precondition put on the request.

– Request did not specify any media types the resource supports.

– Server cannot meet requirement of Expect header field.

– Response entity “MAY be short and stout”.