Archive for the ‘JEE’ Category

h1

Maven and GWT can live together

June 18, 2010

I recently started working on a requirement where the UI was to be developed using GWT. Being a maven fan for quite sometime now, I started using gwt-maven-plugin to create a GWT maven plugin. And ofcourse everything was fine till the point I started adding external maven dependencies. GWT compile started complaining about the source not found for tons of classes. I googled around and find out the only way to get around the issue was to use GWT modules for external dependencies and inherit them in main GWT UI application. This approach works flawlessly if you are working with project created in Eclipse using the GWT web project wizard and other dependent projects are standard Eclipse Java project. This approach wasn’t supposed to work, as most of our applications or artifacts are maven based project. On further googling and downloading the source code of gwt-maven-plugin it turns out there is another version of gwt-maven-plugin available on svn repository of GWT project itself. It’s version is 1.3.1.google. Also there is another configuration that needs to be added in gwt-maven-plugin configuration namely “configureSourcesArtifacts” for all the dependencies you have source or is downloadable from the maven repository. You can find more detailed explanation of this configuration on the gwt-maven-plugin site under gwt:compile goal. Once you setup this configuration running mvn compile gwt:compile will be able to compile the GWT project for all permutations with ease.

Please contact me in case you need a sample pom file which I am using for my project.

Happy mavenizing GWT 🙂

h1

JPA2 Junit4 testing with HSQLDB as in-memory database

January 25, 2010

Followed the steps from this great article –

http://antoniogoncalves.org/xwiki/bin/view/Article/TestingJPA
Only issue is that this article uses EclipseLink instead of hibernate implementation of JPA.
If you are using Netbeans 6.8 and you generated the pom file for the project, please perform the following steps –
1. Comment out the following dependency
javax
javaee-api
6.0
provided
or
javax
javaee-web-api
6.0
provided
(depending upon the type of project you created, web or ejb)
2. Add the following exclusion from hibernate-entitymanager artifact
org.hibernate
ejb3-persistence
3. For latest bean validation jsr add the following artifact
org.glassfish
bean-validator
3.0-JBoss-4.0.2_02
and for the persistence apis add the following dependency
javax.persistence
persistence-api
1.0
4. Comment out ejb3-persistence api artifact
org.hibernate
ejb3-persistence
1.0.1.GA
But of course you would have to add the test level dependency for HSQLDB and update the Junit version from old 3.8.2 to latest 4.5
Also for DBunit and dates keep this note handy

DbUnit use the JDBC escape formats for string representation.

Type Format
DATE yyyy-mm-dd
TIME hh:mm:ss
TIMESTAMP yyyy-mm-dd hh:mm:ss.fffffffff
Happy Testing