Announcement Announcement Module
Collapse
No announcement yet.
@Stateless don't recognize "name" attribute Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Stateless don't recognize "name" attribute

    I'm implementing the migration task from an ear JBoss application to Spring stand-alone jar application. The problem is: the value of "name" attribute in @Stateless(name="Bean") is not recognized in the Bean Factory when the annotation @EJB(name="Bean") verifies this reference in another EJB.

    This problem is resolved when the annotations (@EJB) contains no "name" attribute. What is happen? The pitchfork project (http://www.springsource.com/pitchfork) also uses the annotations without the "name" attributes. I have tested with 2.5.6 and 3.1.0 versions. Some idea?

    This example shown the problem:

    @Stateless(name = "BeanA")
    public class BeanA implements IBeanA {

    @EJB(name="BeanB")
    private BeanB b;

    ...
    }

    @Stateless(name = "BeanB")
    public class BeanB implements IBeanB {
    ...
    }



    Caused by: org.springframework.beans.factory.NoSuchBeanDefini tionException: No bean named 'BeanB' is defined
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.getBeanDefinition(DefaultListab leBeanFactory.java:527)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getMergedLocalBeanDefinition(AbstractB eanFactory.java:1087)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:278 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:198)
    at org.springframework.context.annotation.CommonAnnot ationBeanPostProcessor.autowireResource(CommonAnno tationBeanPostProcessor.java:440)
    at org.springframework.context.annotation.CommonAnnot ationBeanPostProcessor.getResource(CommonAnnotatio nBeanPostProcessor.java:414)
    at org.springframework.context.annotation.CommonAnnot ationBeanPostProcessor$EjbRefElement.getResourceTo Inject(CommonAnnotationBeanPostProcessor.java:696)
    at org.springframework.beans.factory.annotation.Injec tionMetadata$InjectedElement.inject(InjectionMetad ata.java:147)
    at org.springframework.beans.factory.annotation.Injec tionMetadata.inject(InjectionMetadata.java:84)
    at org.springframework.context.annotation.CommonAnnot ationBeanPostProcessor.postProcessPropertyValues(C ommonAnnotationBeanPostProcessor.java:302)
    ... 29 more

  • #2
    And how is this related to spring? Spring isn't an EJB container and as such isn't picking up any of the EJB annotations, you will need to use either @Component or @Service to make it work with spring. I fyou need EJBs deploy it to an EJB container and use spring to get a reference to that bean by doing a JNDI lookup...

    Comment

    Working...
    X