Failed to create Spring context E019

Hi. I just discovered and downloaded Diff Blue today and tried to have it create a test, but got an E019 error, with the following additional info from the log:

17:43:39.998 [INFO][analyzer-service:grpc-default-executor-1][c.d.c.a.a.f] Analysis of com.gm.gsmc.gpms.profile.manager.KafkaManager.kafkaUpdateProfileEvent:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/time/LocalDateTime;)V has thrown an exception:
Code: E019
Message: Failed to create Spring context
Details:
Hint: Please contact Diffblue support.
Affected: []
Cause: java.lang.IllegalStateException: Failed to load ApplicationContext

17:43:40.507 [INFO][analyzer-service:grpc-default-executor-0][c.d.cover.c.b] Encountered an internal error E009: Unrecoverable runtime error
17:43:40.507 [INFO][analyzer-service:grpc-default-executor-0][c.d.cover.c.b] Details: Exception: java.lang.AssertionError: Canā€™t handle interfaces in regular object handler

Iā€™m on Win10 Pro
Java 8.0_261
Itā€™s a Spring Boot (2.1.12.RELEASE) app

Thanks,
Seth

P.S. How do I send the cover-plugin.log file?

1 Like

Hi Seth,

Thank you for your message. I am sorry that you experienced this error.
We are looking into it and have now identified the source of the issue.

The log file would nevertheless be useful to us.
Would you be able to send it via the upload button in this forum?

If your project were accessible to us (e.g. open-source) it would allow us to double-check our fix against it.

Many thanks,
Joel Allred
Software Engineering Manager, Diffblue

Same issue here. Iā€™d like to upload my logs, but it says ā€œnew users cannot upload attachmentsā€

Hi Simon,
You should be able to upload files now
Regards
Andy

coverpluginlog.zip (6.8 KB)

Hey Joel. Thanks for the reply. Iā€™ve uploaded the log file but our project is not open source and I canā€™t share it, sorry.

Thanks,
Seth

Hi, similarly canā€™t share our project code, because itā€™s closed source, but hereā€™s the logs now
Archive.zip (37.7 KB)

Hi Seth,

Many thanks for the log files.
We have now created a fix for the E009 which we hope will resolve the E019.
It will be available in the upcoming plugin release 2021.06.01 which will be published to the IntelliJ MarketPlace early next week.

If you could try again with the new release, we could check that there is no other problem on your side.

Let me know if I can be of any help in the meantime.

Thanks

Joel

Hi @Simon_Democko,

Many thanks for sending your logs over.
The JetBrains JDK you are using does not seem to allow Mockito to attach an agent.

Are you able to try again with a different JDK (e.g. Oracle or OpenJDK)?

Can you perhaps also tell which version of Mockito and/or spring-boot-starter-test you are using?

Many thanks
Joel

Spring boot starter 2.4.5
I did not find Mockito in the pom.xml, but I ran mvn dependency:analyze and found
used undeclared dependencies with versions:
[WARNING] org.mockito:mockito-core:jar:3.6.28:test
[WARNING] org.mockito:mockito-junit-jupiter:jar:3.6.28:test

I quickly checked docs, but seems like beyond junit, Diffblue is not requiring anything else: Maven dependencies | Diffblue Docs but even so, it seems like Mockito is pulled in somehow anyway.

I switched to Java 11.0.11.hs-adpt thatā€™s AdoptOpenJDK and I got the same error.

Could it just be that what happens is the same issue as Sethā€™s?

I temporarily tried also now to add these dependencies (docs.diffblue .com)/knowledge-base/JCover/mocking/ and ran it again with AdoptOpenJDK and same error occurred. (thereā€™s powermock and mockito in that link) Hereā€™s the latest logs:
Archive.zip (67.9 KB)

sorry, had to break apart the second link, your forum does not allow me to post more than 2 links, cause Iā€™m a new userā€¦ :lol:

Hi Simon

Thank you!

Mockito is usually pulled in by spring-boot-starter-test cf. https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test/2.4.5

It is indeed possible to run our product without Mockito, but that would result in much lower coverage, especially on Spring projects.

I believe the source of the E019 is different than in Sethā€™s case. I had a look at your logs but it seems that DCover is still running with the JetBrains JDK:

Server command-line: /Applications/IntelliJ IDEA.app/Contents/jbr/Contents/Home/bin/java

Do you have the log file for the run with the AdoptOpenJDK version?
The JDK change might need a rebuild of the project to take effect.

Joel

Archive.zip (79.1 KB)
Hi, I checked again that Iā€™m using AdoptOpenJDK, rebuilt the project, restarted IDEa, check java --version again, ran diffblue, same error.

I took a quick look in the log (included in the archive) and this time, 18:06 I see AdoptOpenJDK being used, see

18:06:27.816 [INFO][analyzer-service:TimedExecutor-11][c.d.cover.c.b] > org.mockito.exceptions.base.MockitoInitializationException:
Could not initialize inline Byte Buddy mock maker.

It appears as if your JDK does not supply a working agent attachment mechanism.
Java : 11
JVM vendor name : AdoptOpenJDK
JVM vendor version : 11.0.8+10
JVM name : OpenJDK 64-Bit Server VM
JVM version : 11.0.8+10
JVM info : mixed mode
OS name : Mac OS X
OS version : 10.16

Simon,

It looks like the latest attached Archive.zip file does not correspond to your description. The timestamps are rather around 14:30 and the mentioned JDK is still the JetBrains one.

Can you perhaps double-check?

Thank you
Joel

Hi, I downloaded and checked and both executions are there. Just scroll to the bottom, the 18:06 executions are at the bottom. I did not delete the log files before doing the latter executions, so it appended it.

Hi @Simon_Democko

Indeed. Sorry I missed that the first time around.

In order to figure out where the error comes from, would it be possible for you to try generating some tests for Spring PetClinic (GitHub - spring-projects/spring-petclinic: A sample Spring-based application), say for the OwnerController class?

This could help us figure out whether the issue is related to your environment or to the specifics of your project.

Thanks
Joel

Hi @sethbott

The latest version of the plugin (2021.06.01) has now been published to the JetBrains Marketplace.
Are you able to update the plugin and check whether your issue has now been fixed?

Thank you
Joel

Hi,

For petclinic I ran it twice in a row. First time it didnā€™t generate anything. Second time it generated quite a bunch of tests. Not sure why first time it didnā€™t do it.

Logs attached.
Archive.zip (3.9 KB)

Hi,
I am trying to use diffblue to generate test cases but getting ā€œApplicationContextā€ error. I have attached the error logs here. It is generating test for simpler methods but complex methods with dao calls to database is failing.
Any help would be appreciated.

15:58:53 Writing tests for: WaitListServiceImpl.getHttpRequestHeaders

15:59:36 Failed to create Spring context: Attempt to initialize test context failed with ā€˜Failed to load ApplicationContextā€™ at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132) at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:123) when running class:

package com.wdpr.dvc.memavail.service.impl;

@org.springframework.test.context.ContextConfiguration(classes = {com.wdpr.dvc.memavail.service.impl.WaitListServiceImpl.class})

@org.junit.runner.RunWith(value = org.springframework.test.context.junit4.SpringRunner.class) // if JUnit 4

@org.junit.jupiter.api.extension.ExtendWith(value = org.springframework.test.context.junit.jupiter.SpringExtension.class) // if JUnit 5

public class DiffblueFakeClass0 {

@org.springframework.boot.test.mock.mockito.MockBean J long;

@org.springframework.boot.test.mock.mockito.MockBean(name = ā€œimmediateBlockServiceā€) com.wdpr.dvc.memavail.blockInventory.BlockService blockService;

@org.springframework.boot.test.mock.mockito.MockBean com.wdpr.dvc.memavail.clients.msgsv.DrmctApiImpl drmctApiImpl;

@org.springframework.boot.test.mock.mockito.MockBean com.wdpr.dvc.memavail.clients.msgsv.FreeSellAPIImpl freeSellAPIImpl;

@org.springframework.boot.test.mock.mockito.MockBean javax.servlet.http.HttpServletRequest httpServletRequest;

@org.springframework.boot.test.mock.mockito.MockBean com.wdpr.dvc.memavail.service.MemApiService memApiService;

@org.springframework.boot.test.mock.mockito.MockBean com.wdpr.dvc.memavail.service.OffersAvailabilityService offersAvailabilityService;

@org.springframework.boot.test.mock.mockito.MockBean com.wdpr.dvc.memavail.clients.msgsv.PointsPricingImpl pointsPricingImpl;

@org.springframework.boot.test.mock.mockito.MockBean com.wdpr.dvc.memavail.service.RetrieveRoomListPackageService retrieveRoomListPackageService;

@org.springframework.boot.test.mock.mockito.MockBean com.wdpr.dvc.memavail.util.TravelBoxUtil travelBoxUtil;

@org.springframework.boot.test.mock.mockito.MockBean com.wdpr.dvc.memavail.dao.WaitListEntriesDAO waitListEntriesDAO;

@org.springframework.beans.factory.annotation.Autowired com.wdpr.dvc.memavail.service.impl.WaitListServiceImpl waitListServiceImpl;

@org.junit.Test // if JUnit 4

@org.junit.jupiter.api.Test // if JUnit 5

public void testSpringContextLoads() {}

}
emphasized text

Hi @Himanshu, thank you for getting in touch, I am sorry that you have hit this problem - we will look into this immediately

In the meantime please could you confirm your environment please:

  • Diffblue Cover Version
  • Are you using CLI or IntelliJ Plugin?
  • Windows/Linux/Mac
  • Maven/Gradle

Thank you once again,

Matt
Diffblue

Hi,
Thanks for the reply
My environment is
-Diffblue Cover Version ā†’ 2021.10.01-community.2021.2
-Are you using CLI or IntelliJ Plugin? ā†’ IntelliJ Plugin
-Windows/Linux/Mac - Windows
-Maven/Gradle - Maven

Thanks @Himanshu,

The log you posted contains a Spring class which Diffblue Cover is using to create the Spring context, it is failing to load for some unknown reason.

Could you please paste this code into your project and run the testSpringContextLoads() test method, this will give us more information on what exactly the problem is?

Thanks for your time

Matt
Diffblue