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
-
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.
-
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?
Edit- Because I havent got the awnser I was looking for I have tried to narrow the scope of my question some more.
On this example http://ift.tt/1hgRXbx
You can see the client is able to call the Greeter class, even though it is sitting on another server. The client has no import of the Greeter class. So how is it able to cast the EJB lookup to a class it doesn't have any reference to?
Aucun commentaire:
Enregistrer un commentaire