Discussed in #8121
Apache NetBeans version
Apache NetBeans 24
What happened
A new unwanted directory is appearing in the build directory and so being included in the .war file
/build/web/WEB-INF/classesa/NetbeansProjects/jaffa/build/web/javascript/[various files here]
The folder contains files that are generated and written to the web directory during the build.
If I subsequently edit files in under the web directory of the project they start to appear in the classesa directory with additional directory tree structure
Language / Project Type / NetBeans Component
java ant web application project
How to reproduce
- Click add new project
- Select Category Java with Ant/Java Web/Web Application
- Do a clean and build and then review the contents of
build/web/WEB-INF/ - you will see there is a classes directory but no classesa directory.
-Make an edit to the index.html, save, and then review the contents of build/web/WEB-INF/ - you will see there is now a classesa directory created with subdirectories that ultimately contain a copy of the index.html file.
When files under the web directory are subsequently modified the classesa directory gets added to with the jsp files I have edited.
Did this work correctly in an earlier version?
Yes
Analysis
The issue was originally reported as issue #8119 which was converted to a discussion under the assumption, that this was a misunderstanding of the correct project structure. In the discussion the steps to reproduce above were added. And with these the issue is reproducible (a slightly different name prefix was observed, but the problem is identical).
Debugging ultimately leads to enterprise/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/DeployOnSaveManager.java and its distributeOnSave method. For any change that method is triggered and this code is executed:
|
for (Artifact artifact : artifacts) { |
|
File fsFile = artifact.getFile(); |
|
File altDistFile = artifact.getDistributionPath(); |
|
if (altDistFile == null) { |
|
String classes = "target" + File.separator + "classes"; |
|
String filePath = artifact.getFile().getPath(); |
|
String altDistRelativePath = filePath.substring(filePath.indexOf(classes) + classes.length()); |
|
altDistFile = new File(destRoot.getPath() + File.separator + "WEB-INF" + File.separator + "classes" + altDistRelativePath); |
|
} |
The value of filePath in line 628 is /tmp/WebApplication1/build/web/index.html, the value of classes from line 627 is target/classes. Now in line 629 filePath.indexOf is called and will yield -1 (not found). This case is not handled. The assumptions here are wrong and cause this issue.
Discussed in #8121
Apache NetBeans version
Apache NetBeans 24
What happened
A new unwanted directory is appearing in the build directory and so being included in the .war file
/build/web/WEB-INF/classesa/NetbeansProjects/jaffa/build/web/javascript/[various files here]
The folder contains files that are generated and written to the web directory during the build.
If I subsequently edit files in under the web directory of the project they start to appear in the classesa directory with additional directory tree structure
Language / Project Type / NetBeans Component
java ant web application project
How to reproduce
build/web/WEB-INF/- you will see there is aclassesdirectory but noclassesadirectory.-Make an edit to the
index.html, save, and then review the contents ofbuild/web/WEB-INF/- you will see there is now aclassesadirectory created with subdirectories that ultimately contain a copy of theindex.htmlfile.When files under the web directory are subsequently modified the classesa directory gets added to with the jsp files I have edited.
Did this work correctly in an earlier version?
Yes
Analysis
The issue was originally reported as issue #8119 which was converted to a discussion under the assumption, that this was a misunderstanding of the correct project structure. In the discussion the steps to reproduce above were added. And with these the issue is reproducible (a slightly different name prefix was observed, but the problem is identical).
Debugging ultimately leads to
enterprise/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/DeployOnSaveManager.javaand itsdistributeOnSavemethod. For any change that method is triggered and this code is executed:netbeans/enterprise/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/DeployOnSaveManager.java
Lines 623 to 631 in 56b8332
The value of
filePathin line 628 is/tmp/WebApplication1/build/web/index.html, the value ofclassesfrom line 627 istarget/classes. Now in line 629filePath.indexOfis called and will yield-1(not found). This case is not handled. The assumptions here are wrong and cause this issue.