Spring Data Gremlin example with TitanDB

I am trying to use https://github.com/gjrwebber/spring-data-gremlin with TitanDB. TitanDBConfiguration.java:

@Slf4j @Data @Configuration @EnableTransactionManagement @EnableGremlinRepositories(basePackageClasses = , repositoryFactoryBeanClass = GremlinRepositoryFactoryBean.class) class TitanDBConfiguration < @Bean GremlinRepositorygremlinRepository(GremlinGraphFactory gremlinGraphFactory, GremlinGraphAdapter gremlinGraphAdapter, GremlinSchemaFactory gremlinSchemaFactory) < GremlinSchemagremlinSchema = gremlinSchemaFactory.getSchema(Person.class); return new TitanGremlinRepository<>(gremlinGraphFactory, gremlinGraphAdapter, gremlinSchema); > @Bean GremlinBeanPostProcessor gremlinBeanPostProcessor(SchemaGenerator schemaGenerator) < return new GremlinBeanPostProcessor(schemaGenerator, Application.class.getPackage().getName()); >@Bean GremlinTransactionManager transactionManager(TitanGremlinGraphFactory titanGremlinGraphFactory) < return new GremlinTransactionManager(titanGremlinGraphFactory); >@Bean TitanGremlinGraphFactory titanGremlinGraphFactory() < TitanGremlinGraphFactory titanGremlinGraphFactory = new TitanGremlinGraphFactory(); titanGremlinGraphFactory.setUrl("inmemory"); titanGremlinGraphFactory.setUsername("admin"); titanGremlinGraphFactory.setPassword("admin"); return titanGremlinGraphFactory; >@Bean GremlinSchema gremlinSchema(GremlinSchemaFactory gremlinSchemaFactory) < return gremlinSchemaFactory.getSchema(Person.class); >@Bean GremlinSchemaFactory gremlinSchemaFactory() < return new GremlinSchemaFactory(); >@Bean AnnotatedSchemaGenerator annotatedSchemaGenerator() < return new JpaSchemaGenerator(); >@Bean SchemaWriter schemaWriter() < return new TitanSchemaWriter(); >@Bean GremlinGraphAdapter gremlinGraphAdapter() < return new TitanGraphAdapter(); >@Bean GremlinRepositoryContext gremlinRepositoryContext ( GremlinGraphFactory gremlinGraphFactory, GremlinGraphAdapter gremlinGraphAdapter, GremlinSchemaFactory gremlinSchemaFactory, SchemaWriter schemaWriter ) < return new GremlinRepositoryContext ( gremlinGraphFactory, gremlinGraphAdapter, gremlinSchemaFactory, schemaWriter, TitanGremlinRepository.class ); >> 
PersonRepository.java: @Repository public interface PersonRepository extends GremlinRepository Person.java:
@Vertex public class Person
For test I am trying to do:
public static void main(String[] args)
And what I get is:
0 [main] INFO org.springframework.context.annotation.AnnotationConfigApplicationContext - Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@198e2867: startup date [Wed Aug 03 18:30:42 CEST 2016]; root of context hierarchy 644 [main] WARN org.springframework.context.annotation.ConfigurationClassEnhancer - @Bean method TitanDBConfiguration.gremlinBeanPostProcessor is non-static and returns an object assignable to Spring's BeanFactoryPostProcessor interface. This will result in a failure to process annotations such as @Autowired, @Resource and @PostConstruct within the method's declaring @Configuration class. Add the 'static' modifier to this method to avoid these container lifecycle issues; see @Bean javadoc for complete details. 806 [main] INFO org.reflections.Reflections - Reflections took 103 ms to scan 2 urls, producing 7 keys and 10 values 1579 [main] INFO com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration - Set default timestamp provider MICRO 1595 [main] INFO com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration - Generated unique-instance-id=7f00010131422-asd1 1620 [main] INFO com.thinkaurelius.titan.diskstorage.Backend - Initiated backend operations thread pool of size 8 1742 [main] INFO com.thinkaurelius.titan.diskstorage.log.kcvs.KCVSLog - Loaded unidentified ReadMarker start time 2016-08-03T16:30:44.726Z into com.thinkaurelius.titan.diskstorage.log.kcvs.KCVSLog$MessagePuller@5a18cd76 1873 [main] WARN org.springframework.context.annotation.AnnotationConfigApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gremlinRepositoryContext' defined in com.company.graphdatasource.configuration.TitanDBConfiguration: Unsatisfied dependency expressed through method 'gremlinRepositoryContext' parameter 2: Error creating bean with name 'gremlinSchemaFactory': Invocation of init method failed; nested exception is java.lang.NullPointerException; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gremlinSchemaFactory': Invocation of init method failed; nested exception is java.lang.NullPointerException Exception in thread "main" org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gremlinRepositoryContext' defined in com.company.graphdatasource.configuration.TitanDBConfiguration: Unsatisfied dependency expressed through method 'gremlinRepositoryContext' parameter 2: Error creating bean with name 'gremlinSchemaFactory': Invocation of init method failed; nested exception is java.lang.NullPointerException; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gremlinSchemaFactory': Invocation of init method failed; nested exception is java.lang.NullPointerException at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:776) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) at org.springframework.context.annotation.AnnotationConfigApplicationContext.(AnnotationConfigApplicationContext.java:84) at com.company.graphdatasource.Main.main(Main.java:11) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gremlinSchemaFactory': Invocation of init method failed; nested exception is java.lang.NullPointerException at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207) at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1214) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1054) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1019) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) . 19 more Caused by: java.lang.NullPointerException at org.springframework.data.gremlin.schema.GremlinSchemaFactory.init(GremlinSchemaFactory.java:27) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:365) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:310) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133) . 33 more 
As this is open source project, I have checked what is wrong:
@Component public class GremlinSchemaFactory < @Autowired private Setschemas; private Map> schemaMap = new HashMap>(); @PostConstruct public void init() < for (GremlinSchema schema : schemas) < String key = schema.getClassType().getSimpleName(); if (schemaMap.containsKey(key)) < key = schema.getClassName(); >schemaMap.put(key, schema); > > . > 

Line number 27 (where is NullPointer) is: String key = schema.getClassType().getSimpleName(); Nullpointer is being thrown, because schemas is LinkedHashSet that contains one element - null. This means, that my GremlinSchema has been not injected into Set schemas, but I do not know why. I have tested, that my

@Bean GremlinSchema gremlinSchema(GremlinSchemaFactory gremlinSchemaFactory) 

is being successfully created. So my @Bean is being created, but not injected, so I thought about packages and Spring contexts, so here are packages of above classes: com.company.Application has @Configuration and @ComponentScan com.company.graphdatasource.configuration.TitanDBConfiguration (annotations above) com.company.graphdatasource.model.entity.Person (annotations above) com.company.graphdatasource.gremlin.PersonRepository (annotation above) Above looks good for me.

springDataGremlin = '0.1.1-SNAPSHOT' enter code here compile "com.github.gjrwebber:spring-data-gremlin-titan:$" compile "com.github.gjrwebber:spring-data-gremlin-schemagen-jpa:$"