[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

J2EE deployment best practise

Posted on 2004-04-06
12
Medium Priority
?
272 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
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 30

Expert Comment

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

Accepted Solution

by:
CEHJ earned 160 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Assisted Solution

by:Tommy Braas
Tommy Braas earned 170 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 170 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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month18 days, 7 hours left to enroll

829 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