title: Access main application class in Quarkus extension
body: <p>I have a main Quarkus application with an EventBus which publishes a custom <code>MyEvent</code> class, and a Quarkus extension designed for the main application with a listener for these events.</p>
  <p>My problem is : <strong>the extension does not know the <code>MyEvent</code> class</strong>, so it cannot read the events as anything else than basic <code>Object</code>. I need to access the <code>MyEvent</code> attributes values in the extension. Is there a way to achieve that ?</p>
  <p>I tried redefining the <code>MyEvent</code> class in the extension (<code>MyExtEvent</code>) for brutal casting, but it did obviously not work.</p>
  <p>Simplified main app code :</p>
  <p>MyEvent :</p>
  <pre><code>public class MyEvent {
      private String id;
      private String data;
  
      public MyEvent() {}
  
      public String getId() {
          return id;
      }
  
      public void setId(String id) {
          this.id = id;
      }
  
      public String getData() {
          return data;
      }
  
      public void setData(String data) {
          this.data = data;
      }
  }
  </code></pre>
  <p>Service :</p>
  <pre><code>import io.vertx.mutiny.core.eventbus.EventBus;
  
  import javax.enterprise.context.ApplicationScoped;
  import javax.inject.Inject;
  
  @ApplicationScoped
  public class MyServiceBean implements MyService {
      @Inject
      EventBus bus;
  
      public void notify(MyEvent event) {
          bus.publish(&quot;audit&quot;, event);
      }
  }
  </code></pre>
  <p>Simplified extension code :</p>
  <p>MyExtEvent :</p>
  <pre><code>public class MyExtEvent {
      private String id;
      private String data;
  
      public MyExtEvent() {}
  
      public String getId() {
          return id;
      }
  
      public void setId(String id) {
          this.id = id;
      }
  
      public String getData() {
          return data;
      }
  
      public void setData(String data) {
          this.data = data;
      }
  }
  </code></pre>
  <p>Listener :</p>
  <pre><code>import io.quarkus.vertx.ConsumeEvent;
  
  import javax.enterprise.context.RequestScoped;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  
  @RequestScoped
  public class EventsListener {
      private static final Logger LOGGER = Logger.getLogger(EventsListener.class.getName());
  
      @ConsumeEvent(value = &quot;audit&quot;)
      public void consume(Object oevent) {
          LOGGER.log(Level.FINE, &quot;Event received : &quot; + oevent.toString());
          MyExtEvent event = (MyExtEvent) oevent;
          // Do stuff with &quot;id&quot; and &quot;data&quot; fields
          LOGGER.log(Level.FINE, &quot;Event id : &quot; + event.getId());
          LOGGER.log(Level.FINE, &quot;Event data : &quot; + event.getData());
      }
  }
  </code></pre>
  <p>Casting exception received after the logging line :</p>
  <pre><code>java.lang.ClassCastException: class &lt;main app path&gt;.MyEvent cannot be cast to class &lt;extension path&gt;.MyExtEvent (&lt;main app path&gt;.MyEvent is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @79d9214d; &lt;extension path&gt;.MyExtEvent is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @3c22fc4c)
  </code></pre>