activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Volodymyr Buell (JIRA)" <j...@apache.org>
Subject [jira] Updated: (AMQ-2960) PooledConnectionFactoryBean returns null in OSGi env sometimes
Date Tue, 05 Oct 2010 16:48:40 GMT

     [ https://issues.apache.org/activemq/browse/AMQ-2960?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Volodymyr Buell updated AMQ-2960:
---------------------------------

    Description: 
>From time to time PooledConnectionFactoryBean failed to initialize itself correctly in
ServiceMix 4 (FUSE actually). From activemq-broker.xml:

Exception in thread "SpringOsgiExtenderThread-20" org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'pooledConnectionFactory' defined in URL [bundleentry://110.fwk173823/META-INF/spring/activemq-broker.xml]:
factory-bean 'pooledConnectionFactoryFactory' returned null
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:289)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:903)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:817)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
	at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
	at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
	at java.lang.Thread.run(Thread.java:619)


The problem is that Spring sometimes invokes @PreConstruct *AFTER* the getObject() has been
used for dependent beans constructing. Therefore PooledConnectionFactoryBean.getObject() returns
null.
Lazy initialization is fixing this issue:

    public Object getObject() throws Exception {
        if (pooledConnectionFactory == null)
        {
            afterPropertiesSet();
        }
        return pooledConnectionFactory;
    }


  was:
>From time to time **PooledConnectionFactoryBean failed to initialize itself** correctly
in [[ServiceMix]] 4 (FUSE actually). From activemq-broker.xml:

Exception in thread "SpringOsgiExtenderThread-20" org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'pooledConnectionFactory' defined in URL [bundleentry://110.fwk173823/META-INF/spring/activemq-broker.xml]:
factory-bean 'pooledConnectionFactoryFactory' returned null
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:289)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:903)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:817)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
	at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
	at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
	at java.lang.Thread.run(Thread.java:619)


The problem is that Spring sometimes invokes @PreConstruct _AFTER_ the getObject() has been
used for dependent beans constructing. Therefore **PooledConnectionFactoryBean.getObject()**
returns null.
Lazy initialization is fixing this issue:

    public Object getObject() throws Exception {
        if (pooledConnectionFactory == null)
        {
            afterPropertiesSet();
        }
        return pooledConnectionFactory;
    }



> PooledConnectionFactoryBean returns null in OSGi env sometimes
> --------------------------------------------------------------
>
>                 Key: AMQ-2960
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2960
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>         Environment: ServiceMix-4.2.0-fuse-02-00, spring-osgi 1.2.1, spring 2.5.6.SEC02
>            Reporter: Volodymyr Buell
>         Attachments: PooledConnectionFactoryBean-lazy-initialization-workaround-for-null.patch
>
>
> From time to time PooledConnectionFactoryBean failed to initialize itself correctly in
ServiceMix 4 (FUSE actually). From activemq-broker.xml:
> Exception in thread "SpringOsgiExtenderThread-20" org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'pooledConnectionFactory' defined in URL [bundleentry://110.fwk173823/META-INF/spring/activemq-broker.xml]:
factory-bean 'pooledConnectionFactoryFactory' returned null
> 	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:289)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:903)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:817)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
> 	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
> 	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
> 	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
> 	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
> 	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
> 	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
> 	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
> 	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
> 	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
> 	at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
> 	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
> 	at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
> 	at java.lang.Thread.run(Thread.java:619)
> The problem is that Spring sometimes invokes @PreConstruct *AFTER* the getObject() has
been used for dependent beans constructing. Therefore PooledConnectionFactoryBean.getObject()
returns null.
> Lazy initialization is fixing this issue:
>     public Object getObject() throws Exception {
>         if (pooledConnectionFactory == null)
>         {
>             afterPropertiesSet();
>         }
>         return pooledConnectionFactory;
>     }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message