payara / ecosystem-support

Placeholder repository to handle community requests for the Payara Platform ecosystem tools
4 stars 2 forks source link

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

Open mxread opened 3 years ago

mxread commented 3 years ago

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

Current Outcome

Environment

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;
}
developmentes commented 2 years ago

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 commented 2 years ago

Hi @mxread,

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

fturizo commented 2 years ago

@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 commented 2 years ago

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 commented 1 year ago

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

Netris89 commented 6 months ago

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 ?