title: Maven, JUnit, OpenEJB, ApplicationComposer leads to java.lang.NoSuchMethodError
body: <p>While executin the test (test looks like this: <a href="http://tomee.apache.org/examples-trunk/application-composer/README.html" rel="nofollow">http://tomee.apache.org/examples-trunk/application-composer/README.html</a>), I always get:</p>
  
  <pre><code>java.lang.NoSuchMethodError: org.apache.openejb.jee.ManagedBean.&lt;init&gt;(Ljava/lang/String;Ljava/lang/String;Z)V
      at org.apache.openejb.junit.ApplicationComposer$DeployApplication.evaluate(ApplicationComposer.java:194)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
  </code></pre>
  
  <p>I try to use Maven in order to get all the dependencies right. Here is the list of dependencies:</p>
  
  <pre><code>&lt;dependency&gt;
              &lt;groupId&gt;javax.faces&lt;/groupId&gt;
              &lt;artifactId&gt;jsf-api&lt;/artifactId&gt;
              &lt;version&gt;2.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;5.1.21&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.openejb&lt;/groupId&gt;
              &lt;artifactId&gt;javaee-api&lt;/artifactId&gt;
              &lt;version&gt;6.0-4&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.openejb&lt;/groupId&gt;
              &lt;artifactId&gt;openejb-jee&lt;/artifactId&gt;
              &lt;version&gt;4.0.0-beta-1&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.openjpa&lt;/groupId&gt;
              &lt;artifactId&gt;openjpa-persistence-jdbc&lt;/artifactId&gt;
              &lt;version&gt;2.2.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;4.10&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.openejb&lt;/groupId&gt;
              &lt;artifactId&gt;openejb-junit&lt;/artifactId&gt;
              &lt;version&gt;4.5.0&lt;/version&gt;
          &lt;/dependency&gt;
   &lt;dependency&gt;
              &lt;groupId&gt;javax.persistence&lt;/groupId&gt;
              &lt;artifactId&gt;persistence-api&lt;/artifactId&gt;
              &lt;version&gt;1.0.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.primefaces&lt;/groupId&gt;
              &lt;artifactId&gt;primefaces&lt;/artifactId&gt;
              &lt;version&gt;3.4.2&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>The test should check an EJB-DAO. It is used to write an Entity in the DB and get it out of it again. Here is the test code:</p>
  
  <pre><code>    import com.dlrg.dao.impl.RadioMessageDAOImp;
  import com.dlrg.entity.RadioMessage;
  import org.apache.openejb.jee.EjbJar;
  import org.apache.openejb.jee.StatefulBean;
  import org.apache.openejb.jee.jpa.unit.PersistenceUnit;
  import org.apache.openejb.junit.ApplicationComposer;
  import org.apache.openejb.junit.Configuration;
  import org.apache.openejb.junit.Module;
  import org.junit.Assert;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  
  import javax.annotation.Resource;
  import javax.ejb.EJB;
  import javax.persistence.EntityManager;
  import javax.persistence.PersistenceContext;
  import javax.transaction.UserTransaction;
  import java.util.List;
  import java.util.Properties;
  
  @RunWith(ApplicationComposer.class)
  public class RadioMessageDAOTest {
  
      @EJB
      private RadioMessageDAOImp radioMessageDAO;
  
      @Resource
      private UserTransaction userTransaction;
  
      @PersistenceContext
      private EntityManager entityManager;
  
      @Configuration
      public Properties config() throws Exception {
          Properties p = new Properties();
          p.put("MySQLtest", "new://Resource?type=DataSource");
          p.put("MySQLtest.JdbcDriver", "org.hsqldb.jdbcDriver");
          p.put("MySQLtest.JdbcUrl", "jdbc:hsqldb:file:data/hsqldb/hsqldb");
          return p;
      }
  
      @Module
      public PersistenceUnit persistence() {
          PersistenceUnit unit = new PersistenceUnit("radio-unit");
          unit.setJtaDataSource("MySQLtest");
          unit.setNonJtaDataSource("radioDatabaseUnmanaged");
          unit.getClazz().add(RadioMessage.class.getName());
          unit.setProperty("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
          return unit;
      }
  
      @Module
      public EjbJar beans() {
          EjbJar ejbJar = new EjbJar("radio-beans");
          ejbJar.addEnterpriseBean(new StatefulBean(RadioMessageDAOImp.class));
          return ejbJar;
      }
  
  
  
      @Test
      public void test() throws Exception {
  
          userTransaction.begin();
  
          try {
              entityManager.persist(new RadioMessage());
  
              List&lt;RadioMessage&gt; list = radioMessageDAO.getAll();
              Assert.assertEquals(1, list.size());
  
              for (RadioMessage movie : list) {
                  radioMessageDAO.delete(movie);
              }
  
              Assert.assertEquals(0, radioMessageDAO.getAll().size());
  
          } finally {
              userTransaction.commit();
          }
      }
  }
  </code></pre>