title: How can I inject an EJB with no interface into a Spring bean?
body: <p>I have several EJB 3.x stateless session beans, which have no interfaces defined. I need to inject these beans into a Spring bean, but am unable to do so.</p>
  
  <p>No interface EJB:</p>
  
  <pre><code>@Singleton
  public class MyNoInterfaceEJB {
     public String sayHello() { return "hi"; }
  }
  </code></pre>
  
  <p>My bean:</p>
  
  <pre><code>@Named
  public class MyEJBClientBean {
     @EJB
     private MyNoInterfaceEJB testejb;
  
     // ...
  }
  </code></pre>
  
  <p>And my bean.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd"&gt;
  
      &lt;jee:local-slsb id="testejb" jndi-name="java:global/MyEAR/MyModule/MyProject!com.test.MyNoInterfaceEJB"
              business-interface="com.test.MyNoInterfaceEJB"/&gt;
  
      &lt;context:annotation-config /&gt;
      &lt;context:component-scan base-package="com.test" /&gt;
   &lt;/beans&gt;
  </code></pre>
  
  <p>On initialization of the spring container, I get the following error:</p>
  
  <pre><code>Caused by: org.springframework.beans.factory.BeanCreationException:
  Error creating bean with name 'testejb': 
  Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: [com.test.MyNoInterfaceEJB] is not an interface
  </code></pre>
  
  <p>The exception itself is very clear -- the spring container is expecting that my bean has a local interface view as it's business-interface; however, I don't have one (and can not introduce one). </p>
  
  <p>Any help is greatly appreciated!</p>