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

Run on Payara Server does not work #PayaraTools #VSCode #Win10/FISH-5932 #33

Open
mxread opened this issue Aug 3, 2021 · 6 comments
Open
Assignees
Labels
Status: Accepted Confirmed defect or accepted improvement to implement, issue has been escalated to Platform Dev Type: Bug Label issue as a bug defect

Comments

@mxread
Copy link

mxread commented Aug 3, 2021

Description


I have tried to set up a vscode sample project on a windows 10 machine as described in Add Payara Server 5 to the Visual Studio Code Tutorial.

The server starts and stops fine, but deploying via right click context menu doesn't work. Build does not start and exits with a cryptic:

Cannot read property '0' of undefined.

The problem seems to be a missing plugins section in the build section of the pom.xml generate by the maven javaee8 essentials archetype. If a plugin is declared without a groupId (e.g. as in NetBeans based projects), the same error occurs.

Applying @fix_1 and an ide restart removes this error.

But the build still does not start and exits with another message:

Deployment artifact not found in the target.

I could track down the second issue to:

// Maven.js: ll. 61
if (artifacts[i].endsWith('.war')
    || artifacts[i].endsWith('.jar')
    || artifacts[i].endsWith('.rar')
    || artifacts[i] === this.getBuildReader().getFinalName()) {  // comparison with an Object always fails
    artifact = filename;
    break;
}
// MavenPomReader.js : ll. 67 
parseBuild(build) {
    if (build
        && build[0]
        && build[0].finalName) {
        return build[0].finalName; // returns an Object instead of a string
    }
    return '';
}

Applying @fix_2 and an ide restart removes the second error. Build and deployment finish w/o any issue.
Applying @fix_3 will eliminate further problems with missing/incomplete plugins.

Expected Outcome

  • The vscode extension should work with an incomplete plugins section in the maven pom.xml.
  • The vscode extension should correctly determine the artifact name for further processing.

Current Outcome

  • Build via right click context menu fails regardless of valid or invalid pom.xml.

Environment

  • Ecosystem Plugin/Tool: VSCode 1.58.2, Payara Tools 1.1.1, Java Extension Pack 0.18.2, AdoptOpenJDK 11.0.11+9
  • Operating System: Windows 10 64-bit

Fixes

@fix_1
Adding following lines to the build sections solves the issue with the first cryptic error message:

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
    </plugin>
    <!-- ... -->
</plugins>

(Why is this missing in the maven archetype?)

@fix_2
Replacing the return line of parseBuild(build) removes the second error:

// MavenPomReader.js : ll. 67 
parseBuild(build) {
    // ...
        return build[0].finalName.toString(); // l. 71
    // ...
}

@fix_3
Adding null safety and complete null checks eliminates first error regardless of missing maven plugins.

// MavenMicroPluginReader.js: ll. 67
parseBuild(build) {
    if (build
        && build[0]
        && build[0].plugins  // was missing
        && build[0].plugins[0]
        && build[0].plugins[0].plugin) {
        for (let plugin of build[0].plugins[0].plugin) {
            let groupId = plugin.groupId?.toString(); // added null safety and explicit string conversion
            let artifactId = plugin.artifactId?.toString(); // added null safety and explicit string conversion
            if (groupId === PayaraMicroMavenPlugin_1.PayaraMicroMavenPlugin.GROUP_ID
                && artifactId === PayaraMicroMavenPlugin_1.PayaraMicroMavenPlugin.ARTIFACT_ID) {
                return plugin;
            }
        }
    }
    return undefined;
}
@mxread mxread added the Type: Bug Label issue as a bug defect label Aug 3, 2021
@shub8968 shub8968 self-assigned this Aug 17, 2021
@shub8968 shub8968 added the Status: Open Issue has been triaged by the front-line engineers and is being worked on verification label Aug 17, 2021
@developmentes
Copy link

hola soy nuevo con esto y no se a que se refiere cuando dice : la aplicación de un @fix_1 o @fix_2

@shub8968 shub8968 changed the title Run on Payara Server does not work #PayaraTools #VSCode #Win10 Run on Payara Server does not work #PayaraTools #VSCode #Win10/FISH-5932 Dec 14, 2021
@shub8968 shub8968 added Status: Accepted Confirmed defect or accepted improvement to implement, issue has been escalated to Platform Dev and removed Status: Open Issue has been triaged by the front-line engineers and is being worked on verification labels Dec 14, 2021
@shub8968
Copy link

Hi @mxread,

I am able to verify it. Thanks for raising the bug and submitting the possible fixes. Your contribution is highly appreciated.

@fturizo
Copy link
Contributor

fturizo commented Dec 14, 2021

@developmentes, if you need assistance in implementing the fixes recommended by the reporter, I'd recommend you to go and seek assistance in the Payara Forum.

@marcb76
Copy link

marcb76 commented Aug 10, 2022

Hola @developmentes,
La aplicación del @fix1 consiste en actualizar el pom.xml del proyecto (webapp) que deseas desplegar en payara.
Para aplicar los fixes @fiX2 y @Fix3 debes:

  1. Bajar el código fuente de la extensión (última versión)
  2. Ubicar el archivo y línea identificados en el @fix
  3. Actualizar el código
  4. Probar (debug) esta "nueva versión" de la extensión en tu vs code (extension host)
  5. Una vez todo esté bien, instalarla en en tu vs code.

Soy bastante nuevo en el tema pero al menos logré resolver esto.
Si necesitas ayuda avisa.

@ojuschugh1
Copy link

hi,where to add this fix1 in pom.xml ?

@Netris89
Copy link

Netris89 commented Apr 3, 2024

Hi,

I'm using Payara Tools v1.3.0 (which, I assume is the latest version) and the problem is still there. I get the following when trying to run a project (which I know runs when I do it via Netbeans).
image

Any update on this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Confirmed defect or accepted improvement to implement, issue has been escalated to Platform Dev Type: Bug Label issue as a bug defect
Projects
None yet
Development

No branches or pull requests

7 participants