Is it possible to use DB2 as database for the Axon tables?
Currently I’m getting the following exception:
org.springframework.beans.MethodInvocationException: Property ‘dataSource’ threw exception; nested exception is org.axonframework.common.AxonConfigurationException:The database product name ‘DB2/LINUXX8664’ is unknown. No SQLCode configuration is known for that database.
this exception is cause by the fact that Axon doesn’t recognize the String “DB2/LINUXX8664” as a known database. It uses the database name to detect which exceptions indicate an optimistic locking error.
There are two ways around this:
disable the inspection. Simply remove the data-source property from the jpa-event-store, and you’re done.
customize the persistence exception resolver. Remove the data-source property, and replace it with persitence-exception-resolver, lke so:
sorry for bringing this up again - but wouldn’t it be nice to support DB2 on Linux out of the box?
This is the version you are running when using the ibm docker image - so it should be quite usual.
For others as a quick workaround: Here is my Java-Config using Axon3 and DB2-LUW on Docker:
@Bean
public Serializer serializer() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
return new JacksonSerializer(objectMapper);
}
// An own resolver is needed because Axon doesn't recognize DB2 on linux correctly
@Bean
public SQLErrorCodesResolver sqlErrorCodesResolver() {
return new SQLErrorCodesResolver("DB2");
}
@Bean
public EventStorageEngine eventStorageEngine(DataSource dataSource) throws SQLException {
EntityManagerProvider entityManagerProvider = new SimpleEntityManagerProvider(entityManager);
return new JpaEventStorageEngine(
serializer(), NoOpEventUpcaster.INSTANCE, sqlErrorCodesResolver(),
null, entityManagerProvider, NoTransactionManager.INSTANCE,
null, null, true);
}