Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 318660 - Publish Dynamic Web Project to the server does not pick up the classes in depended projects.
Summary: Publish Dynamic Web Project to the server does not pick up the classes in dep...
Status: RESOLVED WORKSFORME
Alias: None
Product: WTP Java EE Tools
Classification: WebTools
Component: jst.j2ee (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: jst.j2ee CLA
QA Contact: Chuck Bridgham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-02 01:52 EDT by zzhang CLA
Modified: 2010-11-15 09:45 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description zzhang CLA 2010-07-02 01:52:12 EDT
Build Identifier: I20090611-1540

When I have a dynamic web project I have 2 other java projects in this web application's "Java Build Path", but when I publish the web application to the server and open the browser to invoke my servlet, runtime exception: NoClassDefFoundError is raised.
The class is located in the Java project which has already been added in the Java build path.

Reproducible: Always

Steps to Reproduce:
1. Create a Java Project "MyJavaApp" and create a Class "A" with static method : hello()
2. Create a dynamic web project "MyWebApp" and write a simple servlet "HelloServlet.java"
3. Add Java project "MyJavaApp" into "MyWebApp" Java build path (Go to project tab, then add "MyJavaApp")
4. In "HelloServlet.java" call A.hello(). No compilation error. All good.
5. Add a new server for "MyWebApp", choose Tomcat 6 for example.
6. Publish "MyWebApp" to Tomcat server in eclipse by clicking on debug button in  "Servers" tab.
7. Invoke "HelloServlet" in the browser to make it call "A.hello()"
8. You find exception: java.lang.NoClassDefFoundError: com/test/A

As you can see that I have already included Java project " MyJavaApp" in " MyWebApp" build path and that's why step #4 does not complain anything. However, how after I deploy " MyWebApp" into the server then it start complaining "NoClassDefFoundError"? I guess the "publish" function for eclipse is failed to pick up those java classes in the dependency project(s).
Comment 1 Prakash Rangaraj CLA 2010-07-29 03:34:01 EDT
Moving to WTP
Comment 2 Carl Anderson CLA 2010-11-15 09:45:10 EST
zzhang,

     First, this sounds like you are using the JDT's Java Build Path to specify this compile dependency.  You should be using the J2EE Module Dependencies, which not only adds it to the build path, but also tells WTP that the module should be published.
     However, even if you did not do this, you should have a warning that states that the module is on the Java Build path, but will not be published.  On that warning, there is a quick fix that should also fix this issue up.
     As such, I am closing this, since if I do either of these two, it works for me.