Solved

J2EE deployment best practise

Posted on 2004-04-06
12
264 Views
Last Modified: 2013-11-24
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.
0
Comment
Question by:sklim
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1
12 Comments
 
LVL 30

Expert Comment

by:Mayank S
ID: 10765745
Which App Server are you on?
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 80 total points
ID: 10765746
You should be putting the jar file into the WEB-INF/lib of your web app AFAIK
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10765748
>> noClassDefFound error

- for which class?
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 14

Assisted Solution

by:Tommy Braas
Tommy Braas earned 85 total points
ID: 10765973
Like CEHJ mentioned, you need to put any and all 3rd party jars in the WEB-INF\lib directory of ALL war files which contain files that depend on them. Anonther option is to install those 3rd party jars in the server's 'common' directory which will make them available to ALL web applications.
0
 

Author Comment

by:sklim
ID: 10771310
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.
0
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 85 total points
ID: 10771837
If it is not in WEB-INF/lib, then it should also give you a compilation error, I guess. The idea is - if a JAR is needed in one project, then add it to the WEB-INF/lib of that project. You would be able to figure out yourself which ones are needed and which ones are not.

BTW, since you're on Websphere, if you're using WSAD, then you can add the JARs to the project's build-path but right-clicking on the project in the J2EE perspective's navigation window, click on Java Build Path, click on Add External JARs and select the JAR.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10958345
Three-way split between orangehead911, CEHJ and mayankeagle.
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10964040
Sounds good
0
 

Author Comment

by:sklim
ID: 10970294
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
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10971015
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).
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 11046319
sklim, you need to close this question and split the points yourself.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question