jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • XFire
  • XFIRE-297

Jsr181HandlerMapping may force spring to create abstract bean

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 1.0
  • Fix Version/s: 1.1-beta-1
  • Component/s: Spring
  • Labels:
    None
  • Environment:
    JDK1.4, Spring 1.2.6

Description

when Jsr181HandlerMapping.processBeans() called, it will iterate all the bean in app context

private void processBeans(ApplicationContext beanFactory, AnnotationServiceFactory serviceFactory)
{
String[] beanNames = beanFactory.getBeanDefinitionNames();

// Take any bean name or alias that has a web service annotation
for (int i = 0; i < beanNames.length; i++)
{
if (!beanFactory.isSingleton(beanNames[i])) continue;

Class clazz;
Object bean;
try
{
clazz = getApplicationContext().getType(beanNames[i]);
bean = beanFactory.getBean(beanNames[i]);

but if a abstract bean in context, beanFactory.getBean may force spring create abstract bean, and raise a BeanIsAbstractException error.

org.springframework.beans.factory.BeanIsAbstractException: Error creating bean with name 'abstractTxDefinition': Bean definition is abstract

so we must check the bean definition first, like this

ConfigurableApplicationContext.getBeanFactory().getBeanDefinition().isAbstract()

maybe we also need to add a service adapter to process lazy init bean.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Flier Lu added a comment - 10/Mar/06 3:34 AM

working code

private void processBeans(ApplicationContext beanFactory, AnnotationServiceFactory serviceFactory)
{
String[] beanNames = beanFactory.getBeanDefinitionNames();

ConfigurableApplicationContext ctxt = (ConfigurableApplicationContext) beanFactory;

// Take any bean name or alias that has a web service annotation
for (int i = 0; i < beanNames.length; i++)
{
BeanDefinition def = ctxt.getBeanFactory().getBeanDefinition(beanNames[i]);

if (!def.isSingleton() || def.isAbstract()) continue;

Show
Flier Lu added a comment - 10/Mar/06 3:34 AM working code private void processBeans(ApplicationContext beanFactory, AnnotationServiceFactory serviceFactory) { String[] beanNames = beanFactory.getBeanDefinitionNames(); ConfigurableApplicationContext ctxt = (ConfigurableApplicationContext) beanFactory; // Take any bean name or alias that has a web service annotation for (int i = 0; i < beanNames.length; i++) { BeanDefinition def = ctxt.getBeanFactory().getBeanDefinition(beanNames[i]); if (!def.isSingleton() || def.isAbstract()) continue;
Hide
Permalink
Dan Diephouse added a comment - 12/Mar/06 10:42 AM

Thanks, we'll get this fixed.

Show
Dan Diephouse added a comment - 12/Mar/06 10:42 AM Thanks, we'll get this fixed.
Hide
Permalink
Dan Diephouse added a comment - 15/Mar/06 9:49 AM

Fixed in SVN now. Thanks!

Show
Dan Diephouse added a comment - 15/Mar/06 9:49 AM Fixed in SVN now. Thanks!
Hide
Permalink
Karl Palsson added a comment - 21/Nov/08 10:10 AM

Was a second bug created for the lazy-init beans? Because that's still a problem.

Show
Karl Palsson added a comment - 21/Nov/08 10:10 AM Was a second bug created for the lazy-init beans? Because that's still a problem.

People

  • Assignee:
    Dan Diephouse
    Reporter:
    Flier Lu
Vote (0)
Watch (0)

Dates

  • Created:
    10/Mar/06 1:16 AM
    Updated:
    21/Nov/08 10:10 AM
    Resolved:
    15/Mar/06 9:49 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.