Skip to content

Support for Payara Server instance running on WSL breaks "Web Application" ant projects #8138

@matthiasblaesing

Description

@matthiasblaesing

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.

Metadata

Metadata

Assignees

Labels

Ant[ci] enable "build tools" testsJava EE/Jakarta EE[ci] enable enterprise jobRegressionThis used to work!kind:bugBug report or fix

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions