wood burning stoves 2.0*
The moose likes Servlets and the fly likes using classes from other modules in web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "using classes from other modules in web.xml" Watch "using classes from other modules in web.xml" New topic
Author

using classes from other modules in web.xml

Mark Wa
Ranch Hand

Joined: May 29, 2009
Posts: 122
Hi, We've got an ear and some wars all set up, currently on of the wars contains "common" classes used by other modules. I would like to use one of these classes in the web.xml of the other modules, but my server will not publish when i try this.

The reason for this is that I would like to set up a SessionListener to monitor the number of active sessions. As I understand a single sessionListener would suffice for all modules?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Mark,
You can move the common classes to a separate project/jar and have each war refer to that. It's called a jar dependency and a common technique.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Nick White Ro
Greenhorn

Joined: Jan 27, 2010
Posts: 15
Another option, if you have multiple applications in the same container that use the same classes, you can package them in a JAR and put the JAR in the container's library folder.
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

Take a little study about SOA. Is a pattern to share apps communications, so you may have access to some class implementation without the need of code replication.


[uaiHebert.com] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: using classes from other modules in web.xml