Solved

J2EE deployment best practise

Posted on 2004-04-06
12
259 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:mayankeagle
Comment Utility
Which App Server are you on?
0
 
LVL 86

Accepted Solution

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

Expert Comment

by:mayankeagle
Comment Utility
>> noClassDefFound error

- for which class?
0
 
LVL 14

Assisted Solution

by:Tommy Braas
Tommy Braas earned 85 total points
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 30

Assisted Solution

by:mayankeagle
mayankeagle earned 85 total points
Comment Utility
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:mayankeagle
Comment Utility
Three-way split between orangehead911, CEHJ and mayankeagle.
0
 
LVL 14

Expert Comment

by:Tommy Braas
Comment Utility
Sounds good
0
 

Author Comment

by:sklim
Comment Utility
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:mayankeagle
Comment Utility
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
Comment Utility
sklim, you need to close this question and split the points yourself.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
commonTwo  challenge 63 98
Updating Java 9 87
parentbit challenge 3 51
github account with ecipse 1 15
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

743 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

8 Experts available now in Live!

Get 1:1 Help Now