Two Laptop Bag
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
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

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
author & internet detective

Joined: May 26, 2003
Posts: 33132

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Nick White Ro

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.

[] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
I agree. Here's the link:
subject: using classes from other modules in web.xml
It's not a secret anymore!