title: Injecting a Kotlin EJB into a Java POJO
body: <p>Just started experimenting with Kotlin (1.2.60) &amp; Java (EE8). All is deployed successfully in an EAR file onto JBoss WildFly 13.0.0.Final using Java EE 8, EJB 3.2. No exceptions are shown in the log. </p>
  
  <p>I've created a Kotlin EJB:</p>
  
  <pre><code>@Stateless
  @LocalBean
  open class NOTiFYEJB {
  
      open val logger = LoggerFactory.getLogger("NOTiFYEJB")
  
      open fun sayHelloKotlinWorld() = {
          logger.info("&gt;&gt;&gt;&gt;&gt; sayHelloKotlinWorld .....")
      }
  }
  </code></pre>
  
  <p>Which is 'registered' on WildFly 13:</p>
  
  <blockquote>
    <p>08:06:26,131 INFO  [org.jboss.as.ejb3.deployment] (MSC service thread
    1-1) WFLYEJB0473: JNDI bindings for session bean named 'NOTiFYEJB' in
    deployment unit 'subdeployment "NOTiFYwellJAR.jar" of deployment
    "NOTiFYwell.ear"' are as follows:</p>
    
    <p>java:global/NOTiFYwell/NOTiFYwellJAR/NOTiFYEJB!com.notifywell.kotlin.ejb.NOTiFYEJB
      java:app/NOTiFYwellJAR/NOTiFYEJB!com.notifywell.kotlin.ejb.NOTiFYEJB
      java:module/NOTiFYEJB!com.notifywell.kotlin.ejb.NOTiFYEJB
      ejb:NOTiFYwell/NOTiFYwellJAR/NOTiFYEJB!com.notifywell.kotlin.ejb.NOTiFYEJB
      java:global/NOTiFYwell/NOTiFYwellJAR/NOTiFYEJB
      java:app/NOTiFYwellJAR/NOTiFYEJB    java:module/NOTiFYEJB</p>
  </blockquote>
  
  <p>I inject this into a @model Java Pojo and call the method:</p>
  
  <pre><code>@Model
  @Path("/")
  public class NOTiFYwellModel {
  
      @Inject
      private NOTiFYEJB nOTiFYEJB;
  
      public NOTiFYwellModel() {
      }
  
      @GET
      @Produces(MediaType.APPLICATION_JSON)
      @Path("/say-hello-kotlin-world")
      public Response sayHelloKotlinWorld() {
          logger.info("&gt;&gt;&gt;&gt; sayHelloKotlinWorld nOTiFYEJB = {}", nOTiFYEJB);
  
          nOTiFYEJB.sayHelloKotlinWorld();
  
          return null; // Just for test
      }
  }
  </code></pre>
  
  <p>When I run the Unit test:</p>
  
  <pre><code>String url = "http://localhost:8080/NOTiFYwell/notifywell/say-hello-kotlin-world";
  
  HttpGet httpGet = new HttpGet(url);
  httpGet.setHeader(CONTENT_TYPE, APPLICATION_JSON);
  
  // Execute and get the response.
  HttpClient httpClient = HttpClientBuilder.create().build();
  HttpResponse response = httpClient.execute(httpGet);
  </code></pre>
  
  <p>The method in the @Model NOTiFYwellModel class is called:</p>
  
  <blockquote>
    <p>08:07:00,459 INFO  [com.notifywell.model.NOTiFYwellModel] (default
    task-1) >>>> sayHelloKotlinWorld nOTiFYEJB = Proxy for view class:
    com.notifywell.kotlin.ejb.NOTiFYEJB of EJB: NOTiFYEJB</p>
  </blockquote>
  
  <p>But the next line which calls the method in the (Injected) Kotlin EJB is not executed.</p>
  
  <pre><code>nOTiFYEJB.sayHelloKotlinWorld();
  </code></pre>
  
  <p>It is as though the 'local' interface is not found.</p>
  
  <p>This 'architecture/design' is working fine everywhere else when I inject a (local) Java EJB.</p>
  
  <p>Are you able to use Weld CDI to @Inject a Kotlin EJB into a Java Class?</p>