title: Injecting EJB into a Spring Boot environment
body: <p>I am currently working on a Spring Boot project, consisting of a full-stack web application, using Spring JPA for the persistence, services for the businness level and Spring MVC for the REST endpoints.</p>
  
  <p>So far so good, but I've been required to add functionalities implemented in pure Java EE.
  I immediately thought about "inserting" a couple of plain old Enterprise Java Beans in some way into the current Spring Boot application.</p>
  
  <p>So far I've tried different possibilites, but nothing worked.
  The EJb is something like </p>
  
  <pre><code>    @Stateless(name = "TeacherService")
      public class TeacherServiceImpl implements TeacherService {
          ....
      }
  </code></pre>
  
  <p>I'd like to inject it into a Spring RestController like this:</p>
  
  <pre><code>    @RestController
      public class ExampleController {
  
         @EJB / @Inject / @Autowire
         private TeacherService teacherService;   
  
         @GetMapping(value = "user")   
         public String getSomeData() {
           return teacherService.someMethod();
         }
      }
  </code></pre>
  
  <p>I tried several combinations but nothing worked so far.
  I found some info around, but it looks like the only way to merge EJB with Spring is to use the complete Spring Framework instead of Spring Boot.
  Before anyone points that out, I know it's a stupid task and I could simply declare the class as a Spring Bean with something like @Service, or @Component, but the assignment states to "provide some functions using plain Java EE" and those annotations belong to Spring.</p>
  
  <p>Is there any workaround  (or anything I haven't tried) for this kind of task? 
  Alternatively, what component of Java EE could be easily compatible with Spring Boot?
  Thank you for your time.</p>