Link to home
Start Free TrialLog in
Avatar of sklim
sklim

asked on

J2EE deployment best practise

I have a J2EE environment having the following modules

1) EJBModule - EJB Project
2) UtilityModule - Java Project
3) WebModule - Struts Project - more than one
4) An EAR Application

All (1), (2) and (3) are added to the EAR Application. There is no error during deployment. However, i keep encountering noClassDefFound error during runtime.

there are some 3rd party jar files used in the UtilityModule (3).
e.g. i wrote a class as follows:
public class Common {
  public String replace(String key, String pattern, String value) {
  org.apache.regexp.RE re = new org.apache.regexp.RE(pattern);
  return re.subst(key, value);      
  }
}

the org.apache.regexp.RE is a class package in a jar that is placed in the classpath of the UtilityModule.

Below are cases where i encounter the problem:
1) Call the replace method in struts project
2) Call the replace method in the EJB module. but access EJB module from struts project.

error still occur if i were to put the 3rd party jar files in the classpath of my struts project.

Can somebody please tell me what's the best practise to arrange my modules to avoid the noclassdeffound exception.
Avatar of Mayank S
Mayank S
Flag of India image

Which App Server are you on?
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> noClassDefFound error

- for which class?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sklim
sklim

ASKER

I'm running it on Websphere Application Server.

if i were to put all the 3rd party jars in the WEB-INF\lib directory, what is the proper way to do so that my UtilityModule can reference the class in the 3rd party jars?

the NoClassDefFoundError occur for org/apache/regexp/RE

if i were to put all the 3rd party jars in the server's common directory, does it mean that i do not need to package them during deployment?

i've tried remove the jar from my utilityModule, and put the jar into the WEB-INF\lib directory in the war files, it's still doesn't work.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Three-way split between orangehead911, CEHJ and mayankeagle.
Sounds good
Avatar of sklim

ASKER

Actually I'm asking for the right way to package my projects (in the environment as specified). Anyway, i appreciate the suggestions give.
Please help to split the points to the experts. Thanks
You should follow the "Split Points" link right above the comment-box. Are you not able to find it? Using that link, you can select the comments given by the experts and allot individual points to them (such that the total sum is 250).
sklim, you need to close this question and split the points yourself.