I'm using tomcat. I want put the guava jar and my own jar in tomcat/lib. My jar has a factory to get the event bus and all webapps get access to that factory. I don't know how can I register a listener in webapp1 and post an event from webapp2. The object I'm using in webapp2 doesn't exists in webapp1, I can only share java objects like String, Map of strings etc. but not an object from other webapp.
Some ideas?
this is a classloading issue: most probably, domain classes of webapp1 are not (and should not be) avail in webapp2. believe me, when i say, you don't want to share live objects between webapps.
If you want to share data, consider using a proper JMS(or other similar messaging library), if you want to share behavior, use a REST-service. just to mention the simple common solutions.
all that being said, if you REALLY NEED to go there, you can put the classes you want to share in a single jar and place this and guava in the server-wide classpath + pay extra attention to deployment procedures, as you create a memory-leak. (Still, every time you use that kind of nasty hack, god kills a kitten)