5 Replies Latest reply: Jan 13, 2012 3:12 AM by Christos Vasilakis RSS

    Access EJB

    Christos Vasilakis Newbie

      Hi there,

       

      I have defined a Singleton EJB as

       

      @Singleton

      @Startup

      @ConcurrencyManagement(ConcurrencyManagementType.CONTAINER)

      public class Routing {

      private HashMap<String, HashMap<String, NE>> routing;

       

      @PostConstruct

      public void init() {

      logger.info("@PostConstruct()");

       

      routing  =  new HashMap<String, HashMap<String, NE>>();

      }

       

      @PreDestroy

      public void cleanup() {

      logger.info("@PreDestroy()");

      }

          

      @Lock(LockType.WRITE)

      public void addRouteFromRegistrationCommandMsg(RegistrationCommandMessage message) {

        ..

      }


       

      On my RouteBuilder I

      from("switchyard://RegistrationRoute")

             .unmarshal().json(JsonLibrary.Jackson, gr.forthnet.nms.svcrrd.service.messages.RegistrationCommandMessage.class)

                 .bean(Routing.class, "addRouteFromRegistrationCommandMsg(gr.forthnet.nms.svcrrd.service.messages.RegistrationCommandMessage)")                       

             .log("registration completed");


       

      The bean is successfully called together with json unmarshalling. The problem is that routing instance variable is NULL and I get a NullPointerException so probably it is not the EJB but a new bean instance. I thought because the bean is exposed as CDI I could have access to it.

       

      The other method is to use camel-ejb component. I tried it too (and installed the camel-ejb component on the jboss instance) but I couldn't get access to it. Something is wrong with the JNDI name and the way I call it.

       

      Any tips on how to proper access the EJB through the route?

       

      Regards,

      Christos