Hi all,

I'm developing a Spring Boot application, and we use OrientDB in this. But 
every time I'm changing my code, Spring is reloading my app, which is 
great. However, OrientDB doesn't want to play along, and it's throwing 
NPE's at me.

Is there any way I can work around this?

This is my current stacktrace, using Spring Boot 1.3.3 and OrientDB 2.1.8:

Caused by: org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'asinService': Injection of autowired dependencies 
failed; nested exception is 
org.springframework.beans.factory.BeanCreationException: Could not autowire 
field: private com.bpb.book.AsinRepository 
com.bpb.amazon.AsinService.asinRepository; nested exception is 
org.springframework.beans.factory.UnsatisfiedDependencyException: Error 
creating bean with name 'asinRepository' defined in file 
[/Users/erikp/Userfiles/projects/bestprogrammingbooks/build/classes/main/com/bpb/book/AsinRepository.class]:
 
Unsatisfied dependency expressed through constructor argument with index 0 
of type [com.orientechnologies.orient.core.db.OPartitionedDatabasePool]: 
Error creating bean with name 'pool' defined in 
com.bpb.BestProgrammingBooksApplication: Bean instantiation via factory 
method failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[com.orientechnologies.orient.core.db.OPartitionedDatabasePool]: Factory 
method 'pool' threw exception; nested exception is 
java.lang.NullPointerException; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error creating 
bean with name 'pool' defined in com.bpb.BestProgrammingBooksApplication: 
Bean instantiation via factory method failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[com.orientechnologies.orient.core.db.OPartitionedDatabasePool]: Factory 
method 'pool' threw exception; nested exception is 
java.lang.NullPointerException
at 
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
... 24 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Could 
not autowire field: private com.bpb.book.AsinRepository 
com.bpb.amazon.AsinService.asinRepository; nested exception is 
org.springframework.beans.factory.UnsatisfiedDependencyException: Error 
creating bean with name 'asinRepository' defined in file 
[/Users/erikp/Userfiles/projects/bestprogrammingbooks/build/classes/main/com/bpb/book/AsinRepository.class]:
 
Unsatisfied dependency expressed through constructor argument with index 0 
of type [com.orientechnologies.orient.core.db.OPartitionedDatabasePool]: 
Error creating bean with name 'pool' defined in 
com.bpb.BestProgrammingBooksApplication: Bean instantiation via factory 
method failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[com.orientechnologies.orient.core.db.OPartitionedDatabasePool]: Factory 
method 'pool' threw exception; nested exception is 
java.lang.NullPointerException; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error creating 
bean with name 'pool' defined in com.bpb.BestProgrammingBooksApplication: 
Bean instantiation via factory method failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[com.orientechnologies.orient.core.db.OPartitionedDatabasePool]: Factory 
method 'pool' threw exception; nested exception is 
java.lang.NullPointerException
at 
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
... 35 common frames omitted
Caused by: 
org.springframework.beans.factory.UnsatisfiedDependencyException: Error 
creating bean with name 'asinRepository' defined in file 
[/Users/erikp/Userfiles/projects/bestprogrammingbooks/build/classes/main/com/bpb/book/AsinRepository.class]:
 
Unsatisfied dependency expressed through constructor argument with index 0 
of type [com.orientechnologies.orient.core.db.OPartitionedDatabasePool]: 
Error creating bean with name 'pool' defined in 
com.bpb.BestProgrammingBooksApplication: Bean instantiation via factory 
method failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[com.orientechnologies.orient.core.db.OPartitionedDatabasePool]: Factory 
method 'pool' threw exception; nested exception is 
java.lang.NullPointerException; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error creating 
bean with name 'pool' defined in com.bpb.BestProgrammingBooksApplication: 
Bean instantiation via factory method failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[com.orientechnologies.orient.core.db.OPartitionedDatabasePool]: Factory 
method 'pool' threw exception; nested exception is 
java.lang.NullPointerException
at 
org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:185)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1143)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1046)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
... 37 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'pool' defined in 
com.bpb.BestProgrammingBooksApplication: Bean instantiation via factory 
method failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[com.orientechnologies.orient.core.db.OPartitionedDatabasePool]: Factory 
method 'pool' threw exception; nested exception is 
java.lang.NullPointerException
at 
org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:813)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
... 50 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to 
instantiate 
[com.orientechnologies.orient.core.db.OPartitionedDatabasePool]: Factory 
method 'pool' threw exception; nested exception is 
java.lang.NullPointerException
at 
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 
org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
... 63 common frames omitted
Caused by: java.lang.NullPointerException: null
at 
com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.activateOnCurrentThread(ODatabaseDocumentTx.java:2908)
 
~[orientdb-core-2.1.10.jar:2.1.10]
at 
com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.<init>(ODatabaseDocumentTx.java:174)
 
~[orientdb-core-2.1.10.jar:2.1.10]
at 
com.orientechnologies.orient.core.db.OPartitionedDatabasePool$DatabaseDocumentTxPolled.<init>(OPartitionedDatabasePool.java:126)
 
~[orientdb-core-2.1.10.jar:2.1.10]
at 
com.orientechnologies.orient.core.db.OPartitionedDatabasePool$DatabaseDocumentTxPolled.<init>(OPartitionedDatabasePool.java:122)
 
~[orientdb-core-2.1.10.jar:2.1.10]
at 
com.orientechnologies.orient.core.db.OPartitionedDatabasePool.initQueue(OPartitionedDatabasePool.java:386)
 
~[orientdb-core-2.1.10.jar:2.1.10]
at 
com.orientechnologies.orient.core.db.OPartitionedDatabasePool.<init>(OPartitionedDatabasePool.java:186)
 
~[orientdb-core-2.1.10.jar:2.1.10]
at 
com.orientechnologies.orient.core.db.OPartitionedDatabasePool.<init>(OPartitionedDatabasePool.java:171)
 
~[orientdb-core-2.1.10.jar:2.1.10]
at 
com.bpb.BestProgrammingBooksApplication.pool(BestProgrammingBooksApplication.groovy:56)
 
[main/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0]
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
~[na:1.8.0]
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 
~[na:1.8.0]
at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0]
at 
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
 
~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
... 64 common frames omitted

The error is triggered from this line:

/**
 * Activates current database instance on current thread.
 */
@Override
public ODatabaseDocumentTx activateOnCurrentThread() {
  ODatabaseRecordThreadLocal.INSTANCE.set(this);
  return this;
}


Since the error is triggered from my main class at line 56, I tried 
initializing the ODatabaseRecordThreadLocal.INSTANCE myself, just like this:


@Bean
static OPartitionedDatabasePool pool() {
    ODatabaseRecordThreadLocal.INSTANCE = new ODatabaseRecordThreadLocal();

    return new OPartitionedDatabasePool("remote:localhost/TestDb", "test", 
"test")
}


But this results in a new error:


Caused by: com.orientechnologies.orient.core.exception.ODatabaseException: 
Error on opening database 'remote:localhost/BestProgrammingBooks'

        at 
com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.<init>(ODatabaseDocumentTx.java:204)
 ~[orientdb-core-2.1.10.jar:2.1.10]

        at 
com.orientechnologies.orient.core.db.OPartitionedDatabasePool$DatabaseDocumentTxPolled.<init>(OPartitionedDatabasePool.java:126)
 ~[orientdb-core-2.1.10.jar:2.1.10]

        at 
com.orientechnologies.orient.core.db.OPartitionedDatabasePool$DatabaseDocumentTxPolled.<init>(OPartitionedDatabasePool.java:122)
 ~[orientdb-core-2.1.10.jar:2.1.10]

        at 
com.orientechnologies.orient.core.db.OPartitionedDatabasePool.initQueue(OPartitionedDatabasePool.java:386)
 ~[orientdb-core-2.1.10.jar:2.1.10]

        at 
com.orientechnologies.orient.core.db.OPartitionedDatabasePool.<init>(OPartitionedDatabasePool.java:186)
 ~[orientdb-core-2.1.10.jar:2.1.10]

        at 
com.orientechnologies.orient.core.db.OPartitionedDatabasePool.<init>(OPartitionedDatabasePool.java:171)
 ~[orientdb-core-2.1.10.jar:2.1.10]

        at 
com.bpb.BestProgrammingBooksApplication.pool(BestProgrammingBooksApplication.groovy:59)
 [main/:na]

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
~[na:1.8.0]

        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
~[na:1.8.0]

        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 ~[na:1.8.0]

        at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0]

        at 
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
 ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]

        ... 64 common frames omitted

Caused by: com.orientechnologies.orient.core.exception.OConfigurationException: 
Error on opening database: the engine 'remote' was not found. URL was: 
remote:localhost/BestProgrammingBooks. Registered engines are: []

        at 
com.orientechnologies.orient.core.Orient.loadStorage(Orient.java:460) 
~[orientdb-core-2.1.10.jar:2.1.10]

        at 
com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.<init>(ODatabaseDocumentTx.java:187)
 ~[orientdb-core-2.1.10.jar:2.1.10]

        ... 75 common frames omitted


Any suggestions how to work around this?



Thanks, Erik

-- 

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

Reply via email to