Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 317834

Summary: Serve modules without publishing is not working
Product: [WebTools] WTP Common Tools Reporter: Iván Perdomo <ivan.perdomo>
Component: wst.commonAssignee: Carl Anderson <ccc>
Status: RESOLVED FIXED QA Contact: Carl Anderson <ccc>
Severity: normal    
Priority: P3 CC: b_stader, cbridgha, count.negative, gabriele.ctn+eclipse, stefan
Version: 3.2Flags: ccc: pmc_approved? (david_williams)
ccc: pmc_approved? (raghunathan.srinivasan)
ccc: pmc_approved? (naci.dai)
deboer: pmc_approved+
ccc: pmc_approved? (neil.hauge)
ccc: pmc_approved? (kaloyan)
cbridgha: review+
Target Milestone: 3.2.1   
Hardware: PC   
OS: Linux   
Whiteboard: PMC_approved
Attachments:
Description Flags
Error stack traces when starting the Apache Tomcat server
none
Tomcat configuration
none
.project file used by the webapp
none
.classpath file
none
Changes in the .classpath as suggested by Larry (comment #4)
none
Error log from the current workspace session
none
.settings/org.eclipse.wst.common.component
none
Add a simple null check to VirtualContainer.createVirtualResource() none

Description Iván Perdomo CLA 2010-06-24 10:38:39 EDT
Created attachment 172617 [details]
Error stack traces when starting the Apache Tomcat server

I have downloaded Eclipse Helios (that includes WTP 3.2.0) and tested the usual configuration I use in 3.5 for a Apache tomcat based webapp.

I know that there has been enhancements in the 'Serve modules without publishing' feature, but to me it fails with a NPE, and then the tomcat server tries to load the application from the disk and there is nothing there.

Attached you'll find the two error stack trace (errors.log) when starting the tomcat server.

I have tested the same server configuration without the 'Serve modules without publishing' and it works just fine.


Cheers,

Iván
Comment 1 Iván Perdomo CLA 2010-06-24 10:39:29 EDT
Created attachment 172618 [details]
Tomcat configuration
Comment 2 Iván Perdomo CLA 2010-06-24 11:33:03 EDT
Created attachment 172625 [details]
.project file used by the webapp
Comment 3 Iván Perdomo CLA 2010-06-24 11:33:44 EDT
Created attachment 172626 [details]
.classpath file

I think that here is where the configuration have changed.
Comment 4 Larry Isaacs CLA 2010-06-24 22:09:12 EDT
As shown in the stack trace, the TomcatPublishModuleVisitor is calling VirtualContainer.getResources().  It does this simply to get a list of resources it needs to examine in an attempt to identify all the "webcontent" folders it needs to handle.  Some "edge case" in your project is causing this getResources() request to throw the NPE.  My first guess would be the classpathentry items in the ".classpath" file that contain [kind="src" path="/OpenbravoTrl"] and [kind="src" path="/OpenbravoWAD"].  You could try temporarily removing those two items from the ".classpath" file and see if the server will publish without the NPE with "Server Modules..." enabled.  Until the "problem" resource is identified, it will be hard to say where the bug actually is.  At this point, I can only say it isn't in the WTP Tomcat plug-ins.
Comment 5 Iván Perdomo CLA 2010-06-25 03:41:52 EDT
(In reply to comment #4)
> As shown in the stack trace, the TomcatPublishModuleVisitor is calling
> VirtualContainer.getResources().  It does this simply to get a list of
> resources it needs to examine in an attempt to identify all the "webcontent"
> folders it needs to handle.  Some "edge case" in your project is causing this
> getResources() request to throw the NPE.  My first guess would be the
> classpathentry items in the ".classpath" file that contain [kind="src"
> path="/OpenbravoTrl"] and [kind="src" path="/OpenbravoWAD"].  You could try
> temporarily removing those two items from the ".classpath" file and see if the
> server will publish without the NPE with "Server Modules..." enabled.  Until
> the "problem" resource is identified, it will be hard to say where the bug
> actually is.  At this point, I can only say it isn't in the WTP Tomcat
> plug-ins.

Hi Larry,

First of all, thanks for your suggestions.

I tried removing the two additional projects from the .classpath and is still failing. Attached you'll find the changes in the .classpath (diff) and the exported error log from the current workspace session.

Any more ideas?

Iván
Comment 6 Iván Perdomo CLA 2010-06-25 03:42:49 EDT
Created attachment 172716 [details]
Changes in the .classpath as suggested by Larry (comment #4)
Comment 7 Iván Perdomo CLA 2010-06-25 03:43:14 EDT
Created attachment 172718 [details]
Error log from the current workspace session
Comment 8 Larry Isaacs CLA 2010-06-25 09:15:26 EDT
Please attach the ".settings/org.eclipse.wst.common.component" file from your project.  The "problem" resource could be in there.  Also, you could try creating a new project.  Then start duplicating the Java Build Path and Deployment Assembly settings of your "problem" project in the new project and see if you can find which setting causes the NPE for the new project.  Thanks.
Comment 9 Iván Perdomo CLA 2010-06-25 11:31:04 EDT
Created attachment 172769 [details]
.settings/org.eclipse.wst.common.component

As requested (in comment #8) the .settings/org.eclipse.wst.common.component file
Comment 10 Iván Perdomo CLA 2010-06-25 11:40:14 EDT
Hi Larry,

You pointed me in the right direction. When double checking the .setting/org.eclipse.wst.common.component file I noticed that I had some entries pointing to deleted folders.

With a clean wst.common.component file (as the one attached) the application loads just fine.

Again, thanks for your support.

Best Regards,

Iván
Comment 11 Larry Isaacs CLA 2010-06-25 12:26:55 EDT
Thanks, that was going to be my next guess.  Re-opening since there is still a bug.  Given the cause you discovered, I would say that VirtualContainer.createVirtualResource() shouldn't be throwing NPEs in this case.
Comment 12 Bernhard Stader CLA 2010-06-28 04:48:54 EDT
I too have problems when using serve modules without publishing. Whereas the same configuration works with publishing.
Some resources are not found because the false folder is used.
For example:
i have a maven project with file structe src/main/java, src/main/webapp and src/main/resources.
in src/main/resources/ the file log4j.properties exists and the standard java output path is target/classes

When starting the server the file log4j.properties is in (workspace location)/target/classes but it is expected to be in (workspace location)/src/main/webapp/WEB-INF/classes. So a java.io.FileNotFoundException is thrown.
Comment 13 Carl Anderson CLA 2010-07-05 07:10:52 EDT
Created attachment 173407 [details]
Add a simple null check to VirtualContainer.createVirtualResource()
Comment 14 Carl Anderson CLA 2010-07-05 07:14:59 EDT
Since we are already shutting down WTP 3.2.1, and since PMC review is needed, I am adding in Chuck Bridgham as a reviewer just to ensure that another set of eyes reviews this code fix before requesting PMC approval.
Comment 15 Chuck Bridgham CLA 2010-07-07 09:13:50 EDT
approved
Comment 16 Carl Anderson CLA 2010-07-07 09:35:34 EDT
This is a minor NPE which is preventing the "Serve modules without publishing" from working properly under certain conditions.
There is no workaround.
I have run the JUnit bucket against this fix, as well as tested by hand.
Simply put, if there is no underlying Eclipse resource for a component resource, VirtualContainer.createVirtualResource() now returns null instead of an NPE.  (Note that it would already return null if the type was not a FILE or a FOLDER.)  Chuck Bridgham has reviewed this fix.
This is a low risk fix- we are adding in a null check, and returning null from a method that could already return null.
Comment 17 Carl Anderson CLA 2010-07-07 11:33:41 EDT
Committed to HEAD for WTP 3.2.1 and WTP 3.3
Comment 18 count negative CLA 2011-03-06 04:48:38 EST
Please reopen for WTP 3.2.3.v201101121727 because there is the same behavior as in 3.2.0
Comment 19 count negative CLA 2011-03-07 03:04:25 EST
Ah, ok. After some investigations on weekend. I can now say it's only _not_ working if you use a tomcat 7 installation (7.0.8) and enable "serve modules without publish". On my old tomcat 6, everything is working fine.
Comment 20 count negative CLA 2011-03-07 03:04:58 EST
Ah, ok. After some investigations on weekend. I can now say it's only _not_ working if you use a tomcat 7 installation (7.0.8) and enable "serve modules without publish". On my old tomcat 6, everything is working fine.