Arquillian Exception:java.lang.NoClassDefFoundError

Issue:

When you deploy and run Arquillian testcase, you may encountered java.lang.NoClassDefFoundError exception like following.

 

Exception:

15:07:54,364 INFO  [org.jboss.as.repository] (management-handler-thread - 13) JBAS014900: Content added at location D:\jboss\standalone\data\content\f4\db8b058b61b2509e8ed692bacb90d9641b5b4e\content
15:07:54,366 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "test.war"
15:07:57,922 INFO  [org.jboss.as.jpa] (MSC service thread 1-9) JBAS011401: Read persistence.xml for primary
15:07:57,931 INFO  [org.jboss.weld.deployer] (MSC service thread 1-8) JBAS016002: Processing weld deployment test.war
15:07:57,932 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-8) JNDI bindings for session bean named BirdRegistration in deployment unit deployment "test.war" are as follows:

 java:global/test/BirdRegistration!net.mytest.xye.service.BirdRegistration
 java:app/test/BirdRegistration!net.mytest.xye.service.BirdRegistration
 java:module/BirdRegistration!net.mytest.xye.service.BirdRegistration
 java:global/test/BirdRegistration
 java:app/test/BirdRegistration
 java:module/BirdRegistration

15:07:57,941 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) JBAS016005: Starting Services for CDI deployment: test.war
15:07:57,942 INFO  [org.jboss.as.jpa] (MSC service thread 1-12) JBAS011402: Starting Persistence Unit Service 'test.war#primary'
15:07:57,943 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) JBAS010400: Bound data source [jboss/datasources/XYE-webapp5TestDS]
15:07:57,944 INFO  [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-12) HHH000204: Processing PersistenceUnitInfo [
 name: primary
 ...]
15:07:57,949 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-12) MSC00001: Failed to start service jboss.persistenceunit."test.war#primary": org.jboss.msc.service.StartException in service jboss.persistenceunit."test.war#primary": 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$Worker.runTask(Unknown Source) [rt.jar:1.6.0_35]
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_35]
 at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_35]
Caused by: java.lang.NoClassDefFoundError: net/mytest/xye/model/Sighting
 at java.lang.Class.getDeclaredMethods0(Native Method) [rt.jar:1.6.0_35]
 at java.lang.Class.privateGetDeclaredMethods(Unknown Source) [rt.jar:1.6.0_35]
 at java.lang.Class.getDeclaredMethods(Unknown Source) [rt.jar:1.6.0_35]
 at org.hibernate.annotations.common.reflection.java.JavaXClass.getDeclaredMethodProperties(JavaXClass.java:112)
 at org.hibernate.annotations.common.reflection.java.JavaXClass.getDeclaredProperties(JavaXClass.java:129)
 at org.hibernate.annotations.common.reflection.java.JavaXClass.getDeclaredProperties(JavaXClass.java:121)
 at org.hibernate.cfg.InheritanceState.determineDefaultAccessType(InheritanceState.java:262)
 at org.hibernate.cfg.InheritanceState.getElementsToProcess(InheritanceState.java:224)
 at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:663)
 at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3406)
 at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3360)
 at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1334)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1724)
 at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)
 at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)
 at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)
 at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
 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.ClassNotFoundException: net.mytest.xye.model.Sighting from [Module "deployment.test.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.performLoadClassChecked(ConcurrentClassLoader.java:423) [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]
 ... 24 more

15:07:58,166 INFO  [org.jboss.as.server] (management-handler-thread - 13) JBAS015870: Deploy of deployment "test.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"test.war#primary\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"test.war#primary\": Failed to start service"}}
15:07:58,174 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-9) JBAS010409: Unbound data source [jboss/datasources/XYE-webapp5TestDS]
15:07:58,194 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-9) JBAS015877: Stopped deployment test.war in 28ms
15:07:58,194 INFO  [org.jboss.as.controller] (management-handler-thread - 13) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.persistenceunit."test.war#primary": org.jboss.msc.service.StartException in service jboss.persistenceunit."test.war#primary": Failed to start service

 

Solution:

Please add missed class 'Sighting.class' to TestArchive, such as

   @Deployment
   public static Archive<?> createTestArchive() {
      return ShrinkWrap.create(WebArchive.class, "test.war")
            .addClasses(Bird.class, Sighting.class, BirdRegistration.class, Resources.class)
            .addAsResource("META-INF/test-persistence.xml", "META-INF/persistence.xml")
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
            // Deploy our test datasource
            .addAsWebInfResource("test-ds.xml", "test-ds.xml");
   }


 

 

 

 

 

转载于:https://www.cnblogs.com/duadu/p/6335491.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
: org/springframework/boot/context/properties/ConfigurationPropertiesBean是什么原因导致的?如何解决这个问题? 回答: 引发这个错误的原因是缺少org.springframework.boot.context.properties.ConfigurationPropertiesBean类。\[1\]这个错误通常是由于Spring和Jackson版本不兼容引起的。\[2\]解决这个问题的方法是确保使用的Spring和Jackson版本是兼容的,可以尝试升级或降级其中一个框架的版本,以解决依赖冲突。另外,还可以检查项目的依赖配置,确保所有相关的依赖都正确添加并且版本匹配。 #### 引用[.reference_title] - *1* [Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/Configuration](https://blog.csdn.net/sxeric/article/details/121213870)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/exc/InvalidDefinitionExcep](https://blog.csdn.net/qq_41725214/article/details/95896490)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [Caused by: java.lang.NoClassDefFoundError: org/mybatis/logging/LoggerFactory](https://blog.csdn.net/qq_43371556/article/details/122035159)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值