1

arquillian 1.1.1.Final を使用するプロジェクトがあり、グラフェンやその他の拡張機能を使用したいくつかの動作テストがあります。ここで、ワープを使用していくつかのテストを追加したいと思います。しかし、NoClassDefFoundError が発生しています。例外は次のとおりです。

 class br.com.sample.view.LoginTest$1 in Module "deployment.login.war:main" from Service Module Loader: java.lang.LinkageError: Failed to link br/com/sample/view/LoginTest$1 (Module "deployment.login.war:main" from Service Module Loader)
  at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:396) [jboss-modules.jar:1.1.1.GA]
  at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:243) [jboss-modules.jar:1.1.1.GA]
  at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:73) [jboss-modules.jar:1.1.1.GA]
  at org.jboss.modules.Module.loadModuleClass(Module.java:517) [jboss-modules.jar:1.1.1.GA]
  at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:182) [jboss-modules.jar:1.1.1.GA]
  at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.1.GA]
  at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.1.GA]
  at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.1.GA]
  at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.1.GA]
  at org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner.getPackagesInJar(HibernateAnnotationScanner.java:171)
  at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:489) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
  at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:851) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
  at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:596) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
  at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
  at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
  at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
  at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
  at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_25]
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_25]
  at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]
Caused by: java.lang.NoClassDefFoundError: org/jboss/arquillian/warp/Activity
  at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.7.0_25]
  at java.lang.ClassLoader.defineClass(ClassLoader.java:788) [rt.jar:1.7.0_25]
  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) [rt.jar:1.7.0_25]
  at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:327) [jboss-modules.jar:1.1.1.GA]
  at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:391) [jboss-modules.jar:1.1.1.GA]
  ... 20 more
Caused by: java.lang.ClassNotFoundException: org.jboss.arquillian.warp.Activity from [Module "deployment.login.war:main" from Service Module Loader]
  at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.1.GA]
  at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.1.GA]
  at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.1.GA]
  at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.1.GA]
  at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.1.GA]
  ... 25 more


13:26:07,636 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC00001: Failed to start service jboss.persistenceunit."login.war#test-ds": org.jboss.msc.service.StartException in service jboss.persistenceunit."login.war#test-ds": Failed to start service
  at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_25]
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_25]
  at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]
Caused by: java.lang.RuntimeException: error trying to scan <jar-file>: vfs:/content/login.war/WEB-INF/classes/
  at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:854)
  at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:596)
  at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72)
  at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)
  at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)
  at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
  at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
  ... 3 more
Caused by: java.lang.RuntimeException: JBAS011431: Could not load entity class 'br.com.sample.view.LoginTest$1' with PersistenceUnitInfo.getClassLoader()
  at org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner.getPackagesInJar(HibernateAnnotationScanner.java:175)
  at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:489)
  at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:851)
  ... 9 more
Caused by: java.lang.ClassNotFoundException: br.com.sample.view.LoginTest$1 from [Module "deployment.login.war:main" from Service Module Loader]
  at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.1.GA]
  at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.1.GA]
  at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.1.GA]
  at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.1.GA]
  at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.1.GA]
  at org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner.getPackagesInJar(HibernateAnnotationScanner.java:171)
  ... 11 more

私のテストは次のようになります。

@RunWith(Arquillian.class)  
@WarpTest  
@RunAsClient  
public class LoginTest {  

  @Drone  
  private WebDriver browser;  

  @Page  
  private LoginPage loginPage;  


  @ArquillianResource  
  URL deploymentUrl;  


  @Deployment  
  public static WebArchive createDeployment() {  
  DatabaseUtils.createDatabase();  
  return Deployments.createDefaultDeployment();  
  }  

  private void insertDataAndGetLoginUrl() {  
  DatabaseUtils.setTestData("datasets/users.xml");  
  browser.get(deploymentUrl + "/login" + Constants.JSF_EXTENSION);  
  }  

  @Test  
  public void loginSuccessful() {  
  insertDataAndGetLoginUrl();  

  Warp.initiate(new Activity() {  
  @Override  
  public void perform() {  
  loginPage.login("admin", "Admin123");  

  }  
  });  

  String location = browser.getCurrentUrl();  


  assertThat(location, containsString("user/search" + Constants.JSF_EXTENSION));  
  }}  

そして、私のpomには次のものがあります:

<dependency>
  <groupId>org.jboss.arquillian.extension</groupId>
  <artifactId>arquillian-warp-bom</artifactId>
  <version>1.0.0.Alpha4</version>
  <type>pom</type>
  <scope>import</scope>
</dependency>
<dependency>
  <groupId>org.jboss.arquillian.extension</groupId>
  <artifactId>arquillian-warp</artifactId>
  <version>1.0.0.Alpha4</version>
  <type>pom</type>
  <scope>test</scope>
</dependency>

誰でも助けることができますか?

4

2 に答える 2

1

ここでの問題は、次の 2 つの要因の組み合わせです。

  • Hibernate は Web アーカイブ内のクラスをスキャンし、匿名クラスのアクティビティをロードできず、失敗します (そのような失敗を無視する必要がありますが、CDI/Weld と同じです)。

  • Warp はパッケージからアクティビティを削除しません

回避策として、archive.addClass(Activity.class) が役立つと思います。

于 2013-10-09T13:05:34.683 に答える
0

Arquillian はテストごとにマイクロ デプロイを作成します。.Libraries、リソースなどを実行するために必要なすべてのテストをロードする必要があります。

私のテストでは、次の構成を使用しましたが、これは正常に機能しています。

@RunWith(Arquillian.class)
@DataSource("java:/analyticsTestDS")
@UsingDataSet("datasets/account/account-registration-activate.xml")
public class AccountRegistrationActivateServiceImplTest extends PostgresDBTestCase {


    @Deployment
    public static Archive<?> createTestArchive() {

        PomEquippedResolveStage pom = Maven.resolver().loadPomFromFile("pom.xml");
        File[] commonsLang = pom.resolve(
                "org.jadira.usertype:usertype.core",
                "org.hibernate:hibernate-validator",
                "edu.vt.middleware:vt-password",
                 "monetdb:monetdb-jdbc",
                "joda-time:joda-time"
        ).withTransitivity().asFile();

        WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war")
                .addPackages(true, "com.atomsail.analytics.accounts")
                .addAsResource("META-INF/test-persistence.xml", "META-INF/persistence.xml")
                .addAsWebInfResource("ejb/account/account-registration-services-jboss-ejb3.xml", "jboss-ejb3.xml")
                .addAsWebInfResource("test-web.xml", "web.xml")
                .addAsResource("truncate_all_app.sql")
                .addAsLibraries(commonsLang);

        System.out.println(war.toString(true));


        return war;
    }




@Test
@InSequence(1)
public void activationTest()  {



}

}

于 2016-10-07T14:39:24.223 に答える