Announcement Announcement Module
No announcement yet.
@Stateless don't recognize "name" attribute Page Title Module
Move Remove Collapse
Conversation Detail Module
  • 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 ( 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 {

    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 istableBeanFactory.getBeanDefinition(DefaultListab
    at BeanFactory.getMergedLocalBeanDefinition(AbstractB
    at BeanFactory.doGetBean( )
    at BeanFactory.getBean(
    at org.springframework.context.annotation.CommonAnnot ationBeanPostProcessor.autowireResource(CommonAnno
    at org.springframework.context.annotation.CommonAnnot ationBeanPostProcessor.getResource(CommonAnnotatio
    at org.springframework.context.annotation.CommonAnnot ationBeanPostProcessor$EjbRefElement.getResourceTo Inject(
    at org.springframework.beans.factory.annotation.Injec tionMetadata$InjectedElement.inject(InjectionMetad
    at org.springframework.beans.factory.annotation.Injec tionMetadata.inject(
    at org.springframework.context.annotation.CommonAnnot ationBeanPostProcessor.postProcessPropertyValues(C
    ... 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...