java.lang.IllegalStateException: Cannot instantiate datasource instance of de.focus_shift.jaxb.JaxbConfigurationService #224
-
Dear Jollyday development team, when running the following test in JUnit 5 import de.focus_shift.Holiday;
import de.focus_shift.HolidayManager;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import java.util.Set;
@ExtendWith(MockitoExtension.class)
public class JollydayTests
{
@Test
void printHollydaysForOneYearGermany()
{
final HolidayManager holidayManager = HolidayManager.getInstance();
}
} I run into the following error: java.lang.IllegalStateException: Cannot instantiate datasource instance of de.focus_shift.jaxb.JaxbConfigurationService. What is the reason for this error and how can this error be fixed? In my pom.xml I have imported jollyday-core (0.14.0) and jollyday-jaxb (0.14.0): <dependency>
<groupId>de.focus-shift</groupId>
<artifactId>jollyday-core</artifactId>
<version>0.14.0</version>
</dependency>
<dependency>
<groupId>de.focus-shift</groupId>
<artifactId>jollyday-jaxb</artifactId>
<version>0.14.0</version>
</dependency> My Java version is 19.0.2 and my Maven version is 3.9.0 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Can you provide a sample project? I hope I will find some time next week. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, it might be challenging to provide a sample project since I have no right to share it. However, it seems that the error occurs in the following method: private ConfigurationService instantiateDataSource(String dataSourceClassName) {
try {
Class<?> dataSourceClass = this.classLoadingUtil.loadClass(dataSourceClassName);
return (ConfigurationService)dataSourceClass.getDeclaredConstructor().newInstance();
} catch (Exception var3) {
throw new IllegalStateException("Cannot instantiate datasource instance of " + dataSourceClassName, var3);
}
} and it happens since |
Beta Was this translation helpful? Give feedback.
-
I'm getting the same Exception. But I can also provide the cause of it. The root cause is - according to the stacktrace - a |
Beta Was this translation helpful? Give feedback.
I'm getting the same Exception. But I can also provide the cause of it. The root cause is - according to the stacktrace - a
java.lang.ClassNotFoundException: jakarta.xml.bind.JAXBException
This on the other hand is due to a conflict in the jaxb-runtime version present in the (my) project. I have the "old" jaxb-runtime with the
javax.xml.bind
namespace; it comes from Spring 2. But jollyday requires the "new" jaxb-runtime with thejakarta.xml.bind
namespace; which is only present in Spring 3.Yes there are other cases when the jaxb-runtime version does not match, but the above circumstance is just one example. So check your dependencies if it has the wrong runtime. (Check which dependency p…