I'm getting error java.lang.NoClassDefFoundError
when running some tests only some times.
Here's the set up: Tests are written in Scala with services in Scala and Java. Using ant and ivy as well.
Order.scala looks something like this:
object Order extends JdbcEnabled {
val orderServiceClientIpAddress = Network.localIpAddress
val PersonalOffersSaleId = "123"
lazy val checkoutClient = new CheckoutClientImpl(YamlConfigFactory.loadConfig(
this.getClass.getClassLoader.getResourceAsStream("core_config.yaml")
).getRequiredSubConfig("core").getRequiredSubConfig(Environment.HostEnv))
val storeList = new JLinkedList[Store]()
storeList.add(OrderHelper.getSelectedStore)
var skuList = OrderHelper.getAvailableSkus
val skusForInternationalOrders = skuList
def createOrder(){...}}
There are many tests running with TestNG. Sometimes all the tests pass without any problem, but sometimes they fail with this exception.
Here's a snippet of how a test calls Order api when it fails.
val orderNumber = Order.createOrder()
This is the entire stack trace when the test fails:
java.lang.NoClassDefFoundError: Could not initialize class com.api.Order$
at com.CreateOrder.setUpOnce(CreateOrder.scala:35)
Line 35 in that class, CreateOrder.scala is:
val orderNumber = Order.createOrder()