Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
matthiasblaesing opened this issue Jan 10, 2025 Discussed in #8121 · 2 comments · Fixed by #8144
Closed
Assignees
Labels
Ant [ci] enable "build tools" tests Java EE/Jakarta EE [ci] enable enterprise job kind:bug Bug report or fix Regression This used to work!

Comments

@matthiasblaesing
Copy link
Contributor

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.

@matthiasblaesing matthiasblaesing added kind:bug Bug report or fix Regression This used to work! labels Jan 10, 2025
@matthiasblaesing
Copy link
Contributor Author

@jGauravGupta please have a look at this issue. It seems your change "Support for Payara Server instance running on WSL" (PR #7885) breaks normal Web Application projects. Please have a look and see how this can be fixed.

@jGauravGupta
Copy link
Contributor

Thanks a lot, @matthiasblaesing, for providing detailed information to reproduce the error. I am looking into this as a priority.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ant [ci] enable "build tools" tests Java EE/Jakarta EE [ci] enable enterprise job kind:bug Bug report or fix Regression This used to work!
Projects
None yet
3 participants