Upgrading from 1.2 to 2.x

310 views
Skip to first unread message

coderinabstract

unread,
Apr 3, 2013, 9:49:44 PM4/3/13
to axonfr...@googlegroups.com
Hi,

Trying to upgrade to latest and greatest and going through motions... from 1.2.1 and document journey.. to 2.0 and ... hopefully help others

first step upgrading from 1.2.1 to 1.3.3 getting error on Saga Repository

  <bean id="sagaRepository" class="org.axonframework.saga.repository.jpa.JpaSagaRepository">

        <property name="resourceInjector" ref="sagaInjector"/>

            

    </bean>

     

Spring config editor in eclipse showing following error. 

 No constructor with 0 arguments defined in class 'org.axonframework.saga.repository.jpa.JpaSagaRepository'

- No constructor with 0 arguments defined in class 

'org.axonframework.saga.repository.jpa.JpaSagaRepository'

Checked docs but nothing jumped at me to fix this. Any thoughts... Cheers


coderinabstract

unread,
Apr 3, 2013, 10:40:34 PM4/3/13
to axonfr...@googlegroups.com
First learning...

EntityManagerProvider needed as constructor, created simple based on one from util package

@Component

public class MyEntityManagerProvider implements EntityManagerProvider {   

@PersistenceContext

private EntityManager entityManager;

    @Override

    public EntityManager getEntityManager() {

        return entityManager;

    }

}

Constructor added as ref to the SagaRepository config

 <bean id="sagaRepository" class="org.axonframework.saga.repository.jpa.JpaSagaRepository">

    <constructor-arg><ref bean="myEntityManagerProvider"/></constructor-arg>

        <property name="resourceInjector" ref="sagaInjector"/>

            

    </bean>

Had a EventStoreModule for custom XStream converters needed to modify that creation to include EntityManagerProvider in JPAEventStore constructor

@Configuration

public class EventStoreModule {


public EventStoreModule(){

}

@Autowired

@Named("myEntityManagerProvider")

EntityManagerProvider entityManagerProvider;

@Bean(name="eventStore")

public JpaEventStore eventStore() {

XStreamEventSerializer eventSerializer = new XStreamEventSerializer();

XStream xStream = eventSerializer.getXStream();


xStream.registerConverter(new JodaMoneyConverter());

xStream.registerConverter(new NamedObjectConverter());

       

JpaEventStore eventStore = new JpaEventStore(entityManagerProvider, eventSerializer);

return eventStore;

}

}

This seems to have upgraded to 1.3.3 now on to 1.4..
Cheers

coderinabstract

unread,
Apr 3, 2013, 11:36:21 PM4/3/13
to axonfr...@googlegroups.com
Ok.. 1.4 upgrades to Quartz2.0, anybody has tips for upgrade.. we use Quartztable maker script with quartz 1.8.4... this was a hack we did long time ago.. as part of app build in same db to keep things simple and contained.. need to figure out how to upgrade this to 2.0..

and also seeing the following error

Initialization of bean failed; nested exception is org.axonframework.util.AxonConfigurationException: Unable to wrap annotated handler.

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)

at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:384)

at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)

at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)

at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:543)

at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)

Need to research

Cheers...

Any thoughts, tips... will continue digging.. Cheers..

coderinabstract

unread,
Apr 4, 2013, 12:42:07 AM4/4/13
to axonfr...@googlegroups.com
Need some help... looks like all commandhandlers and event handlers throwing this error, must be missing something significant... Upgraded app to Spring 3.1.1 and thought could be AOP related, but not working... Any thoughts, ideas.. cheers...Thanks..
Message has been deleted

coderinabstract

unread,
Apr 4, 2013, 12:59:32 AM4/4/13
to axonfr...@googlegroups.com

Deep nested error in stack trace with more relevance below..

java.lang.IllegalArgumentException: IntroductionAdviceSupport implements no interfaces

at org.springframework.aop.support.DefaultIntroductionAdvisor.<init>(DefaultIntroductionAdvisor.java:73)

at org.springframework.aop.framework.AdvisedSupport.addAdvice(AdvisedSupport.java:404)

at org.springframework.aop.framework.AdvisedSupport.addAdvice(AdvisedSupport.java:393)

at org.axonframework.util.AbstractAnnotationHandlerBeanPostProcessor.createJavaProxyInvoker(AbstractAnnotationHandlerBeanPostProcessor.java:100)

at org.axonframework.util.AbstractAnnotationHandlerBeanPostProcessor.postProcessAfterInitialization(AbstractAnnotationHandlerBeanPostProcessor.java:78)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1461)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)

at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)

at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)

at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)

bui...@gmail.com

unread,
Apr 4, 2013, 2:53:18 PM4/4/13
to axonfr...@googlegroups.com
Hi,

sorry for the late reply. I am currently abroad and have limited access to the (almost-ubiquitous) internet. 

The problem you're facing seems to be related to Spring's proxying mechanism. Do you have CGLib on the classpath? Spring resorts to JavaProxies if it cannot be found. In some cases, you also need to specify proxy-target-class="true" in the component-scan element (or some other elements that allow that to be set). 

That should solve the issue of the annotated handlers not being constructed properly. Which Spring version do you use?

Unfortunately, I do not know how to migrate a Quartz 1 to a version 2 store. For the more recent Axon 1 releases, there is a quartz backport that allows you to keep using Axon 1. I did not do the same for Axon 2.

Cheers,

Allard
--
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/groups/opt_out.
 
 

coderinabstract

unread,
Apr 5, 2013, 11:03:08 PM4/5/13
to axonfr...@googlegroups.com
Hi.. thanks for suggestion.. however still cannot get it to work.. the spring versions is 3.1.1.RELEASE and also have cglib 2.2 in classpath.

The irony is that this setup works perfectly with 1.3.3 and not with 1.4.  

Will continue to dig...can't get it to work .The project is completely mavenized and the only difference in pom is axon version. I did to the diffs between 1.3.3 and 1.4 and so see a difference in the proxy class post processing of Axon in code below. What is intriguing is that this code change is what seems to be where error coming. Also all other annotations are working fine e.g hibernate

at org.axonframework.util.AbstractAnnotationHandlerBeanPostProcessor.createJavaProxyInvoker(AbstractAnnotationHandlerBeanPostProcessor.java:100)

1.3.3 
-    @Override
-    public Object postProcessAfterInitialization(final Object bean, final String beanName) throws BeansException {
-        Class<?> targetClass = bean.getClass();
-        if (isPostProcessingCandidate(targetClass)) {
-            Subscribable adapter = initializeAdapterFor(bean);
-            managedAdapters.put(beanName, adapter);
-            return createAdapterProxy(targetClass, bean, adapter, getAdapterInterface());
-        }
-        return bean;
-    }



1.4
+    @Override
+    public Object postProcessAfterInitialization(final Object bean, final String beanName) throws BeansException {
+        Class<?> targetClass = bean.getClass();
+        if (isPostProcessingCandidate(targetClass)) {
+            Subscribable adapter = initializeAdapterFor(bean);
+            managedAdapters.put(beanName, adapter);
+            return createAdapterProxy(targetClass, bean, adapter, getAdapterInterface(), true);
+        } else if (isPostProcessingCandidate(AopProxyUtils.ultimateTargetClass(bean))) {
+            // Java Proxy, find target and inspect that instance
+            try {
+                Object targetBean = ((Advised) bean).getTargetSource().getTarget();
+                // we want to invoke the Java Proxy if possible, so we create a CGLib proxy that does that for us
+                Object proxyInvokingBean = createJavaProxyInvoker(bean, targetBean);
+
+                Subscribable adapter = initializeAdapterFor(proxyInvokingBean);
+                managedAdapters.put(beanName, adapter);
+                return createAdapterProxy(targetClass, proxyInvokingBean, adapter, getAdapterInterface(), false);
+            } catch (Exception e) {
+                throw new AxonConfigurationException("Unable to wrap annotated handler.", e);
+            }
+        }
+        return bean;
+    }

Any thoughts? ideas?

Cheers and Thanks...

coderinabstract

unread,
Apr 6, 2013, 2:26:54 AM4/6/13
to axonfr...@googlegroups.com

One error deeper below after traversing through the axon function is where this function of createJavaProxyInvoker is looking for an interface on POJO, which does not exist by design. Not sure whey its looking for interfaces.? This was introduced in 1.4.

Caused by: java.lang.IllegalArgumentException: IntroductionAdviceSupport implements no interfaces

at org.springframework.aop.support.DefaultIntroductionAdvisor.<init>(DefaultIntroductionAdvisor.java:73)

at org.springframework.aop.framework.AdvisedSupport.addAdvice(AdvisedSupport.java:404)

at org.springframework.aop.framework.AdvisedSupport.addAdvice(AdvisedSupport.java:393)

bui...@gmail.com

unread,
Apr 6, 2013, 4:31:09 AM4/6/13
to axonfr...@googlegroups.com
Hi,

this afternoon (western european time) I expect to have some time to dive into this. In the meantime, did you try adding the proxy-target-class attribute to a spring component-scan, context:annotation-driven or tx:annotation-driven element? I haven't seen this issue before, and there must be something simple to resolve it, or at least work around it. 

The problem seems to be related to Spring using the java proxying method, which only works on interfaces. I'll have a look at this as well.

To be continued...

Allard

coderinabstract

unread,
Apr 6, 2013, 1:20:22 PM4/6/13
to axonfr...@googlegroups.com
Thank you so much Allard... I think I may have a solution related to conflicting jars in maven dependency.. So don't spend any of your time till I get back.. Cheers and Thanks again..

Allard Buijze

unread,
Apr 6, 2013, 1:30:32 PM4/6/13
to Axon Framework Users
Hi,

that's actually good news, because I didn't mange to reproduce the problem yet. I didn't manage to create a configuration in which you get a Java Proxy in spring for a class that doesn't implement any interface.

Keep me updated in case you find the solution.

Cheers,

Allard

coderinabstract

unread,
Apr 6, 2013, 1:36:38 PM4/6/13
to axonfr...@googlegroups.com
OK.. I think this is the issue.. axon infrastructure config spring xml had these two settings from a long time

<bean

class="org.axonframework.eventhandling.annotation.AnnotationEventListenerBeanPostProcessor">

<property name="executor" ref="taskExecutor" />

</bean>


<bean

class="org.axonframework.commandhandling.annotation.AnnotationCommandHandlerBeanPostProcessor">

<property name="commandBus" ref="commandBus" />

</bean>

Commented these out and thats when error disappeared and become normal. These seemed to be kicking into JavaProxys  with the declaration even when they were not supposed to... Not sure why though?

Cheers and thanks again for all the help.. now need to do more testing and then prep for moving to 2.0... the big change

bui...@gmail.com

unread,
Apr 6, 2013, 3:33:48 PM4/6/13
to axonfr...@googlegroups.com, axonfr...@googlegroups.com
Does that mean you had the 'manual' post processors configured, as well as an axon:annotation-config element?
If not, doublecheck whether your event listeners and command handlers are working properly. 

Cheers,

Allard

coderinabstract

unread,
Apr 6, 2013, 7:27:28 PM4/6/13
to axonfr...@googlegroups.com
Yes both of these were in axon infrastructure config

<axon:annotation-config command-bus="commandBus"

executor="taskExecutor" />

<axon:event-bus id="eventBus" />

<bean

class="org.axonframework.eventhandling.annotation.AnnotationEventListenerBeanPostProcessor">

<property name="executor" ref="taskExecutor" />

</bean>

<bean

class="org.axonframework.commandhandling.annotation.AnnotationCommandHandlerBeanPostProcessor">

<property name="commandBus" ref="commandBus" />

</bean>

Still cannot understand why this would break it in 1.4? as it worked very well upto 1.3.3.

Cheers and Thanks...

bui...@gmail.com

unread,
Apr 7, 2013, 2:46:03 AM4/7/13
to axonfr...@googlegroups.com
Hi,

thanks for the info. I'll fix this issue in 2.x. I have created issue AXON-119 (http://issues.axonframework.org/youtrack/issue/AXON-119) for it. 

The reason is doesn't work in 1.4 anymore is that 1.4 deals with proxies, which could occur when you use libraries like Spring-Security to secure certain methods. To make sure that even Command and Event Handlers can be annotated with these security annotations, Axon needs to be able to work with proxied objects. 

The problem is dat the post processors proxy the beans themselves as well. So by adding two post processors, the second recognizes the proxy and will attempt to proxy it again, which fails. 

Cheers,

Allard

coderinabstract

unread,
Apr 7, 2013, 4:09:00 AM4/7/13
to axonfr...@googlegroups.com
Great Thanks... Ok.. now working on getting to Axon2.0... seeing AggregateIdentifier initialization issues in certain scenario.. one scneario is as follows

Aggregate initializes and fires several events in constructor.. has been working perfecty upto 1.4. Now the problem is event 1 goes to outside domain, event two is the one which is handled by aggregate and initializes its aggregateIdentifier, however from the external domain there is another incoming call to the aggregate. 

Before the auper(aggregateIdentifier) of AbstractAnnotatedAggregateRoot took care of this scenario. I will dig deeper and try to get more color. Please let me know if anything jumps out.

The situation again is
 - constructor has logic to analyze variables and fire thirparty domain events
- then fire initailization event which is handled by aggregate and where this.id = event.getAggrregateId is set

Now am getting 

 AggregateIdentifier is unknown in. Make sure the Aggregate Identifier is initialized before registering events.

at org.axonframework.domain.AbstractAggregateRoot.getEventContainer(AbstractAggregateRoot.java:163)

at org.axonframework.domain.AbstractAggregateRoot.registerEvent(AbstractAggregateRoot.java:72)

at org.axonframework.eventsourcing.AbstractEventSourcedAggregateRoot.apply(AbstractEventSourcedAggregateRoot.java:96)

at org.axonframework.eventsourcing.AbstractEventSourcedAggregateRoot.apply(AbstractEventSourcedAggregateRoot.java:75)

Before aggregate would get initialized with super..  Any thoughts.. I will dig deeper.. however wanted to see if anything pops out. 

coderinabstract

unread,
Apr 7, 2013, 4:24:27 AM4/7/13
to axonfr...@googlegroups.com
Ok some more color, now if i rearrage the events to have the first one which initializes the aggregate and if 2 or more events fire in constructor am getting this

java.lang.IllegalArgumentException: Unsuitable aggregate for this repository: wrong type

at org.axonframework.common.Assert.isTrue(Assert.java:52)

at org.axonframework.repository.AbstractRepository.add(AbstractRepository.java:62)

at org.axonframework.repository.LockingRepository.add(LockingRepository.java:80)

This constructor logic works perfectly working fine in 1.4... so a lot of logic is tied to this strategy and it working before.. Looks like stuck.. anything pops, ideas.. thoughts

Thanks and Cheers...

Allard Buijze

unread,
Apr 7, 2013, 4:35:22 AM4/7/13
to Axon Framework Users
Hi,

the first event of an aggregate must always set the identifier. Otherwise, Axon can't know what the ID of an aggregate is.

The problem you're encountering is probably a configuration bug in your application, which wasn't detected in 1.4. Since Axon 2, a repository checks whether the aggregate you pass into it is actually an instance of the type te repository stores. It seems that this is not the case here.
Make sure the right repository instance is injected into your command handler.

Cheers,

Allard

coderinabstract

unread,
Apr 7, 2013, 4:35:28 AM4/7/13
to axonfr...@googlegroups.com
My bad.. the rearranging seems to made things move forward.. the wrong type error was my mistake in refactoring the axon:event-sourcing-repository to wrong type.. so please dont worry about the wrong type error... Lot more to do.. Stay tuned..Thanks and Cheers..

coderinabstract

unread,
Apr 7, 2013, 2:17:32 PM4/7/13
to axonfr...@googlegroups.com
Ok.. now having core snapshotter errors.. looks like the snapshotter is not working when the time comes to snapshot... this is not giving too much info.. snapshotter config and repository which is throwing errors is as follows and the error stack is also below.. old config had standard spring beans, now moved to axon tags based configuration.

 <axon:snapshotter id="snapshotter"

           event-store="eventStore" 

           executor="taskExecutor" 

           transaction-manager="transactionManager"/>


<axon:event-sourcing-repository id="myAggregateRepository"

aggregate-type="com.fp.server.MyAggregate" event-bus="eventBus" 

event-store="eventStore" >

<axon:snapshotter-trigger snapshotter-ref="snapshotter"

event-count-threshold="5" />

</axon:event-sourcing-repository>

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">

<property name="entityManagerFactory" ref="entityManagerFactory" />

</bean>

<bean id="entityManagerFactory"

class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">

<property name="persistenceUnitName" value="tutorial" />

<property name="jpaVendorAdapter">

<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">

<property name="databasePlatform" value="${hibernate.sql.dialect}" />

<property name="generateDdl" value="${hibernate.sql.generateddl}" />

<property name="showSql" value="${hibernate.sql.show}" />

</bean>

</property>

<property name="dataSource" ref="dataSource" />

</bean>

<bean id="actualDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">

<property name="driverClass" value="${jdbc.driverclass}" />

<property name="jdbcUrl" value="${jdbc.url}" />

<property name="user" value="${jdbc.username}" />

<property name="password" value="${jdbc.password}" />

<property name="maxPoolSize" value="20" />

<property name="minPoolSize" value="10" />


</bean>


<bean id="dataSource"

class="org.springframework.jdbc.datasource.IsolationLevelDataSourceAdapter">

<property name="targetDataSource" ref="actualDataSource" />

<property name="isolationLevel" value="2" />

</bean>

in persistence.xml  <persistence-unit name="tutorial" transaction-type="RESOURCE_LOCAL">

        <provider>org.hibernate.ejb.HibernatePersistence</provider>.......

ERROR

2013-04-07 13:57:20,669 [taskExecutor-2] WARN  org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: null

2013-04-07 13:57:20,669 [taskExecutor-2] ERROR org.hibernate.util.JDBCExceptionReporter - failed batch

2013-04-07 13:57:20,669 [taskExecutor-2] WARN  org.axonframework.eventsourcing.AbstractSnapshotter - An attempt to create and store a snapshot resulted in an exception. Exception summary: {}

javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update

at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387)

at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1315)

at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:255)

at org.axonframework.eventstore.jpa.DefaultEventEntryStore.findRedundantSnapshots(DefaultEventEntryStore.java:126)

at org.axonframework.eventstore.jpa.DefaultEventEntryStore.pruneSnapshots(DefaultEventEntryStore.java:97)

at org.axonframework.eventstore.jpa.JpaEventStore.appendSnapshotEvent(JpaEventStore.java:254)

at org.axonframework.eventsourcing.AbstractSnapshotter$CreateSnapshotTask.run(AbstractSnapshotter.java:90)

at org.axonframework.eventsourcing.SpringAggregateSnapshotter$TransactionalRunnableWrapper.run(SpringAggregateSnapshotter.java:137)

at org.axonframework.eventsourcing.AbstractSnapshotter$SilentTask.run(AbstractSnapshotter.java:145)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)

at java.lang.Thread.run(Thread.java:680)

Caused by: org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update

at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)

at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)

at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)

at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)

at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:268)

at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184)

at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)

at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:64)

at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1185)

at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1261)

at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)

at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:246)

... 9 more

Caused by: java.sql.BatchUpdateException: failed batch

at org.hsqldb.jdbc.jdbcStatement.executeBatch(Unknown Source)

at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(Unknown Source)

at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)

at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)

at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)

... 17 more

coderinabstract

unread,
Apr 7, 2013, 2:27:49 PM4/7/13
to axonfr...@googlegroups.com
One more point... none of the events are serializabe..? except scheduled  events  which are stored in quartz job store... not sure if this has anything to do  with serialization as no appropriate error... and normal eventing into domainevententry seems to be ok. 

coderinabstract

unread,
Apr 7, 2013, 7:45:41 PM4/7/13
to axonfr...@googlegroups.com
Could not figure out.. more tracing with hibernate SQL below.. see that there is a null on payloadRevision, however dont think thats the error but more color...


Hibernate: insert into SnapshotEventEntry (eventIdentifier, metaData, payload, payloadRevision, payloadType, timeStamp, aggregateIdentifier, sequenceNumber, type) values (?, ?, ?, ?, ?, ?, ?, ?, ?)

2013-04-07 16:40:08,884 [taskExecutor-2] TRACE org.hibernate.type.descriptor.sql.BasicBinder - binding parameter [1] as [VARCHAR] - 20a08c46-f8c3-402b-a5a2-fd0fed345583

2013-04-07 16:40:08,884 [taskExecutor-2] TRACE org.hibernate.type.descriptor.sql.BasicBinder - binding parameter [2] as [BLOB] - [B@15cd7c6b

2013-04-07 16:40:08,884 [taskExecutor-2] TRACE org.hibernate.type.descriptor.sql.BasicBinder - binding parameter [3] as [BLOB] - [B@65a35ffb

2013-04-07 16:40:08,884 [taskExecutor-2] TRACE org.hibernate.type.descriptor.sql.BasicBinder - binding parameter [4] as [VARCHAR] - <null>

2013-04-07 16:40:08,884 [taskExecutor-2] TRACE org.hibernate.type.descriptor.sql.BasicBinder - binding parameter [5] as [VARCHAR] - com.vrntmgr.server.deal.Deal

2013-04-07 16:40:08,884 [taskExecutor-2] TRACE org.hibernate.type.descriptor.sql.BasicBinder - binding parameter [6] as [VARCHAR] - 2013-04-07T16:40:08.872-04:00

2013-04-07 16:40:08,884 [taskExecutor-2] TRACE org.hibernate.type.descriptor.sql.BasicBinder - binding parameter [7] as [VARCHAR] - AC9378D3-17DF-4D64-B3E8-D31D2A4F5C48

2013-04-07 16:40:08,884 [taskExecutor-2] TRACE org.hibernate.type.descriptor.sql.BasicBinder - binding parameter [8] as [BIGINT] - 52

2013-04-07 16:40:08,885 [taskExecutor-2] TRACE org.hibernate.type.descriptor.sql.BasicBinder - binding parameter [9] as [VARCHAR] - Deal

2013-04-07 16:40:08,887 [taskExecutor-2] WARN  org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: null

2013-04-07 16:40:08,887 [taskExecutor-2] ERROR org.hibernate.util.JDBCExceptionReporter - failed batch

2013-04-07 16:40:08,887 [taskExecutor-2] WARN  org.axonframework.eventsourcing.AbstractSnapshotter - An attempt to create and store a snapshot resulted in an exception. Exception summary: {}

coderinabstract

unread,
Apr 8, 2013, 4:22:36 AM4/8/13
to axonfr...@googlegroups.com
The errors above were from hsqldb.. the error below is from mySQL.. seems like duplicate entry insertion in snapshot arena... Thoughts... ideas.. Cheers.

2013-04-08 04:17:24,900 [taskExecutor-1] WARN  org.hibernate.util.JDBCExceptionReporter - SQL Error: 1062, SQLState: 23000
2013-04-08 04:17:24,900 [taskExecutor-1] ERROR org.hibernate.util.JDBCExceptionReporter - Duplicate entry '17B889B6-E292-4A04-B842-C9F7236F9294-8-Deal' for key 'PRIMARY'
2013-04-08 04:17:24,902 [taskExecutor-1] WARN  org.axonframework.eventsourcing.AbstractSnapshotter - An attempt to create and store a snapshot resulted in an exception:
javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1315)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:255)
at org.axonframework.eventstore.jpa.DefaultEventEntryStore.findRedundantSnapshots(DefaultEventEntryStore.java:126)
at org.axonframework.eventstore.jpa.DefaultEventEntryStore.pruneSnapshots(DefaultEventEntryStore.java:97)
at org.axonframework.eventstore.jpa.JpaEventStore.appendSnapshotEvent(JpaEventStore.java:254)
at org.axonframework.eventsourcing.AbstractSnapshotter$CreateSnapshotTask.run(AbstractSnapshotter.java:90)
at org.axonframework.eventsourcing.SpringAggregateSnapshotter$TransactionalRunnableWrapper.run(SpringAggregateSnapshotter.java:137)
at org.axonframework.eventsourcing.AbstractSnapshotter$SilentTask.run(AbstractSnapshotter.java:145)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:680)
Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:268)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:64)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1185)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1261)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:246)
... 9 more
Caused by: java.sql.BatchUpdateException: Duplicate entry '17B889B6-E292-4A04-B842-C9F7236F9294-8-Deal' for key 'PRIMARY'
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2007)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1443)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
... 17 more

Allard Buijze

unread,
Apr 8, 2013, 5:17:32 AM4/8/13
to Axon Framework Users
Looks like there is a duplicate snapshot. This is normally not a problem. It could mean that there are two processes creating a snapshot at the same time. In that case, it's a configuration issue. Otherwise, it's perfectly fine to ignore (silence) this exception.

Cheers,

Allard


coderinabstract

unread,
Apr 8, 2013, 11:42:34 AM4/8/13
to axonfr...@googlegroups.com
Unfortunately, this is happening with only one user using app with very frequent in log and seems like every time snapshotting is required this error happens. Not sure why this is happening even with single user as this did never happen before in 1.x environment.

Have gone back and redone the entire experience on the 1.4 branch of the app, and don't see any of these errors for same app use case scenarios  so now really need to strive to make this error go away and also not see it in cluttering production logs. Right now with single user this stack trace is clogging up the log also, so please help with any ideas to improve the situation by any configuration or code change options to pursue.

Thanks and cheers...

Allard Buijze

unread,
Apr 9, 2013, 1:57:39 AM4/9/13
to Axon Framework Users
Hi,

unfortunately, from here, I cannot see what's happening. Basically, the exception means that a same snapshot is created twice. This can have two reasons. You have either configured two snapshotters, which is not likely, but not impossible. Or your snapshotter is being triggered twice in a very short timeframe.

Do you snapshot asynchronously? Do you have any events from an aggregate that trigger a command on that same aggregate?

Meanwhile, I'll also have a look at the snapshotting code to see if there is a way to detect this scenario and skip snapshotting. In the end, there is no point creating a snapshot of an aggregate that has been loaded using exclusively another snapshot.

Cheers,

Allard

coderinabstract

unread,
Apr 9, 2013, 3:00:04 AM4/9/13
to axonfr...@googlegroups.com
Hi Allard, Thanls for the prompt response as always..

For your questions below.
1) Only one snapshotter with standard Axon config element  <axon:snapshotter id="snapshotter"

           event-store="eventStore" 

           executor="taskExecutor" 

           transaction-manager="transactionManager"/>

2) Yes there are events firing out of a starting aggregate.. getting to aggregate boundary sagas to fire commands on other aggregate, which fire events coming back to original aggregates sagas as response and then calling a command on the starting aggregate firing internal state change on the aggregate... This is all synchronous... in the middle one event is async however have disabled that async cluster and event handling and made it synchronous.. and can still get this error with same predictability all the time.

Let me know and i can send more detailed logs to you directly for Axon  and/or app output to see this error predictably happening as it can be reproduced whenever time to snapshot in this case 5 events snapshot trigger threshold.

Thanks and Cheers...

Allard Buijze

unread,
Apr 11, 2013, 2:38:03 AM4/11/13
to Axon Framework Users
Hi,

I'll try to reproduce this problem in a simple scenario, so that I can make it part of the build process. But I think to know where the problem comes from.

Since your snapshotter is asynchronous, but the process is synchronous and processes the same aggregate twice, it is not unlkely that the snapshotter is triggered twice. The second trigger will cause the exact same snapshot version to be created as the first one. The snapshotter doesn't detect this and simply stores the snapshot.

A workaround you could try is to use a synchronous snapshotter (removing the executor and transaction-manager is probably enough). I have created issue AXON-120 for this one (http://issues.axonframework.org/youtrack/issue/AXON-120).

Another remark I'd like to make is that a saga invoking a command on an aggregate based on an event of that same aggregate is a code smell. Are you sue the aggregate can't make the decision the launch that event in the first place? It's not always possible, but when it is, you don't want to go through a saga.

Cheers,

Allard

coderinabstract

unread,
Apr 12, 2013, 12:08:50 AM4/12/13
to axonfr...@googlegroups.com
Thanks for tracking this. Will try out sync option and report.

With respect to the remark on code smell.. let me elaborate on why we do that and get input if we can improving it further.

We have aggregate A which produces Event A.. Event A is intercepted by SagaA and calls command on Aggregate B. Aggregate B fires Event B which is intercepted by SagaA to complete/stop the saga as it was waiting for response of work being done on AggregateB. Now SagaA calls a command on Aggregate A to complete full round trip.

Hope this clarifies the context. One early on/legacy design point which we have emphasized is that the aggregate is not trapping events directly with EventHandler unless those are events which are only generated by itself. it is only trapping events it generates by firing of command operations on it. Obvious question that comes to mind is can aggregate event handler trap events from other aggregates without the firing of a command? 

Look forward to thoughts and input.

Cheers and Thanks...

Allard Buijze

unread,
Apr 12, 2013, 2:48:30 AM4/12/13
to Axon Framework Users
Hi,

your scenario sounds viable. From previous mails, I was under the impression that the Saga sent a command directly from an event from the same aggregate. But that doesn't seem to be the case.

Cheers,

Allard

coderinabstract

unread,
Apr 17, 2013, 9:13:58 PM4/17/13
to axonfr...@googlegroups.com
Removed the task executor and transaction manager and still saw these errors... on  a side note cache was not configured when seeing errors, however have configured cache based on the default axon-trader sample now and did not see this error yet which seems strange...

Is there any best practice guidance for axon-cache config for the aggregates.... and what not to do?

Thanks and Cheers...
On Wednesday, April 3, 2013 9:49:44 PM UTC-4, coderinabstract wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-lef
...

Allard Buijze

unread,
Apr 18, 2013, 3:17:48 AM4/18/13
to Axon Framework Users
Hi,

the issue should have been addressed in 2.0.2. I did notice, however, that the exception is only being logged when the logger is on debug level. If the logger is on another level, a one-liner is logged mentioning that it occurred, but without the stacktrace.
Do you have logging on the debug level?

Cheers,

Allard


--
Reply all
Reply to author
Forward
0 new messages