Here is a quick tutorial to get your hands dirty with the Log4j logging framework.
Log4j allows logging requests to print to multiple output destinations, also known as appenders.
There are several output destinations: console, files, sockets, emails …
First create a Maven project :
mvn archetype:generate
Choose archetype number 109 (quickstart)
Continue reading
[GWT] Reduce the number of permutations
Here is a tip that I found on other blogs and I think is worth mentioning again. I tried it, it reduced the number of permutations from 15 to 3 only (1 permutation for IE, 1 permutation for the FR locale, 1 permutation for the EN locale). That means a compilation time of 1:05.750s instead of 2:02.828s.
In the module file (blabla.gwt.xml), you need to add this line :
<set-property name="user.agent" value="ie6" />
This of course will produce permutations for Internet Explorer 6 only.
There is also another property to define the locales :
<extend-property name="locale" values="fr" />
So this will generate 2 permutations only : 1 for IE and 1 for the FR locale.
Here is a list of user agents :
http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/user/UserAgent.gwt.xml
Java puzzlers
This week I attended the very first and very well organized conference What’s Next ? in Paris and one of the speakers was Neil Gafter, co-author of the book “Java™ Puzzlers: Traps, Pitfalls, and Corner Cases” (2005).
He shared with us 2 or 3 puzzlers which I will share here too :
Question 1) What will the following program print ?
import java.util.Random; public class Rhymes { private static Random rnd = new Random(); public static void main(String[] args) { StringBuffer word = null; switch(rnd.nextInt(2)) { case 1: word = new StringBuffer('P'); case 2: word = new StringBuffer('G'); default: word = new StringBuffer('M'); } word.append('a'); word.append('i'); word.append('n'); System.out.println(word); } }
Eclipse Dali vs Hibernate Tools
The process of mapping tables to entities is greatly simplified with tools like Eclipse Dali and Hibernate Tools, both available as Eclipse plugins. It avoids mapping them by hand, which in my opinion is prone to mapping errors and takes more time. And I really do not see why one should map them by hand when great tools like Eclipse Dali and Hibernate Tools are available.
In my book, I describe the use of the Eclipse Dali plugin to automatically generate the entities.
Lately I have also used Hibernate Tools and I have already noticed a few differences between these two tools.
I am going to list some of these differences.
Continue reading
[GWT] Table with pagination and one sortable column
I just added a very basic GWT project to my github account to display a table with pagination and one sortable column.
The code is mostly based on the official GWT tutorial :
http://code.google.com/intl/en/webtoolkit/doc/latest/DevGuideUiCellTable.html
I basically just added the SimplePage element to handle pagination :
SimplePager pager = new SimplePager();
pager.setDisplay(table);
Source :
https://github.com/longbeach/MyFirstCellTable
Demo :
http://tableaupagination.appspot.com/
How to rollback a transaction in GAE
This has nothing to do with JPA.
I was trying to deploy a GWT webapp to GAE when I suddenly got an error.
As a remedy, i got the message :
"java.io.IOException: Error posting to URL: https://appengine.google.com/api/appversion/create?app_id=tableaupagination&version=2&
409 Conflict
Another transaction by user xxxxx is already in progress for this app and major version. That user can undo the transaction with appcfg.py's "rollback" command."
After digging into Google a bit, I found that the way to launch that rollback command under Windows is the following :
1) Figure out where the Google App Engine Java SDK directory is.
In my case, it’s under the Eclipse plugins directory :
D:\Dev\eclipse-jee-helios-SR1-win32\plugins\com.google.appengine.eclipse.sdkbundle.1.4.2_1.4.2.v201102111811
The bin folder contains the appcfg.cmd command.
2) Under a DOS command prompt, go to the workspace folder of your project and launch the following command :
"D:\Dev\eclipse-jee-helios-SR1-win32\plugins\com.google.appengine.eclipse.sdkbundle.1.4.2_1.4.2.v201102111811\appengine-java-sdk-1.4.2\bin\appcfg" rollback war
After that, you can try to deploy the app again and it should work.
Links :
http://code.google.com/intl/fr/appengine/docs/java/tools/uploadinganapp.html
http://code.google.com/intl/fr/appengine/docs/java/gettingstarted/uploading.html
[Tutorial] Create your first GWT project and deploy it to GAE
Here is a first quick and simple tutorial on how to develop and deploy your very first GWT web application to Google App Engine.
Requirements :
Eclipse
Google Web Toolkit plugin for Eclipse
A Google App Engine account + GMAIL account
So here are the steps :
Continue reading
Code for the book is now on GitHub
I finally added the code for the book “Les EJB 3 (avec Struts 2, JSF 2, JasperReports 3, Flex 3)” to GitHub.
To grab it, you have 2 options :
1) use GIT and type :
git clone git://github.com/longbeach/VenteEnLigne.git
2) use SVN and type :
svn co http://svn.github.com/longbeach/VenteEnLigne
As a matter of fact, and surprising as it might sound, you can use SVN to grab code from GitHub 🙂
Maven integration for Eclipse JDK Warning
After installing the M2Eclipse plugin, I get this annoying warning message every time i start Eclipse :
Continue reading
Installing Git on Cygwin
Installing Git on the free Unix emulator Cygwin has become pretty easy. There is no need for compilation, you just need to download the packages. Here are the steps :
Continue reading
Assembla
I found another cool website that offers free workspaces that can be managed with Subversion, Git, Mercurial etc…
Of course it also offers various plans with monthly payments.
Anyway, I just put an empty project in my workspace. Check out the screenshots :
Continue reading
Start/stop Jonas with Maven and Cargo. And deploy too.
I found very little information on what to add exactly to the POM.xml file to start/stop Jonas with Maven and Cargo.
So here is a quick example with a basic webapp application.
Continue reading
[Tutorial] Create a PDF document with Maven and iText
Here is a quick way to start learning how to use the open-source library iText to generate PDF documents.
I start with the archetype maven-archetype-quickstart (number 101, which is the default archetype), an archetype which contains a sample Maven project.
Continue reading
[Tutorial] Start and stop JBoss with the Cargo plugin.
In this video tutorial, I show how to start / stop JBoss 6 using the plugin Cargo for Maven. And to deploy an archive.
In the previous tutorial, I created and imported the project in Eclipse with the m2Eclipse plugin.
Continue reading
[Tutorial] Create a Maven project and import it with m2Eclipse
In this video tutorial, I show how to create a Maven project under DOS. Then how to import it to Eclipse with m2Eclipse.
Continue reading
[Tutorial] Create, compile and test a project with Maven
Here is a first video tutorial about Maven, under DOS.
First i create a project based on the maven-archetype-quickstart archetype with the following command and arguments :
mvn archetype:generate -DgroupId=com.company.celinio -DartifactId=FirstTuto -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
[Tutorial] RESTful web services with CXF
This is a short follow-up to a previous post about Web Services with CXF.
Developing RESTful web services with CXF is quite easy. Here I quickly explore 2 ways to do it.
COBOL-IT developer studio
I have not done any COBOL programming for more than 15 years. The last time was in 1995, during my studies.
We used Microfocus Visual COBOL back then, I believe.
So anyways, the other day I heard about Cobol-IT Developer Studio, a free COBOL development workshop based on Eclipse !
Continue reading
[Tutorial] WSDL to Java with Apache CXF and soapUI
The WSDL2java command generates JAX-WS compliant Java code for the services that are defined in the WSDL document.
This is known as the Top-Down approach (contract first, based on an existing WSDL file).
Continue reading
[Tutorial] Create a Web Service with Apache CXF and JBoss 6
I have recently started studying Apache CXF, the open source web service framework. I am familiar with developing Web Services using EJB 3, Axis or Glue. But not with CXF. Until now.
CXF is a mix of two projects : Celtix and XFire, which explains the name CXF.
It provides support for the JAX-WS, JAX-RS and JAX-RPC specifications.
Developing Web Services using CXF and JBoss is quite easy. The only annoying part is to figure out which JARs libraries
to include in the classpath and which JARs libraries to exclude.
Continue reading
[Book review] Pro HTML5 Programming
I heard about this book after attending a presentation on HTML5 by one of its authors, Peter Lubbers. I found his demonstration about the offline cache, a new feature in HTML5, very interesting and so I wanted to know more about HTML5.
The book has an official site : http://www.prohtml5.com
In my opinion, this book is a good introduction in the new features of HTML5.
Continue reading
JBoss AS 7 : standalone mode and domain mode
I just noticed that the latest version of JBoss, version 7 Alpha 1, is having a new set of folders and files.
Continue reading
CanIuse.com and fmbip.com
Here are two very useful sites :
http://www.caniuse.com/
Like it says, it shows “compatibility tables for features in HTML5, CSS3, SVG and other upcoming web technologies”.
Another one is http://fmbip.com.
It displays a table showing exactly what browser you’re using and what CSS3 & HTML5 capabilities the browser supports.
http://fmbip.com/litmus displays test results showing when you can start to use specific HTML5 & CSS3 functionality.
Very handy resources for developers !