Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Corrupt bean cache? Autowiring fails.
Corrupt bean cache? Autowiring fails. [message #722349] Mon, 05 September 2011 13:24 Go to next message
Jean-Pierre Bergamin is currently offline Jean-Pierre Bergamin
Messages: 51
Registered: March 2011
Location: Zürich, CH
Member
Hello Virgo users

We are facing a very, very strange issue at the moment, so let me try to explain...

We have an @Repository annotated bean that has a @Autowired annotated setter:
@Repository
public class DependencyModelRepository extends
        AbstractBaseRepository<IDependencyModel, DependencyModel, DependencyModel> implements
        IDependencyModelRepository {

    public DependencyModelRepository() {
        super(DependencyModel.class);
    }

    @Autowired
    public void setDependencyModelGraphRepository(IDependencyModelGraphRepository dependencyGraphRepository) {
        setGraphRepository(dependencyGraphRepository);
    }
}


The base class AbstractBaseRepository has an @Autowired property "private GraphDatabaseContext db".

On some installations, this autowiring fails. The log shows the following:
[2011-09-05 14:39:16.915] DEBUG region-dm-7                  o.s.beans.factory.support.DefaultListableBeanFactory              Creating shared instance of singleton bean 'org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#8'
[2011-09-05 14:39:16.915] DEBUG region-dm-7                  o.s.beans.factory.support.DefaultListableBeanFactory              Creating instance of bean 'org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#8'
[2011-09-05 14:39:16.915] DEBUG region-dm-7                  o.s.beans.factory.support.DefaultListableBeanFactory              Eagerly caching bean 'org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#8' to allow for resolving potential circular references
[2011-09-05 14:39:16.916] DEBUG region-dm-7                  o.s.beans.factory.support.DefaultListableBeanFactory              Invoking afterPropertiesSet() on bean with name 'org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#8'
[2011-09-05 14:39:16.917] DEBUG region-dm-7                  o.s.beans.factory.support.DefaultListableBeanFactory              Creating shared instance of singleton bean 'dependencyModelRepository'
[2011-09-05 14:39:16.917] DEBUG region-dm-7                  o.s.beans.factory.support.DefaultListableBeanFactory              Creating instance of bean 'dependencyModelRepository'
[2011-09-05 14:39:16.921] DEBUG region-dm-7                  org.springframework.beans.factory.annotation.InjectionMetadata    Found injected element on class [net.junisphere.eranger.domain.internal.neo4j.repositories.DependencyModelRepository]: AutowiredFieldElement for private org.springframework.data.neo4j.support.GraphDatabaseContext net.junisphere.eranger.domain.internal.neo4j.repositories.AbstractBaseRepository.db
[2011-09-05 14:39:16.922] DEBUG region-dm-7                  org.springframework.beans.factory.annotation.InjectionMetadata    Found injected element on class [net.junisphere.eranger.domain.internal.neo4j.repositories.DependencyModelRepository]: AutowiredMethodElement for public void net.junisphere.eranger.domain.internal.neo4j.repositories.DependencyModelRepository.setDependencyModelGraphRepository(net.junisphere.eranger.domain.internal.neo4j.repositories.IDependencyModelGraphRepository)
[2011-09-05 14:39:16.922] DEBUG region-dm-7                  o.s.beans.factory.support.DefaultListableBeanFactory              Eagerly caching bean 'dependencyModelRepository' to allow for resolving potential circular references
[2011-09-05 14:39:16.922] DEBUG region-dm-7                  org.springframework.beans.factory.annotation.InjectionMetadata    Processing injected method of bean 'dependencyModelRepository': AutowiredFieldElement for private org.springframework.data.neo4j.support.GraphDatabaseContext net.junisphere.eranger.domain.internal.neo4j.repositories.AbstractBaseRepository.db
[2011-09-05 14:39:16.922] DEBUG region-dm-7                  o.s.beans.factory.support.DefaultListableBeanFactory              Returning eagerly cached instance of singleton bean 'org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#8' that is not fully initialized yet - a consequence of a circular reference
[2011-09-05 14:39:16.925] DEBUG region-dm-7                  o.s.beans.factory.support.DefaultListableBeanFactory              Returning cached instance of singleton bean 'graphDatabaseContext'
[2011-09-05 14:39:16.925] DEBUG region-dm-7                  o.s.b.factory.annotation.AutowiredAnnotationBeanPostProcessor     Autowiring by type from bean name 'dependencyModelRepository' to bean named 'graphDatabaseContext'
[2011-09-05 14:39:16.925] DEBUG region-dm-7                  org.springframework.beans.factory.annotation.InjectionMetadata    Processing injected method of bean 'dependencyModelRepository': AutowiredMethodElement for public void net.junisphere.eranger.domain.internal.neo4j.repositories.DependencyModelRepository.setDependencyModelGraphRepository(net.junisphere.eranger.domain.internal.neo4j.repositories.IDependencyModelGraphRepository)
[2011-09-05 14:39:16.928] INFO  region-dm-7                  o.s.beans.factory.support.DefaultListableBeanFactory              Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@4c0147e3: defining beans [org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#0,org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#1,org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#2,org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#3,org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#4,org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#5,org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#6,org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#7,org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#8,org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#9,org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#10,org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#11,org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#12,org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#13,dataSource,org.h2.Driver#0,org.springframework.jdbc.datasource.init.DataSourceInitializer#0,h2TcpInMemoryServer,h2TcpInMemoryWebServer,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,collectorDao,measurementDao,deviceDao,genericCollectorDao,genericModelDao,genericServerDao,genericDeviceDao,genericMeasurementDao,genericUserDao,versionDao,serverDao,modelDao,userDao,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,loadTimeWeaver,entityManagerFactory,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#0,org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0,userRepository,collectorRepository,jpaDeviceRepository,measurementRepository,versionRepository,modelRepository,serverRepository,domainConversionService,userDetailsService,org.springframework.context.config.internalBeanConfigurerAspect,org.springframework.data.neo4j.config.Neo4jConfiguration#0,org.springframework.context.annotation.ConfigurationClassPostProcessor#0,nodeDelegatingFieldAccessorFactory,relationshipDelegatingFieldAccessorFactory,graphDatabaseService,iFlowModelGraphRepository,iDeviceGraphRepository,iServiceGraphRepository,iDependencyModelGraphRepository,org.springframework.data.repository.core.support.RepositoryInterfaceAwareBeanPostProcessor#0,serviceRepository,dependencyModelRepository,deviceRepository,flowModelRepository,org.springframework.transaction.config.internalTransactionAspect,jpaTransactionManager,jtaTransactionManager,transactionManager,graphDatabaseContext,conversionService,graphRelationshipInstantiator,graphEntityInstantiator,directGraphRepositoryFactory,neo4jRelationshipBacking,relationshipEntityStateFactory,neo4jNodeBacking,nodeEntityStateFactory,configurationCheck,persistenceExceptionTranslator]; root of factory hierarchy


What makes me suspicious are the two lines:
[2011-09-05 14:39:16.922] DEBUG region-dm-7                  org.springframework.beans.factory.annotation.InjectionMetadata    Processing injected method of bean 'dependencyModelRepository': AutowiredFieldElement for private org.springframework.data.neo4j.support.GraphDatabaseContext net.junisphere.eranger.domain.internal.neo4j.repositories.AbstractBaseRepository.db
[2011-09-05 14:39:16.922] DEBUG region-dm-7                  o.s.beans.factory.support.DefaultListableBeanFactory              Returning eagerly cached instance of singleton bean 'org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#8' that is not fully initialized yet - a consequence of a circular reference


An "eagerly cached instance of singleton bean 'org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#8'" is returned, where a graphDatabaseContext instance is expected and this is wrong!

The log file on a system where the autowiring works as expected look like this:
[2011-09-05 13:58:57.869] DEBUG region-dm-7                  org.springframework.beans.factory.annotation.InjectionMetadata    Processing injected method of bean 'dependencyModelRepository': AutowiredFieldElement for pri
vate org.springframework.data.neo4j.support.GraphDatabaseContext net.junisphere.eranger.domain.internal.neo4j.repositories.AbstractBaseRepository.db
[2011-09-05 13:58:57.871] DEBUG region-dm-7                  o.s.beans.factory.support.DefaultListableBeanFactory              Returning cached instance of singleton bean 'graphDatabaseContext'
[2011-09-05 13:58:57.871] DEBUG region-dm-7                  o.s.b.factory.annotation.AutowiredAnnotationBeanPostProcessor     Autowiring by type from bean name 'dependencyModelRepository' to bean named 'graphDatabaseCon
text'
[2011-09-05 13:58:57.871] DEBUG region-dm-7                  org.springframework.beans.factory.annotation.InjectionMetadata    Processing injected method of bean 'dependencyModelRepository': AutowiredMethodElement for pu
blic void net.junisphere.eranger.domain.internal.neo4j.repositories.DependencyModelRepository.setDependencyModelGraphRepository(net.junisphere.eranger.domain.internal.neo4j.repositories.IDependencyModelGraphRepository)
[2011-09-05 13:58:57.872] DEBUG region-dm-7                  o.s.beans.factory.support.DefaultListableBeanFactory              Returning cached instance of singleton bean 'iDependencyModelGraphRepository'


Here the correct graphDatabaseContext is returned: "Returning cached instance of singleton bean 'graphDatabaseContext'".
On those systems this graphDatabaseContext bean has already been instantiated, whereas on non working systems, this bean does not exist yet.

As I mentioned: the very strange thing is, that this issue only happens on some installations. On one machine, everything worked fine until a new disk has been installed and the virgo installation and repository files have been copied over to this new disk.

I have absolutely no clue, where this error originates. Is it spring itself? Is it Spring DM? Maybe Virgo/equinox?
Any ideas how to track down this error?

As a workaround, we can avoid the autowiring of the IDependencyModelGraphRepository in the setter, but since we have quite a number of repositories, we'd like not to have them be declared in XML.

BTW: We use Virgo 3.0.0.RELEASE.


Best regards,
James
Re: Corrupt bean cache? Autowiring fails. [message #722695 is a reply to message #722349] Tue, 06 September 2011 14:26 Go to previous messageGo to next message
Dmitry Sklyut is currently offline Dmitry Sklyut
Messages: 272
Registered: January 2010
Senior Member
Hello James,

Would you mind sharing your xml configs also? Are you deploying as a plan, par, pickup? Is the order of artifact deployments identical between systems that work and those that don't?

There might be timing issues with SpringDM with a particular configuration set-ups.
I think I ran into something similar where inner beans were used with osgi-service config. Can't remember exact issue right now.

Regards,
Dmitry
Re: Corrupt bean cache? Autowiring fails. [message #722805 is a reply to message #722695] Tue, 06 September 2011 18:37 Go to previous message
Jean-Pierre Bergamin is currently offline Jean-Pierre Bergamin
Messages: 51
Registered: March 2011
Location: Zürich, CH
Member
Dmitry Sklyut wrote on Tue, 06 September 2011 10:26
Would you mind sharing your xml configs also?

Most of the configuration is done by component scanning and autowiring, so the XML config is very "basic":

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:datagraph="http://www.springframework.org/schema/data/graph" xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/data/graph http://www.springframework.org/schema/data/graph/datagraph-1.0.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

	<context:spring-configured />
	<context:annotation-config />

	<bean class="org.springframework.data.neo4j.config.Neo4jConfiguration" />
	<bean class="org.springframework.context.annotation.ConfigurationClassPostProcessor" />

	<bean id="graphDatabaseService" class="org.neo4j.kernel.EmbeddedGraphDatabase" destroy-method="shutdown" scope="singleton">
		<constructor-arg index="0" value="${db.path}" />
	</bean>
	
	<datagraph:repositories base-package="net.junisphere.eranger.domain.internal.neo4j.repositories" />

	<context:component-scan base-package="net.junisphere.eranger.domain.internal.neo4j" />
</beans>
	

Neo4jConfiguration is a java-config class.
Quote:
Are you deploying as a plan, par, pickup? Is the order of artifact deployments identical between systems that work and those that don't?

We are deploying with a plan and the deployed artifacts are exactly the same on the systems.
Quote:
There might be timing issues with SpringDM with a particular configuration set-ups.
I think I ran into something similar where inner beans were used with osgi-service config. Can't remember exact issue right now.

I also think that some race condition leads to this. Maybe the order in which "some" files are read could matter somewhere - maybe during a directory scan? As I mentioned, it stopped working on a system after copying the files to a new location.

Any ideas?


Best regards,
James
Previous Topic:Preventing double bundle start when developing plan in Eclipse tooling
Next Topic:Virgo imports merge problem: is it a bug?
Goto Forum:
  


Current Time: Sun Sep 21 12:07:19 GMT 2014

Powered by FUDForum. Page generated in 0.02112 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software