Spring Boot @SpringBootTest gives NoClassDefFoundError: …DataAccessException
I'm unable to solve this. I have a spring boot application.
Main class annotated with
@SpringBootApplication.
Test class annotated with:
@RunWith(SpringRunner.class)
@SpringBootTest
Everything is fine until i add a filter-configurer class in the application:
@Configuration
public class YadaYadaFilterConfigurer
{
@Bean
public FilterRegistrationBean<YadaYadaFilter> createYadaYadaFilter()
{...}
...
}
Boom!
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.FilterRegistrationBean]:
...
nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:...org.springframework.boot/spring-boot-test-autoconfigure/2.0.6.RELEASE/b0eb15474e795850dfa59b01ee6a83d7a39e3645/spring-boot-test-autoconfigure-2.0.6.RELEASE.jar!/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.class]; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/DataAccessException
My dependencies:
dependencies {
implementation('org.springframework.boot:spring-boot-starter-web')
testImplementation('org.springframework.boot:spring-boot-starter-test')
}
Some clearification.
Stripped so that I have only this test-class:
@RunWith(SpringRunner.class)
@SpringBootTest
public class JsonvalidationApplicationTests {
@Test
public void contextLoads() {
}
}
If comment out the @SpringBootTest then everything works. Seems like this annotation introduces a need for more dependencies?
Some more stacktrace:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.FilterRegistrationBean]: Factory method 'createyadayadaFilter' threw exception; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/C:/Users/66122872/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-test-autoconfigure/2.0.6.RELEASE/b0eb15474e795850dfa59b01ee6a83d7a39e3645/spring-boot-test-autoconfigure-2.0.6.RELEASE.jar!/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.class]; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/DataAccessException
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:583)
... 67 more
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/C:/Users/66122872/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-test-autoconfigure/2.0.6.RELEASE/b0eb15474e795850dfa59b01ee6a83d7a39e3645/spring-boot-test-autoconfigure-2.0.6.RELEASE.jar!/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.class]; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/DataAccessException
java spring spring-boot
add a comment |
I'm unable to solve this. I have a spring boot application.
Main class annotated with
@SpringBootApplication.
Test class annotated with:
@RunWith(SpringRunner.class)
@SpringBootTest
Everything is fine until i add a filter-configurer class in the application:
@Configuration
public class YadaYadaFilterConfigurer
{
@Bean
public FilterRegistrationBean<YadaYadaFilter> createYadaYadaFilter()
{...}
...
}
Boom!
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.FilterRegistrationBean]:
...
nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:...org.springframework.boot/spring-boot-test-autoconfigure/2.0.6.RELEASE/b0eb15474e795850dfa59b01ee6a83d7a39e3645/spring-boot-test-autoconfigure-2.0.6.RELEASE.jar!/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.class]; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/DataAccessException
My dependencies:
dependencies {
implementation('org.springframework.boot:spring-boot-starter-web')
testImplementation('org.springframework.boot:spring-boot-starter-test')
}
Some clearification.
Stripped so that I have only this test-class:
@RunWith(SpringRunner.class)
@SpringBootTest
public class JsonvalidationApplicationTests {
@Test
public void contextLoads() {
}
}
If comment out the @SpringBootTest then everything works. Seems like this annotation introduces a need for more dependencies?
Some more stacktrace:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.FilterRegistrationBean]: Factory method 'createyadayadaFilter' threw exception; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/C:/Users/66122872/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-test-autoconfigure/2.0.6.RELEASE/b0eb15474e795850dfa59b01ee6a83d7a39e3645/spring-boot-test-autoconfigure-2.0.6.RELEASE.jar!/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.class]; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/DataAccessException
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:583)
... 67 more
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/C:/Users/66122872/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-test-autoconfigure/2.0.6.RELEASE/b0eb15474e795850dfa59b01ee6a83d7a39e3645/spring-boot-test-autoconfigure-2.0.6.RELEASE.jar!/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.class]; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/DataAccessException
java spring spring-boot
You should also include spring-boot-starter-parent dependency.
– GauravRai1512
Nov 13 '18 at 15:55
1
If those are your only dependencies you are missing stuff, judging from the Exception at least. Apparently you are using data Access somewhere or accidentily import an@JdbcTestannotation in your test class. But I suspect that you only added a snippet of the stacktrace and that the original stacktrace is langer.
– M. Deinum
Nov 13 '18 at 16:45
@GauravRai1512 Adding spring-boot-starter-parent, still yields the same problem.
– user1578293
Nov 14 '18 at 7:17
@M.Deinum If I uncomment "@SpringBootTest" everything works. I stripped everything so I only have one emty test class that does nothing. I have no Data access in the application. Seemls like "@SpringBootTest" is including the data access dependencies. I will update my post a bit.
– user1578293
Nov 14 '18 at 7:21
Could be the auto config for testing that has a hard dependency on it. You might want to create a small test case and create an issue in the spring Boot issue tracker.
– M. Deinum
Nov 14 '18 at 12:52
add a comment |
I'm unable to solve this. I have a spring boot application.
Main class annotated with
@SpringBootApplication.
Test class annotated with:
@RunWith(SpringRunner.class)
@SpringBootTest
Everything is fine until i add a filter-configurer class in the application:
@Configuration
public class YadaYadaFilterConfigurer
{
@Bean
public FilterRegistrationBean<YadaYadaFilter> createYadaYadaFilter()
{...}
...
}
Boom!
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.FilterRegistrationBean]:
...
nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:...org.springframework.boot/spring-boot-test-autoconfigure/2.0.6.RELEASE/b0eb15474e795850dfa59b01ee6a83d7a39e3645/spring-boot-test-autoconfigure-2.0.6.RELEASE.jar!/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.class]; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/DataAccessException
My dependencies:
dependencies {
implementation('org.springframework.boot:spring-boot-starter-web')
testImplementation('org.springframework.boot:spring-boot-starter-test')
}
Some clearification.
Stripped so that I have only this test-class:
@RunWith(SpringRunner.class)
@SpringBootTest
public class JsonvalidationApplicationTests {
@Test
public void contextLoads() {
}
}
If comment out the @SpringBootTest then everything works. Seems like this annotation introduces a need for more dependencies?
Some more stacktrace:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.FilterRegistrationBean]: Factory method 'createyadayadaFilter' threw exception; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/C:/Users/66122872/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-test-autoconfigure/2.0.6.RELEASE/b0eb15474e795850dfa59b01ee6a83d7a39e3645/spring-boot-test-autoconfigure-2.0.6.RELEASE.jar!/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.class]; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/DataAccessException
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:583)
... 67 more
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/C:/Users/66122872/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-test-autoconfigure/2.0.6.RELEASE/b0eb15474e795850dfa59b01ee6a83d7a39e3645/spring-boot-test-autoconfigure-2.0.6.RELEASE.jar!/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.class]; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/DataAccessException
java spring spring-boot
I'm unable to solve this. I have a spring boot application.
Main class annotated with
@SpringBootApplication.
Test class annotated with:
@RunWith(SpringRunner.class)
@SpringBootTest
Everything is fine until i add a filter-configurer class in the application:
@Configuration
public class YadaYadaFilterConfigurer
{
@Bean
public FilterRegistrationBean<YadaYadaFilter> createYadaYadaFilter()
{...}
...
}
Boom!
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.FilterRegistrationBean]:
...
nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:...org.springframework.boot/spring-boot-test-autoconfigure/2.0.6.RELEASE/b0eb15474e795850dfa59b01ee6a83d7a39e3645/spring-boot-test-autoconfigure-2.0.6.RELEASE.jar!/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.class]; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/DataAccessException
My dependencies:
dependencies {
implementation('org.springframework.boot:spring-boot-starter-web')
testImplementation('org.springframework.boot:spring-boot-starter-test')
}
Some clearification.
Stripped so that I have only this test-class:
@RunWith(SpringRunner.class)
@SpringBootTest
public class JsonvalidationApplicationTests {
@Test
public void contextLoads() {
}
}
If comment out the @SpringBootTest then everything works. Seems like this annotation introduces a need for more dependencies?
Some more stacktrace:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.FilterRegistrationBean]: Factory method 'createyadayadaFilter' threw exception; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/C:/Users/66122872/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-test-autoconfigure/2.0.6.RELEASE/b0eb15474e795850dfa59b01ee6a83d7a39e3645/spring-boot-test-autoconfigure-2.0.6.RELEASE.jar!/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.class]; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/DataAccessException
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:583)
... 67 more
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/C:/Users/66122872/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-test-autoconfigure/2.0.6.RELEASE/b0eb15474e795850dfa59b01ee6a83d7a39e3645/spring-boot-test-autoconfigure-2.0.6.RELEASE.jar!/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.class]; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/DataAccessException
java spring spring-boot
java spring spring-boot
edited Nov 14 '18 at 7:30
user1578293
asked Nov 13 '18 at 15:52
user1578293user1578293
504
504
You should also include spring-boot-starter-parent dependency.
– GauravRai1512
Nov 13 '18 at 15:55
1
If those are your only dependencies you are missing stuff, judging from the Exception at least. Apparently you are using data Access somewhere or accidentily import an@JdbcTestannotation in your test class. But I suspect that you only added a snippet of the stacktrace and that the original stacktrace is langer.
– M. Deinum
Nov 13 '18 at 16:45
@GauravRai1512 Adding spring-boot-starter-parent, still yields the same problem.
– user1578293
Nov 14 '18 at 7:17
@M.Deinum If I uncomment "@SpringBootTest" everything works. I stripped everything so I only have one emty test class that does nothing. I have no Data access in the application. Seemls like "@SpringBootTest" is including the data access dependencies. I will update my post a bit.
– user1578293
Nov 14 '18 at 7:21
Could be the auto config for testing that has a hard dependency on it. You might want to create a small test case and create an issue in the spring Boot issue tracker.
– M. Deinum
Nov 14 '18 at 12:52
add a comment |
You should also include spring-boot-starter-parent dependency.
– GauravRai1512
Nov 13 '18 at 15:55
1
If those are your only dependencies you are missing stuff, judging from the Exception at least. Apparently you are using data Access somewhere or accidentily import an@JdbcTestannotation in your test class. But I suspect that you only added a snippet of the stacktrace and that the original stacktrace is langer.
– M. Deinum
Nov 13 '18 at 16:45
@GauravRai1512 Adding spring-boot-starter-parent, still yields the same problem.
– user1578293
Nov 14 '18 at 7:17
@M.Deinum If I uncomment "@SpringBootTest" everything works. I stripped everything so I only have one emty test class that does nothing. I have no Data access in the application. Seemls like "@SpringBootTest" is including the data access dependencies. I will update my post a bit.
– user1578293
Nov 14 '18 at 7:21
Could be the auto config for testing that has a hard dependency on it. You might want to create a small test case and create an issue in the spring Boot issue tracker.
– M. Deinum
Nov 14 '18 at 12:52
You should also include spring-boot-starter-parent dependency.
– GauravRai1512
Nov 13 '18 at 15:55
You should also include spring-boot-starter-parent dependency.
– GauravRai1512
Nov 13 '18 at 15:55
1
1
If those are your only dependencies you are missing stuff, judging from the Exception at least. Apparently you are using data Access somewhere or accidentily import an
@JdbcTest annotation in your test class. But I suspect that you only added a snippet of the stacktrace and that the original stacktrace is langer.– M. Deinum
Nov 13 '18 at 16:45
If those are your only dependencies you are missing stuff, judging from the Exception at least. Apparently you are using data Access somewhere or accidentily import an
@JdbcTest annotation in your test class. But I suspect that you only added a snippet of the stacktrace and that the original stacktrace is langer.– M. Deinum
Nov 13 '18 at 16:45
@GauravRai1512 Adding spring-boot-starter-parent, still yields the same problem.
– user1578293
Nov 14 '18 at 7:17
@GauravRai1512 Adding spring-boot-starter-parent, still yields the same problem.
– user1578293
Nov 14 '18 at 7:17
@M.Deinum If I uncomment "@SpringBootTest" everything works. I stripped everything so I only have one emty test class that does nothing. I have no Data access in the application. Seemls like "@SpringBootTest" is including the data access dependencies. I will update my post a bit.
– user1578293
Nov 14 '18 at 7:21
@M.Deinum If I uncomment "@SpringBootTest" everything works. I stripped everything so I only have one emty test class that does nothing. I have no Data access in the application. Seemls like "@SpringBootTest" is including the data access dependencies. I will update my post a bit.
– user1578293
Nov 14 '18 at 7:21
Could be the auto config for testing that has a hard dependency on it. You might want to create a small test case and create an issue in the spring Boot issue tracker.
– M. Deinum
Nov 14 '18 at 12:52
Could be the auto config for testing that has a hard dependency on it. You might want to create a small test case and create an issue in the spring Boot issue tracker.
– M. Deinum
Nov 14 '18 at 12:52
add a comment |
1 Answer
1
active
oldest
votes
Sorry, after some more investigation i found that the problem is in my FilterRegistrationBean.
the exeption is thrown here.
ClassPathScanningCandidateComponentProvider provider = createComponentScanner();
provider.findCandidateComponents("").stream()...
I will answer this thread and create a new.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53284737%2fspring-boot-springboottest-gives-noclassdeffounderror-dataaccessexception%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sorry, after some more investigation i found that the problem is in my FilterRegistrationBean.
the exeption is thrown here.
ClassPathScanningCandidateComponentProvider provider = createComponentScanner();
provider.findCandidateComponents("").stream()...
I will answer this thread and create a new.
add a comment |
Sorry, after some more investigation i found that the problem is in my FilterRegistrationBean.
the exeption is thrown here.
ClassPathScanningCandidateComponentProvider provider = createComponentScanner();
provider.findCandidateComponents("").stream()...
I will answer this thread and create a new.
add a comment |
Sorry, after some more investigation i found that the problem is in my FilterRegistrationBean.
the exeption is thrown here.
ClassPathScanningCandidateComponentProvider provider = createComponentScanner();
provider.findCandidateComponents("").stream()...
I will answer this thread and create a new.
Sorry, after some more investigation i found that the problem is in my FilterRegistrationBean.
the exeption is thrown here.
ClassPathScanningCandidateComponentProvider provider = createComponentScanner();
provider.findCandidateComponents("").stream()...
I will answer this thread and create a new.
answered Nov 14 '18 at 15:27
user1578293user1578293
504
504
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53284737%2fspring-boot-springboottest-gives-noclassdeffounderror-dataaccessexception%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You should also include spring-boot-starter-parent dependency.
– GauravRai1512
Nov 13 '18 at 15:55
1
If those are your only dependencies you are missing stuff, judging from the Exception at least. Apparently you are using data Access somewhere or accidentily import an
@JdbcTestannotation in your test class. But I suspect that you only added a snippet of the stacktrace and that the original stacktrace is langer.– M. Deinum
Nov 13 '18 at 16:45
@GauravRai1512 Adding spring-boot-starter-parent, still yields the same problem.
– user1578293
Nov 14 '18 at 7:17
@M.Deinum If I uncomment "@SpringBootTest" everything works. I stripped everything so I only have one emty test class that does nothing. I have no Data access in the application. Seemls like "@SpringBootTest" is including the data access dependencies. I will update my post a bit.
– user1578293
Nov 14 '18 at 7:21
Could be the auto config for testing that has a hard dependency on it. You might want to create a small test case and create an issue in the spring Boot issue tracker.
– M. Deinum
Nov 14 '18 at 12:52