Exception using JpaEventStorageEngine or JdbcEventStorageEngine

419 views
Skip to first unread message

Mellow Hide

unread,
Aug 5, 2016, 5:28:10 AM8/5/16
to Axon Framework Users
Hi guys,

I'm trying to use a persistent store for event sourcing in my distributed system. I guess JpaEventStorageEngine or JdbcEventStorageEngine would be fine.

But I get some exception (see below). Here is my spring application configuration:

  @PersistenceContext
private EntityManager entityManager;


@Bean
public CommandBus commandBus() {
return new SimpleCommandBus();
}

@Bean
public CommandGateway commandGateway() {
return new DefaultCommandGateway(commandBus());
}

@Bean
public EventBus eventBus() {
return new SimpleEventBus();
}


@Bean
public EventSourcingRepository eventSourcingRepository() {

EntityManagerProvider entityManagerProvider = new SimpleEntityManagerProvider(entityManager);
EventStorageEngine eventStorageEngine = new JpaEventStorageEngine(entityManagerProvider, NoTransactionManager.INSTANCE);
EventStore eventStore = new EmbeddedEventStore(eventStorageEngine);
EventSourcingRepository repository = new EventSourcingRepository(Delivery.class, eventStore);
return repository;
}



Any help is highly appreciated.

Thx



Exception:


org
.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eventSourcingRepository' defined in class path resource [com/test/icd/vehicleservice/ApplicationConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.axonframework.eventsourcing.EventSourcingRepository]: Factory method 'eventSourcingRepository' threw exception; nested exception is java.lang.NoSuchMethodError: com.thoughtworks.xstream.XStream.addImmutableType(Ljava/lang/Class;Z)V
 at org
.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
 at org
.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
 at org
.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
 at org
.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
 at org
.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
 at org
.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
 at org
.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
 at org
.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
 at org
.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
 at org
.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:776) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
 at org
.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
 at org
.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
 at org
.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
 at org
.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
 at org
.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
 at org
.springframework.boot.SpringApplication.run(SpringApplication.java:313) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
 at org
.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
 at org
.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
 at com
.test.icd.vehicleservice.DeliveryServiceApplication.main(DeliveryServiceApplication.java:10) [main/:na]
 at sun
.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_25]
 at sun
.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_25]
 at sun
.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_25]
 at java
.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_25]
 at com
.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.axonframework.eventsourcing.EventSourcingRepository]: Factory method 'eventSourcingRepository' threw exception; nested exception is java.lang.NoSuchMethodError: com.thoughtworks.xstream.XStream.addImmutableType(Ljava/lang/Class;Z)V
 at org
.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
 at org
.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
 
... 23 common frames omitted
Caused by: java.lang.NoSuchMethodError: com.thoughtworks.xstream.XStream.addImmutableType(Ljava/lang/Class;Z)V
 at org
.axonframework.serialization.AbstractXStreamSerializer.<init>(AbstractXStreamSerializer.java:129) ~[axon-core-3.0-M3.jar:3.0-M3]
 at org
.axonframework.serialization.AbstractXStreamSerializer.<init>(AbstractXStreamSerializer.java:103) ~[axon-core-3.0-M3.jar:3.0-M3]
 at org
.axonframework.serialization.AbstractXStreamSerializer.<init>(AbstractXStreamSerializer.java:78) ~[axon-core-3.0-M3.jar:3.0-M3]
 at org
.axonframework.serialization.AbstractXStreamSerializer.<init>(AbstractXStreamSerializer.java:67) ~[axon-core-3.0-M3.jar:3.0-M3]
 at org
.axonframework.serialization.xml.XStreamSerializer.<init>(XStreamSerializer.java:49) ~[axon-core-3.0-M3.jar:3.0-M3]
 at org
.axonframework.eventsourcing.eventstore.AbstractEventStorageEngine.<init>(AbstractEventStorageEngine.java:37) ~[axon-core-3.0-M3.jar:3.0-M3]
 at org
.axonframework.eventsourcing.eventstore.BatchingEventStorageEngine.<init>(BatchingEventStorageEngine.java:40) ~[axon-core-3.0-M3.jar:3.0-M3]
 at org
.axonframework.eventsourcing.eventstore.jpa.JpaEventStorageEngine.<init>(JpaEventStorageEngine.java:37) ~[axon-core-3.0-M3.jar:3.0-M3]
 at com
.test.icd.vehicleservice.ApplicationConfiguration.eventSourcingRepository(ApplicationConfiguration.java:55) ~[main/:na]
 at com
.test.icd.vehicleservice.ApplicationConfiguration$$EnhancerBySpringCGLIB$$4042e104.CGLIB$eventSourcingRepository$3(<generated>) ~[main/:na]
 at com
.test.icd.vehicleservice.ApplicationConfiguration$$EnhancerBySpringCGLIB$$4042e104$$FastClassBySpringCGLIB$$adac035f.invoke(<generated>) ~[main/:na]
 at org
.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
 at org
.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
 at com
.test.icd.vehicleservice.ApplicationConfiguration$$EnhancerBySpringCGLIB$$4042e104.eventSourcingRepository(<generated>) ~[main/:na]
 at sun
.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_25]
 at sun
.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_25]
 at sun
.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_25]
 at java
.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_25]
 at org
.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
 
... 24 common frames omitted

Allard Buijze

unread,
Aug 5, 2016, 9:27:33 AM8/5/16
to Axon Framework Users
Hi,

You most likely have a old version of XStream on the classpath. Axon is built against version 1.4.9.

Cheers,

Allard

Mellow Hide

unread,
Aug 5, 2016, 10:18:59 AM8/5/16
to Axon Framework Users
Thanks - that helped me out.

Is the @AnnotationDriven already working properly?

I get still get "org.axonframework.commandhandling.NoHandlerForCommandException: No handler was subscribed to command", even when i use the annotation at my configuration class. My handler is defined in the aggregate root. 

Cheers.

Allard Buijze

unread,
Aug 8, 2016, 3:28:50 AM8/8/16
to Axon Framework Users
Hi,

it depends on what "properly" means ;-)
If you mean that it will auto-configure all the necessary components for each aggregate defined in the application context, then it doesn't.

For now, you need to create an AggregateAnnotationCommandHandler instance (pass the aggregate type and reference to repository in the constructor) and then handler.subscribe(commandBus).

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/d/optout.

Mellow Hide

unread,
Aug 9, 2016, 6:08:20 PM8/9/16
to Axon Framework Users
Thank you Allard. We switched back to 2.x - which works fine so far within our spring boot & cloud app. V3 was somehow confusing - I will try out the final as soon as you release it.

Keep on your great work.
 
  Cheers
Reply all
Reply to author
Forward
0 new messages