Support for DB2 as database for DomainEventEntry and SnapshotEventEntry

150 views
Skip to first unread message

Stein Welberg

unread,
Sep 26, 2014, 7:30:46 AM9/26/14
to axonfr...@googlegroups.com
Hi Allard,

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.

Thnx!

Met vriendelijke groet / Kind regards,


Stein Welberg | CTO 





M: +31639110574st...@onegini.com | Pompmolenlaan 9, 3447 GK, Woerden | www.onegini.com

Visit www.onegini.me to create your own Onegini digital identity today!

signature.asc

Allard Buijze

unread,
Sep 26, 2014, 8:47:02 AM9/26/14
to Axon Framework Users
Hi Stein,

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: 
1. disable the inspection. Simply remove the data-source property from the jpa-event-store, and you're done.
2. customize the persistence exception resolver. Remove the data-source property, and replace it with persitence-exception-resolver, lke so:
    <axon:jpa-event-store persistence-exception-resolver="persistenceExceptionResolver"/>
    <bean id="persistenceExceptionResolver" class="org.axonframework.eventstore.jpa.SQLErrorCodesResolver">
        <constructor-arg value="DB2"/>
    </bean>
Since you're using DB2, which is a known DB type, you can simply provide the database name as a constructor to the SQLErrorCodesResolver.

Hope this helps.
Cheers,

Allard

Stein Welberg

unread,
Sep 26, 2014, 9:12:21 AM9/26/14
to axonfr...@googlegroups.com
Hi Allard,

Thnx for the quick response once again! :-)

Met vriendelijke groet / Kind regards,

Stein Welberg | CTO 





M: +31639110574st...@onegini.com | Pompmolenlaan 9, 3447 GK, Woerden | www.onegini.com

Visit www.onegini.me to create your own Onegini digital identity today!

On 26 sep. 2014, at 14:47, Allard Buijze <bui...@gmail.com> wrote:

Hi Stein,

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: 
1. disable the inspection. Simply remove the data-source property from the jpa-event-store, and you're done.
2. customize the persistence exception resolver. Remove the data-source property, and replace it with persitence-exception-resolver, lke so:
    <axon:jpa-event-store persistence-exception-resolver="persistenceExceptionResolver"/>
    <bean id="persistenceExceptionResolver" class="org.axonframework.eventstore.jpa.SQLErrorCodesResolver">
        <constructor-arg value="DB2"/>
    </bean>
Since you're using DB2, which is a known DB type, you can simply provide the database name as a constructor to the SQLErrorCodesResolver.

Hope this helps.
Cheers,

Allard
On Fri, Sep 26, 2014 at 1:30 PM, Stein Welberg <st...@onegini.com> wrote:
Hi Allard,

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.

Thnx!
Met vriendelijke groet / Kind regards,


Stein Welberg | CTO 


<Onegini logo small signature[18].png>



M: +31639110574st...@onegini.com | Pompmolenlaan 9, 3447 GK, Woerden | www.onegini.com

Visit www.onegini.me to create your own Onegini digital identity today!



--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

signature.asc

Herr Manns

unread,
Mar 24, 2017, 6:06:36 AM3/24/17
to Axon Framework Users

Hi Allard,

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);
}

cu,
Dirk

Allard Buijze

unread,
Apr 6, 2017, 5:22:40 AM4/6/17
to Axon Framework Users
Hi Dirk,

I have improved the SQL Error Codes mechanism to support patterns for database names. This should resolve the DB2 related issues.

Cheers,

Allard

--
Reply all
Reply to author
Forward
0 new messages