0

I have a spring boot application which leverages spring data neo4j. I am using the following dependencies in my project.

  1. neo4j 2.2.5
  2. neo4j ogm 1.1.2
  3. spring data neo4j 4.0.0.RELASE
  4. spock-spring 1.0-groovy-2.3.

When i try to run a sample spock test in my project, i get the following stacktrace ...

Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'getSessionFactory' threw exception; 
nested exception is java.lang.ClassFormatError: Invalid annotation element type tag: 0x0
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123) ~[spring-beans-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018) ~[spring-beans-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) ~[spring-beans-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) ~[spring-beans-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) ~[spring-beans-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:766) ~[spring-beans-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:812) ~[spring-context-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:521) ~[spring-context-4.2.0.RC1.jar:4.2.0.RC1]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:678) [spring-boot-1.3.0.M1.jar:1.3.0.M1]
    at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:339) [spring-boot-1.3.0.M1.jar:1.3.0.M1]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:274) [spring-boot-1.3.0.M1.jar:1.3.0.M1]
    at org.springframework.boot.test.SpringApplicationContextLoader.loadContext(SpringApplicationContextLoader.java:102) [spring-boot-1.3.0.M1.jar:1.3.0.M1]

The spock specification looks like this

@ContextConfiguration(loader = SpringApplicationContextLoader.class,classes = TestConfig.class)
class VisitorDomainTestSpec extends Specification {

    @Autowired VisitorRepository visitorRepository

    @Autowired Session session





    def "visitors should be created"()
    {

        given: "A visitor which is saved "
        Visitor visitor = getVisitor()
        visitorRepository.save(visitor)

        when: "We try to retrieve the visitor by name"
        Visitor foundVisitor = findVisitorByProperty("name", visitor.getName()).iterator().next();

        then: "We should be able to retrieve the visitor"
        assertEquals( foundVisitor.id ,visitor.id)
    }

My junit tests pass ok but i am stuck when i am trying to use spock here. Any pointers will be helpful...In my testConfig class, i am wiring an InProcessServer..

Luanne
  • 19,145
  • 1
  • 39
  • 51
arun menon
  • 1
  • 1
  • 2
  • How is your Visitor node class annotated? Are you doing anything with Jackson at all? I saw something similar when using JsonSubTypes with nodes - http://stackoverflow.com/questions/31541727/sdn4-neo4j-ogm-jackson-2-0 – simonl Sep 10 '15 at 14:18
  • I commented out the jackson annotations but was still getting the error for both spock and junit tests. Only when i remove the spock depedency from my pom.xml does my junit test also starts working ... – arun menon Sep 10 '15 at 15:22

0 Answers0