Solved

J2EE deployment best practise

Posted on 2004-04-06
12
263 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Revamp Your Training Process

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

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What's wrong with this code? 4 45
How to determine if a string is a valid SHA value 7 55
ejb message driven bean mdb creation steps 2 54
dao vs facade design patterns 2 68
In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

734 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