Could not detect default resource locations for test class : class path resource does not exist

java, jenkins, maven, spring

Solution

The error is related to this part of the logs:

INFO : org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.xxxx.api.services.MessageServiceImplIntegrationTest]: class path resource [com/xxxx/api/services/MessageServiceImplIntegrationTest-context.xml] does not exist
INFO : org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.xxxx.api.services.MessageServiceImplIntegrationTest]: MessageServiceImplIntegrationTest does not declare any static, non-private, non-final, inner classes annotated with @Configuration.

Basically, your test class doesn't have a configuration part (either xml or `@Configuration`) that it can use to build the application context.

See this link for test configuration with xml and this one for configuration with `@Configuration` annotation.

Problem

I am having a little issue running maven build in jenkins. It's trying to run my integration test but, keep throwing this error: ``` java.lang.IllegalStateException: Neither GenericXmlContextLoader nor AnnotationConfigContextLoader was able to detect defaults, and no ApplicationContextInitializers were declared for context configuration [ContextConfigurationAttributes@2d10dd87 declaringClass = 'com.xxxx.api.services.MessageServiceImplIntegrationTest', locations = '{}', classes = '{}', inheritLocations = true, initializers = '{}', inheritInitializers = true, name = [null], contextLoaderClass = 'org.springframework.test.context.ContextLoader'] ``` See link for full stack trace link.

Original source