EJB testing with TomEE embedded EJBContainer api: java.lang.ClassFormatError exception

前端 未结 2 825
旧时难觅i
旧时难觅i 2021-01-06 02:35

I would test my EJB with TomEE embedded EJBContainer.

This is my JUnit test case skeleton:

package com.xxx.indexer.scheduler.service;

import java.ut         


        
相关标签:
2条回答
  • 2021-01-06 02:56

    I read at this link, https://stackoverflow.com/a/3416368/1412839, that the problem is the order of maven dependencies.

    I have to declare first the tomee embedded artifact, and after the javaee api, in this way:

    <dependency>
      <groupId>org.apache.openejb</groupId>
      <artifactId>tomee-embedded</artifactId>
      <version>1.0.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-api</artifactId>
      <version>6.0</version>
      <scope>provided</scope>
    </dependency>
    

    It works.

    0 讨论(0)
  • 2021-01-06 03:11

    you can replace javax:javaee-api (broken jar) by org.apache.openejb:javaee-api:6.0-4 too and it always works ;)

    0 讨论(0)
提交回复
热议问题