diff --git a/ipojo/tests/handler/transaction/pom.xml b/ipojo/tests/handler/transaction/pom.xml
index a7cb2d2..5f49bb0 100644
--- a/ipojo/tests/handler/transaction/pom.xml
+++ b/ipojo/tests/handler/transaction/pom.xml
@@ -1,11 +1,11 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
-  <groupId>org.apache.felix</groupId>
-  <artifactId>org.apache.felix.ipojo.transaction.test</artifactId>
+  <groupId>ipojo.tests</groupId>
+  <artifactId>tests.transactions</artifactId>
   <packaging>jar</packaging>
   <version>1.3.0-SNAPSHOT</version>
-  <name>org.apache.felix.ipojo.transaction.test</name>
+  <name>iPOJO Transaction Handler Test Suite</name>
   <url>http://maven.apache.org</url>
   <dependencies>
     <dependency>
@@ -20,12 +20,17 @@
   	</dependency>
   	<dependency>
   		<groupId>org.apache.felix</groupId>
+  		<artifactId>org.apache.felix.ipojo.annotations</artifactId>
+  		<version>1.3.0-SNAPSHOT</version>
+  	</dependency>
+  	<dependency>
+  		<groupId>org.apache.felix</groupId>
   		<artifactId>org.apache.felix.transaction</artifactId>
   		<version>0.9.0-SNAPSHOT</version>
   	</dependency>
   	  	<dependency>
   		<groupId>org.apache.felix</groupId>
-  		<artifactId>org.apache.felix.ipojo.transaction</artifactId>
+  		<artifactId>org.apache.felix.ipojo.handler.transaction</artifactId>
   		<version>1.3.0-SNAPSHOT</version>
   	</dependency>
   <!--
@@ -64,7 +69,7 @@
 		<type>jar</type>
 		<scope>test</scope>
 	</dependency>
-	
+
 	<dependency>
 	  <groupId>org.apache.felix</groupId>
   	  <artifactId>org.apache.felix.ipojo.pax.exam.target</artifactId>
@@ -90,9 +95,9 @@
 	 	<artifactId>pax-logging-service</artifactId>
 	 	<version>1.3.0</version>
 	 </dependency>
-	
+
 	</dependencies>
-	
+
 	<repositories>
 		<repository>
 			<id>ops4j.releases</id>
@@ -106,7 +111,7 @@
 			</snapshots>
 		</repository>
 	</repositories>
-	
+
 		<build>
 		<plugins>
 			<plugin>
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestAnnotations.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestAnnotations.java
new file mode 100644
index 0000000..30aa3e7
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestAnnotations.java
@@ -0,0 +1,166 @@
+package org.apache.felix.ipojo.transaction.test;
+
+import static org.ops4j.pax.exam.CoreOptions.bundle;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.MavenUtils.asInProject;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.with;
+
+import java.io.File;
+import java.net.URL;
+
+import org.apache.felix.ipojo.metadata.Element;
+import org.apache.felix.ipojo.pax.exam.target.BundleAsiPOJO;
+import org.apache.felix.ipojo.transaction.test.component.ComponentUsingAnnotations;
+import org.apache.felix.ipojo.transaction.test.component.FooImpl;
+import org.apache.felix.ipojo.transaction.test.service.CheckService;
+import org.apache.felix.ipojo.transaction.test.service.Foo;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Inject;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+
+@RunWith( JUnit4TestRunner.class )
+public class TestAnnotations {
+
+    @Inject
+    private BundleContext context;
+
+    private OSGiHelper osgi;
+
+    private IPOJOHelper ipojo;
+
+    public static final File ROOT = new File("target/tmp");
+    public static final File TEST = new File("src/test/resources");
+
+
+    @Before
+    public void init() {
+        osgi = new OSGiHelper(context);
+        ipojo = new IPOJOHelper(context);
+    }
+
+    @After
+    public void stop() {
+        ipojo.dispose();
+        osgi.dispose();
+    }
+
+    @Configuration
+    public static Option[] configure() {
+        ROOT.mkdirs();
+
+        URL service = TinyBundles.newBundle()
+            .addClass(CheckService.class)
+            .addClass(Foo.class)
+           .prepare(
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
+                .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                )
+            .build( TinyBundles.asURL());
+
+        String fooimpl = TinyBundles.newBundle()
+            .addClass(FooImpl.class)
+            .prepare(
+                    with()
+                    .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
+                    .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                )
+                .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
+
+        String test = TinyBundles.newBundle()
+        .addClass(ComponentUsingAnnotations.class)
+        .prepare(
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Transaction Annotation Test")
+                .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
+            )
+            .build( new BundleAsiPOJO(new File(ROOT, "annotations.jar"), new File(TEST, "annotation.xml"))  ).toExternalForm();
+
+
+        Option[] opt =  options(
+
+                provision(
+                        mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
+                        mavenBundle()
+                        .groupId( "org.ops4j.pax.tinybundles" )
+                        .artifactId( "pax-tinybundles-core" )
+                        .version( "0.5.0-SNAPSHOT" ),
+                        bundle(service.toExternalForm()),
+                        bundle(fooimpl),
+                        bundle(test)
+                    )
+                )
+
+                ;
+        return opt;
+    }
+
+    @Test
+    public void annotations() {
+        Element elem = IPOJOHelper.getMetadata(getBundle(), "org.apache.felix.ipojo.transaction.test.component.ComponentUsingAnnotations");
+        Assert.assertNotNull(elem);
+
+        Element tr = elem.getElements("transaction", "org.apache.felix.ipojo.transaction")[0];
+        Assert.assertEquals("transaction", tr.getAttribute("field"));
+
+        Assert.assertNull(tr.getAttribute("oncommit"));
+        Assert.assertNull(tr.getAttribute("onrollback"));
+
+        Element[] methods = tr.getElements();
+        Assert.assertEquals(4, methods.length);
+
+        Element m1 = getElementByMethod(methods, "doSomethingBad");
+        Assert.assertNotNull(m1);
+
+        Element m2 = getElementByMethod(methods, "doSomethingBad2");
+        Assert.assertNotNull(m2);
+        Assert.assertEquals("required", m2.getAttribute("propagation"));
+
+        Element m3 = getElementByMethod(methods, "doSomethingGood");
+        Assert.assertNotNull(m3);
+        Assert.assertEquals("supported", m3.getAttribute("propagation"));
+        Assert.assertEquals("{java.lang.Exception}", m3.getAttribute("norollbackfor"));
+
+        Element m4 = getElementByMethod(methods, "doSomethingLong");
+        Assert.assertNotNull(m4);
+        Assert.assertEquals("1000", m4.getAttribute("timeout"));
+        Assert.assertEquals("true", m4.getAttribute("exceptiononrollback"));
+    }
+
+    private Element getElementByMethod(Element[] e, String m) {
+        for(Element elem : e) {
+            if(m.equals(elem.getAttribute("method"))) {
+                return elem;
+            }
+        }
+        Assert.fail("Method " + m + " not found");
+        return null;
+    }
+
+    private Bundle getBundle() {
+        for(Bundle b : context.getBundles()) {
+           if ("Transaction Annotation Test".equals(b.getSymbolicName())) {
+               return b;
+           }
+        }
+        Assert.fail("Cannot find the tested bundle");
+        return null;
+    }
+
+
+}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInstallation.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInstallation.java
index 0803abd..e1b3a8d 100644
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInstallation.java
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInstallation.java
@@ -103,7 +103,7 @@
                 provision(
                         mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
                         mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
-                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.transaction").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
                         mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
                         mavenBundle()
                         .groupId( "org.ops4j.pax.tinybundles" )
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInvalidation.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInvalidation.java
index a57a2a8..490fc9b 100644
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInvalidation.java
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInvalidation.java
@@ -41,71 +41,71 @@
 
 @RunWith( JUnit4TestRunner.class )
 public class TestInvalidation {
-    
+
     @Inject
     private BundleContext context;
-    
+
     private OSGiHelper osgi;
-    
+
     private IPOJOHelper ipojo;
-    
+
     public static final File ROOT = new File("target/tmp");
     public static final File TEST = new File("src/test/resources");
 
-    
+
     @Before
     public void init() {
         osgi = new OSGiHelper(context);
         ipojo = new IPOJOHelper(context);
     }
-    
+
     @After
     public void stop() {
         ipojo.dispose();
         osgi.dispose();
     }
-    
+
     @Configuration
-    public static Option[] configure() {    
+    public static Option[] configure() {
         ROOT.mkdirs();
 
-        
+
         URL service = TinyBundles.newBundle()
             .addClass(CheckService.class)
             .addClass(Foo.class)
-           .prepare( 
+           .prepare(
                 with()
                 .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
                 .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
                 .set(Constants.IMPORT_PACKAGE, "javax.transaction")
                 )
             .build( TinyBundles.asURL());
-            
+
         String fooimpl = TinyBundles.newBundle()
             .addClass(FooImpl.class)
-            .prepare( 
+            .prepare(
                     with()
                     .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
                     .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
                 )
                 .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
-        
+
         String test = TinyBundles.newBundle()
         .addClass(FooDelegator.class)
-        .prepare( 
+        .prepare(
                 with()
                 .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
                 .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
             )
             .build( new BundleAsiPOJO(new File(ROOT, "requires.jar"), new File(TEST, "requires.xml"))  ).toExternalForm();
-    
-        
+
+
         Option[] opt =  options(
- 
+
                 provision(
                         mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
                         mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
-                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.transaction").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
                         mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
                         mavenBundle()
                         .groupId( "org.ops4j.pax.tinybundles" )
@@ -120,24 +120,24 @@
                 ;
         return opt;
     }
-    
-    
-    
-    
+
+
+
+
     @Test
     public void testInvalidation() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         final ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("requires-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
-        
+
         Thread thread = new Thread (new Runnable() {
            public void run() {
                try {
@@ -148,19 +148,19 @@
                prov.dispose();
            }
         });
-        
+
         thread.start();
-        
+
         tm.begin();
         Transaction t = tm.getTransaction();
         cs.doSomethingLong(); // 5s, so prov should be disposed during this time and under becomes invalid
-        
+
         Assert.assertEquals(ComponentInstance.INVALID, under.getState());
-        
+
         Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
-        
+
         t.rollback();
     }
-    
-   
+
+
 }
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestMandatory.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestMandatory.java
index 66772e2..bc5eef1 100644
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestMandatory.java
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestMandatory.java
@@ -41,70 +41,70 @@
 
 @RunWith( JUnit4TestRunner.class )
 public class TestMandatory {
-    
+
     @Inject
     private BundleContext context;
-    
+
     private OSGiHelper osgi;
-    
+
     private IPOJOHelper ipojo;
-    
+
     public static final File ROOT = new File("target/tmp");
     public static final File TEST = new File("src/test/resources");
 
-    
+
     @Before
     public void init() {
         osgi = new OSGiHelper(context);
         ipojo = new IPOJOHelper(context);
     }
-    
+
     @After
     public void stop() {
         ipojo.dispose();
         osgi.dispose();
     }
-    
+
     @Configuration
-    public static Option[] configure() {    
+    public static Option[] configure() {
         ROOT.mkdirs();
 
         URL service = TinyBundles.newBundle()
             .addClass(CheckService.class)
             .addClass(Foo.class)
-           .prepare( 
+           .prepare(
                 with()
                 .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
                 .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
                 .set(Constants.IMPORT_PACKAGE, "javax.transaction")
                 )
             .build( TinyBundles.asURL());
-            
+
         String fooimpl = TinyBundles.newBundle()
             .addClass(FooImpl.class)
-            .prepare( 
+            .prepare(
                     with()
                     .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
                     .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
                 )
                 .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
-        
+
         String test = TinyBundles.newBundle()
         .addClass(FooDelegator.class)
-        .prepare( 
+        .prepare(
                 with()
                 .set(Constants.BUNDLE_SYMBOLICNAME,"Mandatory Transaction Propgatation")
                 .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
             )
             .build( new BundleAsiPOJO(new File(ROOT, "mandatory.jar"), new File(TEST, "mandatory.xml"))  ).toExternalForm();
-    
-        
+
+
         Option[] opt =  options(
- 
+
                 provision(
                         mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
                         mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
-                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.transaction").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
                         mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
                         mavenBundle()
                         .groupId( "org.ops4j.pax.tinybundles" )
@@ -119,33 +119,33 @@
                 ;
         return opt;
     }
-    
-    
+
+
     @Test(expected=RuntimeException.class)
     public void testOkOutsideTransaction() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("mandatory-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
         ((CheckService) osgi.getServiceObject(ref)).doSomethingGood(); // Fail !
     }
-    
+
     @Test
     public void testOkInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("mandatory-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -155,32 +155,32 @@
         Assert.assertSame(t2, t);
         t.commit();
     }
-    
+
     @Test(expected=RuntimeException.class)
     public void testExceptionOutsideTransaction() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("mandatory-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
         ((CheckService) osgi.getServiceObject(ref)).doSomethingBad(); // Fail, RTE thrown before the other exception
     }
-    
+
     @Test(expected=RollbackException.class)
     public void testExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("mandatory-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -194,21 +194,21 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
-        
+
         t.commit(); // Throws a rollback exception.
     }
-    
+
     @Test
     public void testExceptionInsideTransactionRB() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("mandatory-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -222,35 +222,35 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
-        
+
         t.rollback();
     }
-    
+
     @Test(expected=RuntimeException.class)
     public void testExpectedExceptionOutsideTransaction() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("mandatory-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
         ((CheckService) osgi.getServiceObject(ref)).doSomethingBad2(); // Throws a RTE
     }
-    
+
     @Test
     public void testExpectedExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("mandatory-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -264,39 +264,39 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-        
+
         t.commit();
     }
-    
+
     @Test(expected=RuntimeException.class)
     public void testOkOutsideTransactionWithCallback() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("mandatory-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
 
         cs.doSomethingGood(); // Throws a RTE.
-        
+
     }
-    
+
     @Test
     public void testOkInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("mandatory-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -305,43 +305,43 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         t.commit();
-        
+
         Assert.assertNull(cs.getLastRolledBack());
         Assert.assertNotNull(cs.getLastCommitted());
         Assert.assertEquals(1, cs.getNumberOfCommit());
         Assert.assertEquals(0, cs.getNumberOfRollback());
-        
+
         Assert.assertSame(t, cs.getLastCommitted());
     }
-    
+
     @Test(expected=RuntimeException.class)
     public void testExceptionOutsideTransactionWithCallback() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("mandatory-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
 
         cs.doSomethingBad(); // Thows a RTE.
-       
+
     }
-    
+
     @Test
     public void testExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("mandatory-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -355,7 +355,7 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
-        
+
         try {
             t.commit(); // Throw a rollback exception.
         } catch (RollbackException e) {
@@ -363,44 +363,44 @@
         } catch (Throwable e) {
             Assert.fail(e.getMessage()); // Unexpected
         }
-        
+
         Assert.assertNotNull(cs.getLastRolledBack());
         Assert.assertNull(cs.getLastCommitted());
         Assert.assertEquals(0, cs.getNumberOfCommit());
         Assert.assertEquals(1, cs.getNumberOfRollback());
-        
+
         Assert.assertSame(t, cs.getLastRolledBack());
     }
-    
+
     @Test(expected=RuntimeException.class)
     public void testExpectedExceptionOutsideTransactionWithCallback() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("mandatory-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
 
         cs.doSomethingBad2();
-        
-      
+
+
     }
-    
+
     @Test
     public void testExpectedExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("mandatory-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -414,17 +414,17 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-        
+
         t.commit();
-        
+
         Assert.assertNull(cs.getLastRolledBack());
         Assert.assertNotNull(cs.getLastCommitted());
         Assert.assertEquals(1, cs.getNumberOfCommit());
         Assert.assertEquals(0, cs.getNumberOfRollback());
-        
+
         Assert.assertSame(t, cs.getLastCommitted());
     }
-    
 
-    
+
+
 }
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNever.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNever.java
index 21d6369..3e38b54 100644
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNever.java
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNever.java
@@ -41,69 +41,69 @@
 
 @RunWith( JUnit4TestRunner.class )
 public class TestNever {
-    
+
     @Inject
     private BundleContext context;
-    
+
     private OSGiHelper osgi;
-    
+
     private IPOJOHelper ipojo;
     public static final File ROOT = new File("target/tmp");
     public static final File TEST = new File("src/test/resources");
 
-    
+
     @Before
     public void init() {
         osgi = new OSGiHelper(context);
         ipojo = new IPOJOHelper(context);
     }
-    
+
     @After
     public void stop() {
         ipojo.dispose();
         osgi.dispose();
     }
-    
+
     @Configuration
-    public static Option[] configure() {    
+    public static Option[] configure() {
         ROOT.mkdirs();
 
         URL service = TinyBundles.newBundle()
             .addClass(CheckService.class)
             .addClass(Foo.class)
-           .prepare( 
+           .prepare(
                 with()
                 .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
                 .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
                 .set(Constants.IMPORT_PACKAGE, "javax.transaction")
                 )
             .build( TinyBundles.asURL());
-            
+
         String fooimpl = TinyBundles.newBundle()
             .addClass(FooImpl.class)
-            .prepare( 
+            .prepare(
                     with()
                     .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
                     .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
                 )
                 .build( new BundleAsiPOJO(new File(ROOT,"FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
-        
+
         String test = TinyBundles.newBundle()
         .addClass(FooDelegator.class)
-        .prepare( 
+        .prepare(
                 with()
                 .set(Constants.BUNDLE_SYMBOLICNAME,"Mandatory Transaction Propgatation")
                 .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
             )
             .build( new BundleAsiPOJO(new File(ROOT, "never.jar"), new File(TEST, "never.xml"))  ).toExternalForm();
-    
-        
+
+
         Option[] opt =  options(
- 
+
                 provision(
                         mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
                         mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
-                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.transaction").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
                         mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
                         mavenBundle()
                         .groupId( "org.ops4j.pax.tinybundles" )
@@ -118,64 +118,64 @@
                 ;
         return opt;
     }
-    
-    
+
+
     @Test
     public void testOkOutsideTransaction() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("never-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
         ((CheckService) osgi.getServiceObject(ref)).doSomethingGood();
     }
-    
+
     @Test(expected=RuntimeException.class)
     public void testOkInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("never-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
         cs.doSomethingGood(); // Fail
     }
-    
+
     @Test(expected=NullPointerException.class)
     public void testExceptionOutsideTransaction() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("never-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
-        ((CheckService) osgi.getServiceObject(ref)).doSomethingBad(); // Throws an NPE 
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingBad(); // Throws an NPE
     }
-    
+
     @Test
     public void testExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("never-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -187,24 +187,24 @@
             Assert.assertTrue(e instanceof RuntimeException);
         }
         Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-        
-        t.rollback(); 
+
+        t.rollback();
     }
-    
+
     @Test(expected=UnsupportedOperationException.class)
     public void testExpectedExceptionOutsideTransaction() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("never-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
-        ((CheckService) osgi.getServiceObject(ref)).doSomethingBad2(); 
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingBad2();
     }
-    
-   
-    
+
+
+
 }
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNotSupported.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNotSupported.java
index bd866fc..7c98681 100644
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNotSupported.java
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNotSupported.java
@@ -41,69 +41,69 @@
 
 @RunWith( JUnit4TestRunner.class )
 public class TestNotSupported {
-    
+
     @Inject
     private BundleContext context;
-    
+
     private OSGiHelper osgi;
-    
+
     private IPOJOHelper ipojo;
     public static final File ROOT = new File("target/tmp");
     public static final File TEST = new File("src/test/resources");
 
-    
+
     @Before
     public void init() {
         osgi = new OSGiHelper(context);
         ipojo = new IPOJOHelper(context);
     }
-    
+
     @After
     public void stop() {
         ipojo.dispose();
         osgi.dispose();
     }
-    
+
     @Configuration
-    public static Option[] configure() {    
+    public static Option[] configure() {
         ROOT.mkdirs();
 
         URL service = TinyBundles.newBundle()
             .addClass(CheckService.class)
             .addClass(Foo.class)
-           .prepare( 
+           .prepare(
                 with()
                 .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
                 .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
                 .set(Constants.IMPORT_PACKAGE, "javax.transaction")
                 )
             .build( TinyBundles.asURL());
-            
+
         String fooimpl = TinyBundles.newBundle()
             .addClass(FooImpl.class)
-            .prepare( 
+            .prepare(
                     with()
                     .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
                     .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
                 )
                 .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
-        
+
         String test = TinyBundles.newBundle()
         .addClass(FooDelegator.class)
-        .prepare( 
+        .prepare(
                 with()
                 .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
                 .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
             )
             .build( new BundleAsiPOJO(new File(ROOT, "notsupported.jar"), new File(TEST, "notsupported.xml"))  ).toExternalForm();
-    
-        
+
+
         Option[] opt =  options(
- 
+
                 provision(
                         mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
                         mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
-                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.transaction").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
                         mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
                         mavenBundle()
                         .groupId( "org.ops4j.pax.tinybundles" )
@@ -118,16 +118,16 @@
                 ;
         return opt;
     }
-    
-    
+
+
     @Test
     public void testOkOutsideTransaction() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("notsupported-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
@@ -135,18 +135,18 @@
         cs.doSomethingGood();
         // No transaction.
     }
-    
+
     @Test
     public void testOkInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("notsupported-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -156,32 +156,32 @@
         Assert.assertSame(t2, t);
         t.commit();
     }
-    
+
     @Test(expected=NullPointerException.class)
     public void testExceptionOutsideTransaction() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("notsupported-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
         ((CheckService) osgi.getServiceObject(ref)).doSomethingBad();
     }
-    
+
     @Test
     public void testExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("notsupported-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -195,21 +195,21 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus()); // No impact on the transaction.
-        
+
         t.commit(); // Ok.
     }
-    
+
     @Test
     public void testExceptionInsideTransactionRB() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("notsupported-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -223,35 +223,35 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus()); // No impact on the transaction.
-        
+
         t.rollback(); // Ok.
     }
-    
+
     @Test(expected=UnsupportedOperationException.class)
     public void testExpectedExceptionOutsideTransaction() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("notsupported-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
         ((CheckService) osgi.getServiceObject(ref)).doSomethingBad2();
     }
-    
+
     @Test
     public void testExpectedExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("notsupported-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -265,43 +265,43 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-        
+
         t.commit();
     }
-    
+
     @Test
     public void testOkOutsideTransactionWithCallback() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("notsupported-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
 
         cs.doSomethingGood();
-        
+
         Assert.assertNull(cs.getLastRolledBack());
         Assert.assertNull(cs.getLastCommitted());
         Assert.assertEquals(0, cs.getNumberOfCommit());
         Assert.assertEquals(0, cs.getNumberOfRollback());
     }
-    
+
     @Test
     public void testOkInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("notsupported-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -310,45 +310,45 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         t.commit();
-        
+
         Assert.assertNull(cs.getLastRolledBack());
         Assert.assertNull(cs.getLastCommitted());
         Assert.assertEquals(0, cs.getNumberOfCommit());
         Assert.assertEquals(0, cs.getNumberOfRollback());
     }
-    
+
     @Test(expected=NullPointerException.class)
     public void testExceptionOutsideTransactionWithCallback() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("notsupported-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
 
         cs.doSomethingBad();
-        
+
         Assert.assertNull(cs.getLastRolledBack());
         Assert.assertNull(cs.getLastCommitted());
         Assert.assertEquals(0, cs.getNumberOfCommit());
         Assert.assertEquals(0, cs.getNumberOfRollback());
     }
-    
+
     @Test
     public void testExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("notsupported-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -362,7 +362,7 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus()); // No effect on the transaction
-        
+
         try {
             t.commit(); // Throw a rollback exception.
         } catch (RollbackException e) {
@@ -370,45 +370,45 @@
         } catch (Throwable e) {
             Assert.fail(e.getMessage()); // Unexpected
         }
-        
+
         Assert.assertNull(cs.getLastRolledBack());
         Assert.assertNull(cs.getLastCommitted());
         Assert.assertEquals(0, cs.getNumberOfCommit());
         Assert.assertEquals(0, cs.getNumberOfRollback());
     }
-    
+
     @Test(expected=UnsupportedOperationException.class)
     public void testExpectedExceptionOutsideTransactionWithCallback() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("notsupported-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
 
         cs.doSomethingBad2();
-        
+
         Assert.assertNull(cs.getLastRolledBack());
         Assert.assertNull(cs.getLastCommitted());
         Assert.assertEquals(0, cs.getNumberOfCommit());
         Assert.assertEquals(0, cs.getNumberOfRollback());
     }
-    
+
     @Test
     public void testExpectedExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("notsupported-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -422,15 +422,15 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-        
+
         t.commit();
-        
+
         Assert.assertNull(cs.getLastRolledBack());
         Assert.assertNull(cs.getLastCommitted());
         Assert.assertEquals(0, cs.getNumberOfCommit());
         Assert.assertEquals(0, cs.getNumberOfRollback());
     }
-    
 
-    
+
+
 }
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequires.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequires.java
index 75839a3..781e0dd 100644
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequires.java
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequires.java
@@ -41,70 +41,70 @@
 
 @RunWith( JUnit4TestRunner.class )
 public class TestRequires {
-    
+
     @Inject
     private BundleContext context;
-    
+
     private OSGiHelper osgi;
-    
+
     private IPOJOHelper ipojo;
-    
+
     public static final File ROOT = new File("target/tmp");
     public static final File TEST = new File("src/test/resources");
 
-    
+
     @Before
     public void init() {
         osgi = new OSGiHelper(context);
         ipojo = new IPOJOHelper(context);
     }
-    
+
     @After
     public void stop() {
         ipojo.dispose();
         osgi.dispose();
     }
-    
+
     @Configuration
-    public static Option[] configure() {    
+    public static Option[] configure() {
         ROOT.mkdirs();
 
         URL service = TinyBundles.newBundle()
             .addClass(CheckService.class)
             .addClass(Foo.class)
-           .prepare( 
+           .prepare(
                 with()
                 .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
                 .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
                 .set(Constants.IMPORT_PACKAGE, "javax.transaction")
                 )
             .build( TinyBundles.asURL());
-            
+
         String fooimpl = TinyBundles.newBundle()
             .addClass(FooImpl.class)
-            .prepare( 
+            .prepare(
                     with()
                     .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
                     .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
                 )
                 .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
-        
+
         String test = TinyBundles.newBundle()
         .addClass(FooDelegator.class)
-        .prepare( 
+        .prepare(
                 with()
                 .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
                 .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
             )
             .build( new BundleAsiPOJO(new File(ROOT, "requires.jar"), new File(TEST, "requires.xml"))  ).toExternalForm();
-    
-        
+
+
         Option[] opt =  options(
- 
+
                 provision(
                         mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
                         mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
-                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.transaction").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
                         mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
                         mavenBundle()
                         .groupId( "org.ops4j.pax.tinybundles" )
@@ -119,33 +119,33 @@
                 ;
         return opt;
     }
-    
-    
+
+
     @Test
     public void testOkOutsideTransaction() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("requires-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
         ((CheckService) osgi.getServiceObject(ref)).doSomethingGood();
     }
-    
+
     @Test
     public void testOkInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("requires-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -155,32 +155,32 @@
         Assert.assertSame(t2, t);
         t.commit();
     }
-    
+
     @Test(expected=NullPointerException.class)
     public void testExceptionOutsideTransaction() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("requires-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
         ((CheckService) osgi.getServiceObject(ref)).doSomethingBad();
     }
-    
+
     @Test(expected=RollbackException.class)
     public void testExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("requires-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -194,21 +194,21 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
-        
+
         t.commit(); // Throw a rollback exception.
     }
-    
+
     @Test
     public void testExceptionInsideTransactionRB() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("requires-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -222,35 +222,35 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
-        
+
         t.rollback();
     }
-    
+
     @Test(expected=UnsupportedOperationException.class)
     public void testExpectedExceptionOutsideTransaction() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("requires-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
         ((CheckService) osgi.getServiceObject(ref)).doSomethingBad2();
     }
-    
+
     @Test
     public void testExpectedExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("requires-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -264,43 +264,43 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-        
+
         t.commit();
     }
-    
+
     @Test
     public void testOkOutsideTransactionWithCallback() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("requires-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
 
         cs.doSomethingGood();
-        
+
         Assert.assertNull(cs.getLastRolledBack());
         Assert.assertNotNull(cs.getLastCommitted());
         Assert.assertEquals(1, cs.getNumberOfCommit());
         Assert.assertEquals(0, cs.getNumberOfRollback());
     }
-    
+
     @Test
     public void testOkInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("requires-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -309,47 +309,47 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         t.commit();
-        
+
         Assert.assertNull(cs.getLastRolledBack());
         Assert.assertNotNull(cs.getLastCommitted());
         Assert.assertEquals(1, cs.getNumberOfCommit());
         Assert.assertEquals(0, cs.getNumberOfRollback());
-        
+
         Assert.assertSame(t, cs.getLastCommitted());
     }
-    
+
     @Test(expected=NullPointerException.class)
     public void testExceptionOutsideTransactionWithCallback() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("requires-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
 
         cs.doSomethingBad();
-        
+
         Assert.assertNotNull(cs.getLastRolledBack());
         Assert.assertNull(cs.getLastCommitted());
         Assert.assertEquals(0, cs.getNumberOfCommit());
         Assert.assertEquals(1, cs.getNumberOfRollback());
     }
-    
+
     @Test
     public void testExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("requires-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -363,7 +363,7 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
-        
+
         try {
             t.commit(); // Throw a rollback exception.
         } catch (RollbackException e) {
@@ -371,47 +371,47 @@
         } catch (Throwable e) {
             Assert.fail(e.getMessage()); // Unexpected
         }
-        
+
         Assert.assertNotNull(cs.getLastRolledBack());
         Assert.assertNull(cs.getLastCommitted());
         Assert.assertEquals(0, cs.getNumberOfCommit());
         Assert.assertEquals(1, cs.getNumberOfRollback());
-        
+
         Assert.assertSame(t, cs.getLastRolledBack());
     }
-    
+
     @Test(expected=UnsupportedOperationException.class)
     public void testExpectedExceptionOutsideTransactionWithCallback() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("requires-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
 
         cs.doSomethingBad2();
-        
+
         Assert.assertNull(cs.getLastRolledBack());
         Assert.assertNotNull(cs.getLastCommitted());
         Assert.assertEquals(1, cs.getNumberOfCommit());
         Assert.assertEquals(0, cs.getNumberOfRollback());
     }
-    
+
     @Test
     public void testExpectedExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("requires-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -425,17 +425,17 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-        
+
         t.commit();
-        
+
         Assert.assertNull(cs.getLastRolledBack());
         Assert.assertNotNull(cs.getLastCommitted());
         Assert.assertEquals(1, cs.getNumberOfCommit());
         Assert.assertEquals(0, cs.getNumberOfRollback());
-        
+
         Assert.assertSame(t, cs.getLastCommitted());
     }
-    
 
-    
+
+
 }
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequiresNew.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequiresNew.java
index 974fca9..00805ed 100644
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequiresNew.java
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequiresNew.java
@@ -41,70 +41,70 @@
 
 @RunWith( JUnit4TestRunner.class )
 public class TestRequiresNew {
-    
+
     @Inject
     private BundleContext context;
-    
+
     private OSGiHelper osgi;
-    
+
     private IPOJOHelper ipojo;
-    
+
     public static final File ROOT = new File("target/tmp");
     public static final File TEST = new File("src/test/resources");
 
-    
+
     @Before
     public void init() {
         osgi = new OSGiHelper(context);
         ipojo = new IPOJOHelper(context);
     }
-    
+
     @After
     public void stop() {
         ipojo.dispose();
         osgi.dispose();
     }
-    
+
     @Configuration
-    public static Option[] configure() {    
+    public static Option[] configure() {
         ROOT.mkdirs();
 
         URL service = TinyBundles.newBundle()
             .addClass(CheckService.class)
             .addClass(Foo.class)
-           .prepare( 
+           .prepare(
                 with()
                 .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
                 .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
                 .set(Constants.IMPORT_PACKAGE, "javax.transaction")
                 )
             .build( TinyBundles.asURL());
-            
+
         String fooimpl = TinyBundles.newBundle()
             .addClass(FooImpl.class)
-            .prepare( 
+            .prepare(
                     with()
                     .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
                     .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
                 )
                 .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
-        
+
         String test = TinyBundles.newBundle()
         .addClass(FooDelegator.class)
-        .prepare( 
+        .prepare(
                 with()
                 .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
                 .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
             )
             .build( new BundleAsiPOJO(new File(ROOT, "requiresnew.jar"), new File(TEST, "requiresnew.xml"))  ).toExternalForm();
-    
-        
+
+
         Option[] opt =  options(
- 
+
                 provision(
                         mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
                         mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
-                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.transaction").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
                         mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
                         mavenBundle()
                         .groupId( "org.ops4j.pax.tinybundles" )
@@ -119,33 +119,33 @@
                 ;
         return opt;
     }
-    
-    
+
+
     @Test
     public void testOkOutsideTransaction() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
         ((CheckService) osgi.getServiceObject(ref)).doSomethingGood(); // Ok
     }
-    
+
     @Test
     public void testOkInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -157,15 +157,15 @@
         Assert.assertEquals(Status.STATUS_NO_TRANSACTION, t2.getStatus());
         t.commit();
     }
-    
+
     @Test
     public void testExceptionOutsideTransaction() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
@@ -178,18 +178,18 @@
             Assert.fail("IllegalStateException expected on rollback");
         }
     }
-    
+
     @Test
     public void testExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -205,35 +205,35 @@
         // Check that t2 is rolledback
         Assert.assertEquals(Status.STATUS_NO_TRANSACTION, t2.getStatus());
         Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-        
+
         t.commit();
     }
-    
+
     @Test(expected=UnsupportedOperationException.class)
     public void testExpectedExceptionOutsideTransaction() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
         ((CheckService) osgi.getServiceObject(ref)).doSomethingBad2();
     }
-    
+
     @Test
     public void testExpectedExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -248,7 +248,7 @@
         Assert.assertNotSame(t2, t);
         Assert.assertEquals(Status.STATUS_NO_TRANSACTION, t2.getStatus());
         Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-        
+
         t.commit();
     }
 }
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestSupported.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestSupported.java
index 962ab17..7a2e6e2 100644
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestSupported.java
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestSupported.java
@@ -41,69 +41,69 @@
 
 @RunWith( JUnit4TestRunner.class )
 public class TestSupported {
-    
+
     @Inject
     private BundleContext context;
-    
+
     private OSGiHelper osgi;
-    
+
     private IPOJOHelper ipojo;
     public static final File ROOT = new File("target/tmp");
     public static final File TEST = new File("src/test/resources");
 
-    
+
     @Before
     public void init() {
         osgi = new OSGiHelper(context);
         ipojo = new IPOJOHelper(context);
     }
-    
+
     @After
     public void stop() {
         ipojo.dispose();
         osgi.dispose();
     }
-    
+
     @Configuration
-    public static Option[] configure() {    
+    public static Option[] configure() {
         ROOT.mkdirs();
 
         URL service = TinyBundles.newBundle()
             .addClass(CheckService.class)
             .addClass(Foo.class)
-           .prepare( 
+           .prepare(
                 with()
                 .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
                 .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
                 .set(Constants.IMPORT_PACKAGE, "javax.transaction")
                 )
             .build( TinyBundles.asURL());
-            
+
         String fooimpl = TinyBundles.newBundle()
             .addClass(FooImpl.class)
-            .prepare( 
+            .prepare(
                     with()
                     .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
                     .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
                 )
                 .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
-        
+
         String test = TinyBundles.newBundle()
         .addClass(FooDelegator.class)
-        .prepare( 
+        .prepare(
                 with()
                 .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
                 .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
             )
             .build( new BundleAsiPOJO(new File(ROOT, "supported.jar"), new File(TEST, "supported.xml"))  ).toExternalForm();
-    
-        
+
+
         Option[] opt =  options(
- 
+
                 provision(
                         mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
                         mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
-                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.transaction").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
                         mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
                         mavenBundle()
                         .groupId( "org.ops4j.pax.tinybundles" )
@@ -118,16 +118,16 @@
                 ;
         return opt;
     }
-    
-    
+
+
     @Test
     public void testOkOutsideTransaction() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("supported-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
@@ -135,18 +135,18 @@
         cs.doSomethingGood();
         // No transaction.
     }
-    
+
     @Test
     public void testOkInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("supported-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -156,32 +156,32 @@
         Assert.assertSame(t2, t);
         t.commit();
     }
-    
+
     @Test(expected=NullPointerException.class)
     public void testExceptionOutsideTransaction() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("supported-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
         ((CheckService) osgi.getServiceObject(ref)).doSomethingBad();
     }
-    
+
     @Test(expected=RollbackException.class)
     public void testExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("supported-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -195,21 +195,21 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
-        
+
         t.commit(); // Throw a rollback exception.
     }
-    
+
     @Test
     public void testExceptionInsideTransactionRB() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("supported-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -223,35 +223,35 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
-        
+
         t.rollback();
     }
-    
+
     @Test(expected=UnsupportedOperationException.class)
     public void testExpectedExceptionOutsideTransaction() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("supported-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
         ((CheckService) osgi.getServiceObject(ref)).doSomethingBad2();
     }
-    
+
     @Test
     public void testExpectedExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("supported-ok");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -265,43 +265,43 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-        
+
         t.commit();
     }
-    
+
     @Test
     public void testOkOutsideTransactionWithCallback() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("supported-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
 
         cs.doSomethingGood();
-        
+
         Assert.assertNull(cs.getLastRolledBack());
         Assert.assertNull(cs.getLastCommitted());
         Assert.assertEquals(0, cs.getNumberOfCommit());
         Assert.assertEquals(0, cs.getNumberOfRollback());
     }
-    
+
     @Test
     public void testOkInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("supported-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -310,47 +310,47 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         t.commit();
-        
+
         Assert.assertNull(cs.getLastRolledBack());
         Assert.assertNotNull(cs.getLastCommitted());
         Assert.assertEquals(1, cs.getNumberOfCommit());
         Assert.assertEquals(0, cs.getNumberOfRollback());
-        
+
         Assert.assertSame(t, cs.getLastCommitted());
     }
-    
+
     @Test(expected=NullPointerException.class)
     public void testExceptionOutsideTransactionWithCallback() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("supported-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
 
         cs.doSomethingBad();
-        
+
         Assert.assertNull(cs.getLastRolledBack());
         Assert.assertNull(cs.getLastCommitted());
         Assert.assertEquals(0, cs.getNumberOfCommit());
         Assert.assertEquals(0, cs.getNumberOfRollback());
     }
-    
+
     @Test
     public void testExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("supported-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -364,7 +364,7 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
-        
+
         try {
             t.commit(); // Throw a rollback exception.
         } catch (RollbackException e) {
@@ -372,47 +372,47 @@
         } catch (Throwable e) {
             Assert.fail(e.getMessage()); // Unexpected
         }
-        
+
         Assert.assertNotNull(cs.getLastRolledBack());
         Assert.assertNull(cs.getLastCommitted());
         Assert.assertEquals(0, cs.getNumberOfCommit());
         Assert.assertEquals(1, cs.getNumberOfRollback());
-        
+
         Assert.assertSame(t, cs.getLastRolledBack());
     }
-    
+
     @Test(expected=UnsupportedOperationException.class)
     public void testExpectedExceptionOutsideTransactionWithCallback() {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("supported-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
 
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
 
         cs.doSomethingBad2();
-        
+
         Assert.assertNull(cs.getLastRolledBack());
         Assert.assertNull(cs.getLastCommitted());
         Assert.assertEquals(0, cs.getNumberOfCommit());
         Assert.assertEquals(0, cs.getNumberOfRollback());
     }
-    
+
     @Test
     public void testExpectedExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
         ComponentInstance under = ipojo.createComponentInstance("supported-cb");
-        
+
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());
-        
+
         ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
         Assert.assertNotNull(ref);
-        
+
         CheckService cs = (CheckService) osgi.getServiceObject(ref);
         TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
         tm.begin();
@@ -426,17 +426,17 @@
         Transaction t2 = cs.getCurrentTransaction();
         Assert.assertSame(t2, t);
         Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-        
+
         t.commit();
-        
+
         Assert.assertNull(cs.getLastRolledBack());
         Assert.assertNotNull(cs.getLastCommitted());
         Assert.assertEquals(1, cs.getNumberOfCommit());
         Assert.assertEquals(0, cs.getNumberOfRollback());
-        
+
         Assert.assertSame(t, cs.getLastCommitted());
     }
-    
 
-    
+
+
 }
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/component/ComponentUsingAnnotations.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/component/ComponentUsingAnnotations.java
new file mode 100644
index 0000000..a516556
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/component/ComponentUsingAnnotations.java
@@ -0,0 +1,34 @@
+package org.apache.felix.ipojo.transaction.test.component;
+
+import javax.transaction.Transaction;
+
+import org.apache.felix.ipojo.annotations.Component;
+
+@Component
+@org.apache.felix.ipojo.transaction.Transaction(field="transaction")
+public class ComponentUsingAnnotations {
+
+    Transaction transaction;
+
+
+    @org.apache.felix.ipojo.transaction.Transactionnal
+    public void doSomethingBad() throws NullPointerException {
+    }
+
+    @org.apache.felix.ipojo.transaction.Transactionnal(propagation="required")
+    public void doSomethingBad2() throws UnsupportedOperationException {
+
+    }
+
+    @org.apache.felix.ipojo.transaction.Transactionnal(propagation="supported", norollbackfor= {"java.lang.Exception"})
+    public void doSomethingGood() {
+
+    }
+
+    @org.apache.felix.ipojo.transaction.Transactionnal(timeout=1000, exceptiononrollback=true)
+    public void doSomethingLong() {
+
+    }
+
+
+}
diff --git a/ipojo/tests/handler/transaction/src/test/resources/annotation.xml b/ipojo/tests/handler/transaction/src/test/resources/annotation.xml
new file mode 100644
index 0000000..d1aa123
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/resources/annotation.xml
@@ -0,0 +1,3 @@
+<ipojo xmlns:tr="org.apache.felix.ipojo.transaction">
+
+</ipojo>
\ No newline at end of file
