Archive for the ‘Maven’ Category

How to unit test Hibernate DAO’s with H2 and Spring

May 12, 2014 Comments off

Source can be downloaded from link;

Writing Unit test cases are very common these days.We can write a Unit test for the functionality with Mocking.I personally feel we should not do Mocking while testing DAO.I prefer to write test cases for the DAO’s by pointing to the Database itself.Here the problem is we cannot execute tests on the production or development database since it will spoil the existing data, because we can build the same project any number of time, especially when we configure continues integration.

In memory databases or file based database comes in handy in this particular situation.There are lot many databases available of this kind like h2, HSQLDB e.t.c.

Here below i have extended a sample created in the below post and have written unit test with h2 database.

Link :

Project Structure



Create a test class with the similar package structure as source class in src/test/java


Sample Insert.sql below.


Sample delete.sql below


Now the main part come into the picture.applicationcontext.xml

We need to configure the h2 database data source as per below.


and the Session Factory as per below.


and we have to add spring-test dependency to the pom file.


Categories: H2, Hibernate, Java, Maven, Spring Tags:

Maven SkipTests command

May 29, 2011 Comments off
Categories: Maven

Running Maven jetty plugin with a different port

May 29, 2011 Comments off
Categories: Maven

how do I set eclipse.ini -vm option for m2Eclipse ?

May 24, 2011 Comments off

I installed maven plugin for eclipse, then I get an error like below:

please make sure the -vm option in eclipse.ini is pointing to a JDK

how to use -vm option to point to my jdk in eclipse.ini?


add jdk javaw.exe file path as the first line to the eclipse.ini file and restart the eclipse.

C:/Program Files/Java/jdk1.6.0_24/bin/javaw.exe

Categories: Maven

Maven Exception

March 23, 2011 Comments off

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:1.4:shade (default) on project sag-server: Error creating shaded jar: Invalid signature file digest for Manifest main attributes -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:1.4:shade (default) on project testProject: Error creating shaded jar: Invalid signature file digest for Manifest main attributes
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(
at org.apache.maven.DefaultMaven.doExecute(
at org.apache.maven.DefaultMaven.execute(
at org.apache.maven.cli.MavenCli.execute(
at org.apache.maven.cli.MavenCli.doMain(
at org.apache.maven.cli.MavenCli.main(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(
at org.codehaus.plexus.classworlds.launcher.Launcher.main(
Caused by: org.apache.maven.plugin.MojoExecutionException: Error creating shaded jar: Invalid signature file digest for Manifest main attributes
at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
… 19 more
Caused by: java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
at java.util.jar.JarVerifier.processEntry(
at java.util.jar.JarVerifier.update(
at java.util.jar.JarFile.initializeVerifier(
at java.util.jar.JarFile.getInputStream(
at org.apache.maven.plugins.shade.DefaultShader.shade(
at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(
… 21 more


Step 1:go to pom.xml file

step 2:goto shade plugin part and add the below given lines


Categories: Maven

Debugging maven web application with eclipse

March 3, 2011 Comments off


Recently I started a new JEE project using Maven2 as build tool, choice done du to the different services that it offers for project with a lot of modules and complex dependency ….
One of the problems that I faced is debugging web layer with respect to the directory structure of the default web archtype.

Here is the best method I found to solve this need:

I suppose that you already created a maven2 web project if not see :

To run http web server I use jetty plugin by simply adding the jetty plugin to the pom.xml

In order to validate this phase it’s possible de run the web app from the command line: mvn jetty:run and wating for maven to download the plugin and if successful running the application.

After that It’s time to configure eclipse for debugging the web app by selecting the Run > Debug … from the menu
# Set Main Class to “org.codehaus.classworlds.Launcher”

Go to the argument tab:
# Set Program arguments to “jetty6:run”
# Set VM arguments to “-Xmx512M -Dclassworlds.conf=[MAVEN_HOME]/bin/m2.conf -Dmaven.home=[MAVEN_HOME]”
(Replace MAVEN_HOME with the location of maven on your system)

Go to the classpath tab:
# remove the application from the user entries
# add the “[MAVEN_HOME]/core/boot/classworlds-1.1.jar” to the user entries

Go to the source tab:
# add the current project to debug

Now you can start debugging your application like you do it always

It is very interesting to set the –o option to the maven command in order to accelerate the fix/debug process.


Categories: Maven
%d bloggers like this: