java.lang.IllegalArgumentException: DataSource must not be null


Samebug tips1

If you're unit testing, you should instantiate only the service and mock the dependencies. If you're testing integration, you should add all the mocking to the configurations file.


5 months ago
Expert tip

Solutions on the web387

Solution icon of stackoverflow
via Stack Overflow by Unknown author, 1 year ago
DataSource must not be null

Solution icon of web
DataSource must not be null

Solution icon of web
DataSource must not be null

Solution icon of web
DataSource must not be null

Solution icon of stackoverflow
DataSource must not be null

Solution icon of web
DataSource must not be null

Solution icon of stackoverflow
DataSource must not be null.

Solution icon of web
via blogspot.com by Unknown author, 1 year ago
DataSource must not be null.

Solution icon of github
via GitHub by trisberg
, 1 year ago
EvaluationContext must not be null

Solution icon of github
PersistentEntity must not be null!

Stack trace

java.lang.IllegalArgumentException: DataSource must not be null
	at org.springframework.util.Assert.notNull(Assert.java:112)
	at org.springframework.jdbc.datasource.lookup.SingleDataSourceLookup.<init>(SingleDataSourceLookup.java:40)
	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.setDataSource(LocalContainerEntityManagerFactoryBean.java:238)
	at com.myc.cc.repository.PersistenceJPAConfig.entityManagerFactory(PersistenceJPAConfig.java:43)
	at com.myc.cc.repository.PersistenceJPAConfig.entityManager(PersistenceJPAConfig.java:37)
	at com.myc.cc.repository.SearchPersonPredicates.findIdByEM(SearchPersonPredicates.java:121)
	at com.myc.cc.service.impl.SearchPersonServiceImpl.findPnumberbyEM(SearchPersonServiceImpl.java:70)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:201)
	at com.sun.proxy.$Proxy114.findPnumberbyEM(Unknown Source)
	at com.myc.cc.web.SearchPersonController.searchPerson(SearchPersonController.java:109)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)

Write tip

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

Users with the same issue

2 times, 2 months ago
2 times, 4 months ago
2 times, 5 months ago
Samebug visitor profile picture
Unknown user
Once, 6 months ago
Samebug visitor profile picture
Unknown user
Once, 9 months ago
195 more bugmates