mardi 28 juillet 2015

Understanding EJB in the context of web applications

I have been working with J2E web applications for some years now and have started to use EJB over the last few weeks. I created a project based on this example

  1. Basically I create two maven projects, similar to what is described here http://ift.tt/1Sdipa9, one that builds a web application(war) and one that builds an EJB. In web applications pom I add a dependency to my EJB and I can use a context look up to call the correct EJB and cast it to the correct class type. Even though my bean is annotated with remote I am guessing this is a local invocation.

  2. On a second attempt I deployed an EJB module and separably deployed the web application. I was able to do a context look up to pull in the session bean. But I could only cast it to an Object class. I think because I had no reference to the EJB in my web application, as it was part of a separably deployed module, I couldn't do the cast.

    I would imagine that since my web applications are seperate, this is a very simple example of a distributed system? If so, How do I avoid this casting issue, if the class definition is in another application?

Aucun commentaire:

Enregistrer un commentaire