View Full Version : Export bean througth webapps.
djeang
Nov 5th, 2004, 08:44 AM
Hello,
I have 2 webapps (say webapp1 and webapp2) living in the same servlet container (tomcat).
In webapp1 I have a AccountManager interface and a AccountManagerImpl classe.
In webapp 2 I have only the AccountManager interface.
I want to use the AccountManagerImpl within my webapp2 but dont wan't to copy the AccountManagerImpl inside my webapp2 (want to keep the implementation outside webapp2)
I could :
- use RMI or webservice remoting but I don't want to ( no need remoting since the objects live in the same JVM).
- provide AccountManagerImpl as a EJB Session local ( but I want to avoid EJB use or jboss : just use Tomcat).
Is there a solution to this issue ?
thanks.
Alef Arendsen
Nov 5th, 2004, 11:18 AM
I don't think there is a real solution to this problem except for hacky solutions. One of those could be looking up the ServletContext in the 'remote' web application (using ServletContext.getContext("/otherApp") ) and retrieve the ApplicationContext from it (and WebApplicationContext.getWebApplicationContext(oth erServletContext) . This will however cause classloading issues. You'd have to place your common libraries in common/lib (tomcat) since there's no way (without some kind of remoting protocol) to issue calls on the interface only.
I'm running into situations often where I have to do 'remote' calls to other web applications. I usually choose one of two options: either use HttpInvokers, Hessian or Burlap or duplicate the implementation jars and context(s). I usually choose the former since often it doesn't concern invocations that are done a lot of times anyway; I don't care about a little serialization overhead.
djeang
Nov 8th, 2004, 01:51 PM
So, the only way to have a bean (a service) implementation used (without remoting) by several web app is to use a local session ejb ?
I believe that i'll have to deal with EJB for a long time.
A pojo container outside the war, but providing beans for many webapp would be a very interisting feature for engine like Tomcat or Jetty. No more need to use EJB, to duplicate the implementation or use (ineficient) remoting.
And, from an architectural point a view, it would provide a stronger separation between web tier and buisness tier.
Does someone heard of such project or have encounter this issue ?
sethladd
Nov 12th, 2004, 11:57 AM
If you web container supports a writable JNDI, you should be able to place your service object into JNDI for all other webapps to see. Of course, you'll still run into classloading issues. You'll have to put those implementation classes into a common lib directory.
We're going to be deploying new apps with this exact requirement very soon, so hopefully it should work out.
ps This is where systems like Jini really show off. All you need is the raw interfaces. You don't need the Impl classes in your client's classespaths. Those Impl classes are downloaded on the fly.
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.