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

Add support for Wildfly 28 #6138

Merged
merged 1 commit into from
Jul 15, 2023

Conversation

asbachb
Copy link
Collaborator

@asbachb asbachb commented Jun 28, 2023

NetBeans communicates to Wildfly via management api. This functionality depends
on several Wildfly classes which are pulled from the Wildfly installation.

It seems that in 28.0.1 some classes and jars were moved which prevents NetBeans
from communicating to Wildfly.

This change simplify the current logic gathering different jars and just use
jboss-cli-client which should contain all necessary classes which are needed
to connect to Wildflys management interface.

I did some manual testing:

  • Start / Stop /Deploy Wildfly 28.0.1
  • Start / Stop / Deploy Wildfly 27.0.1
  • I checked for classes loaded by plugin
  • Downloaded all available Wildfly & JBoss EAP servers
  • Created a test file which creates a Classloader per server and try to load the found classes
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.netbeans.modules.javaee.wildfly;

import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.Collections;
import org.junit.Test;
import org.netbeans.junit.NbTestCase;
import org.openide.util.Exceptions;

/**
 *
 * @author Benjamin Asbach
 */
public class WildflyClassLoaderTest extends NbTestCase {

    public WildflyClassLoaderTest(String name) {
        super(name);
    }

    @Test
    public void testSomeMethod() throws IOException {
        String[] classesUsedByModule = new String[]{
            "org.jboss.dmr.ModelNode",
            "org.jboss.as.controller.client.Operation",
            "org.jboss.as.controller.client.OperationMessageHandler",
            "org.jboss.as.controller.client.ModelControllerClient$Factory",
            "org.jboss.as.controller.client.ModelControllerClientConfiguration$Builder",
            "org.jboss.as.controller.client.ModelControllerClientConfiguration",
            "org.jboss.as.controller.PathAddress",
            "org.jboss.as.controller.PathElement",
            "org.jboss.as.controller.client.helpers.Operations"
        };

        Path wildflyInstallations = Paths.get("/home/asbachb/dev/tmp/wildfly");
        Files.walkFileTree(wildflyInstallations, Collections.emptySet(), 1, new SimpleFileVisitor<Path>(){
            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                WildflyClassLoader classloader = WildflyClassLoader.createWildFlyClassLoader(file.toString());

                System.out.print("Testing " + file.toString() + "...");
                for (String classUsedByModule : classesUsedByModule) {
                    try {
                        classloader.loadClass(classUsedByModule);
                    } catch (ClassNotFoundException ex) {
                        System.out.println("FAILED!");
                        System.out.println("Could not load " + classUsedByModule);
                        
                        Exceptions.printStackTrace(ex);

                        return FileVisitResult.CONTINUE;
                    }
                }

                System.out.println("OK!");

                return FileVisitResult.CONTINUE;
            }
        });
    }
}

Results:

Testing /home/asbachb/dev/tmp/wildfly/wildfly-10.0.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-10.1.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-11.0.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-12.0.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-13.0.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-14.0.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-14.0.1.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-15.0.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-15.0.1.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-16.0.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-17.0.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-17.0.1.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-18.0.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-18.0.1.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-19.1.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-20.0.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-20.0.1.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-21.0.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-21.0.1.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-21.0.2.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-22.0.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-22.0.1.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-23.0.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-23.0.1.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-23.0.2.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-24.0.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-24.0.1.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-25.0.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-25.0.1.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-26.0.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-26.0.1.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-26.1.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-26.1.1.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-26.1.2.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-26.1.3.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-27.0.0.Alpha5...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-27.0.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-27.0.1.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-28.0.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-28.0.1.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-8.0.0.Final...FAILED!
Could not load org.jboss.as.controller.client.ModelControllerClientConfiguration$Builder
Testing /home/asbachb/dev/tmp/wildfly/wildfly-8.1.0.Final...FAILED!
Could not load org.jboss.as.controller.client.ModelControllerClientConfiguration$Builder
Testing /home/asbachb/dev/tmp/wildfly/wildfly-8.2.0.Final...FAILED!
Could not load org.jboss.as.controller.client.ModelControllerClientConfiguration$Builder
Testing /home/asbachb/dev/tmp/wildfly/wildfly-8.2.1.Final...FAILED!
Could not load org.jboss.as.controller.client.ModelControllerClientConfiguration$Builder
Testing /home/asbachb/dev/tmp/wildfly/wildfly-9.0.0.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-9.0.1.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/wildfly-9.0.2.Final...OK!
Testing /home/asbachb/dev/tmp/wildfly/jboss-eap-6.1...FAILED!
Could not load org.jboss.as.controller.client.ModelControllerClientConfiguration$Builder
Testing /home/asbachb/dev/tmp/wildfly/jboss-eap-6.2...FAILED!
Could not load org.jboss.as.controller.client.ModelControllerClientConfiguration$Builder
Testing /home/asbachb/dev/tmp/wildfly/jboss-eap-6.3...FAILED!
Could not load org.jboss.as.controller.client.ModelControllerClientConfiguration$Builder
Testing /home/asbachb/dev/tmp/wildfly/jboss-eap-6.4...FAILED!
Could not load org.jboss.as.controller.client.ModelControllerClientConfiguration$Builder
Testing /home/asbachb/dev/tmp/wildfly/jboss-eap-7.0...OK!
Testing /home/asbachb/dev/tmp/wildfly/jboss-eap-7.1...OK!
Testing /home/asbachb/dev/tmp/wildfly/jboss-eap-7.2...OK!
Testing /home/asbachb/dev/tmp/wildfly/jboss-eap-7.3...OK!
Testing /home/asbachb/dev/tmp/wildfly/jboss-eap-7.4...OK!
Testing /home/asbachb/dev/tmp/wildfly/jboss-eap-8.0...OK!

I assume this would be ok as org.jboss.as.controller.client.ModelControllerClientConfiguration$Builder seems to be not available on the servers classpath and so the module shouldn't be compatible with these servers anyways.

Fixes #5947

@neilcsmith-net neilcsmith-net added the enterprise [ci] enable enterprise job label Jul 4, 2023
@lkishalmi lkishalmi added this to the NB19 milestone Jul 7, 2023
@lkishalmi lkishalmi requested review from pepness, ehsavoie and mbien July 7, 2023 15:43
@asbachb
Copy link
Collaborator Author

asbachb commented Jul 7, 2023

Wildfly 29.0.1.Beta works as well: start/stop/deploy

@ehsavoie
Copy link
Contributor

ehsavoie commented Jul 7, 2023

the jboss-cli-client brings in a lot of classes that we don't need at all and might be problematic. While I agree that some cleanup should be done in the jars that the classloader relies on I'd rather avoid using that jar.

@asbachb
Copy link
Collaborator Author

asbachb commented Jul 7, 2023

@ehsavoie
I'm not 100% sure why this should matter when the ClassLoader is only used for the limited purpose of getting a connection to Wildfly / JBoss EAP. The manual jar curating approach leads to complicated code and is most likely impossible to maintain as it's quite hard to figure out which jars are really needed for the purposes of NetBeans and which wont due to the fact that there's no obvious ClassNotFoundException.

From my understanding using that jar is the supposed way to get a management connection to Wildfly / JBoss EAP.

@mbien
Copy link
Member

mbien commented Jul 8, 2023

the jboss-cli-client brings in a lot of classes that we don't need at all and might be problematic. While I agree that some cleanup should be done in the jars that the classloader relies on I'd rather avoid using that jar.

@ehsavoie what classes are you worried about or what is the concern? The server integration is a hack anyway right now.

But when compared to what it did before when it cherry picked the classpath:

addUrl(urlList, jboss, "dmr" + sep + "main", Pattern.compile("jboss-dmr-.*.jar"));
addUrl(urlList, jboss, "logging" + sep + "main", Pattern.compile("jboss-logging-.*.jar"));
addUrl(urlList, jboss, "marshalling" + sep + "main", Pattern.compile("jboss-marshalling-.*.jar"));
addUrl(urlList, jboss, "marshalling" + sep + "river" + sep + "main", Pattern.compile("jboss-marshalling-river-.*.jar"));
addUrl(urlList, jboss, "remoting" + sep + "main", Pattern.compile("jboss-remoting-.*.jar"));
addUrl(urlList, jboss, "sasl" + sep + "main", Pattern.compile("jboss-sasl-.*.jar"));
addUrl(urlList, jboss, "threads" + sep + "main", Pattern.compile("jboss-threads-.*.jar"));
addUrl(urlList, jboss, "xnio" + sep + "main", Pattern.compile("xnio-api-.*.jar"));
addUrl(urlList, jboss, "xnio" + sep + "nio" + sep + "main", Pattern.compile("xnio-nio-.*.jar"));
addUrl(urlList, as, "controller" + sep + "main", Pattern.compile("wildfly-controller-.*.jar"));
addUrl(urlList, as, "controller" + sep + "main", Pattern.compile("jboss-as-controller-.*.jar"));
addUrl(urlList, as, "controller-client" + sep + "main", Pattern.compile("jboss-as-controller-client-.*.jar"));
addUrl(urlList, as, "controller-client" + sep + "main", Pattern.compile("wildfly-controller-client-.*.jar"));
addUrl(urlList, as, "protocol" + sep + "main", Pattern.compile("wildfly-protocol-.*.jar"));
addUrl(urlList, as, "protocol" + sep + "main", Pattern.compile("jboss-as-protocol-.*.jar"));

Simply using the cli jar seems to be a more maintainable approach. Ideally, this all should not be needed if there would be a server independent tooling interface.

@mbien
Copy link
Member

mbien commented Jul 13, 2023

@asbachb can you squash this to be ready for merge?

I plan to merge this this weekend unless someone says otherwise. Feature freeze is next week.

cc @ehsavoie @matthiasblaesing @pepness

@ehsavoie
Copy link
Contributor

ehsavoie commented Jul 13, 2023

the cli jar is a uber jar. It contains a lot of unrequired code like jakarta json. I know we had issues with API classes leaking into it.
I think the 'best' way would be to do it the WildFly way and use jboss-modules to bring the dependencies. That way we would only need to load a few modules instead. (I think only the controller-client module is required).
PS: the class loader has been done that way because at that time we didn't want to pull the jar in the plugin. I know that is not the case for eclipse jboss-tools.

@ehsavoie
Copy link
Contributor

It might be the org.jboss.as.controller (full) module and not just the org.jboss.as.controller-client but I would have to take a deeper look.

@asbachb
Copy link
Collaborator Author

asbachb commented Jul 13, 2023

I just wonder if it's a better approach to move a potentially better fix to the (maybe never) future or merge this approach and do it better next time.

Fact is: NetBeans is unable to handle Wildfly 28 for almost half a year - Beta releases not counted so potentially even longer.

@ehsavoie
Copy link
Contributor

Yes I no longer work on the core management model of WildFly and didn't notice the removal of method that were used in the NetBeans plugin.

@ehsavoie
Copy link
Contributor

We can merge that but please create a Jira for the module classloading and affect it to me.
PS I'd love to get notified when someone notice that WildFly stops working ...

@asbachb asbachb force-pushed the 5947-add-support-for-wildfly-28 branch from 2f70512 to 6c58fa6 Compare July 13, 2023 15:44
NetBeans communicates to Wildfly via management api. This functionality depends
on several Wildfly classes which are pulled from the Wildfly installation.

It seems that in 28.0.0 some classes and jars were moved which prevents NetBeans
from communicating to Wildfly.

This change simplify the current logic gathering different jars and just use
`jboss-cli-client` which should contain all necessary classes which are needed
to connect to Wildflys management interface.
@asbachb
Copy link
Collaborator Author

asbachb commented Jul 13, 2023

Squashed and created a follow up issue as requested: #6193

@mbien mbien added the ci:all-tests [ci] enable all tests label Jul 15, 2023
@apache apache locked and limited conversation to collaborators Jul 15, 2023
@apache apache unlocked this conversation Jul 15, 2023
@mbien
Copy link
Member

mbien commented Jul 15, 2023

starting another run with all tests enabled to check for side effects. Planning to merge this on Sunday.

@mbien
Copy link
Member

mbien commented Jul 15, 2023

all green and its technically Sunday -> merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:all-tests [ci] enable all tests enterprise [ci] enable enterprise job
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for WildFly 28
5 participants