Solved

J2EE deployment best practise

Posted on 2004-04-06
12
260 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
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
 
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PDFBox - convert image to PDF, PDF resolution 3 112
get weblogic logged in user in java 2 57
jar file executable 12 37
factorial example 4 34
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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

932 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now