0

i am using WildFly 12 in one of my project at work. A ClassNotFound is getting me crazy even the class is correctly part of the project.

    Exception in thread "Thread-92" java.lang.NoClassDefFoundError: com/me/ServerConnectionFactory$1
15:43:22,284 ERROR [stderr] (Thread-92)     at com.me.MyClass.createCommand(ServerConnectionFactory.java:10)

I dont understand the reason why WildFly is saying that he is not found the MyClass$1 when the name of my class is MyClass ? I was thinking that it is a problem of java reflection so i made all my methods public. ( i made it cause of proxy objects that create WildFly ). It looks that it fails at switch point but it doesn't make sense.

Someone has a solution or can give me some suggestions ? Thnks to everyone

As mention from Aris i am puting here my class.

@ApplicationScoped
public class ServerConnectionFactory {

    public List<String> createCommand(String url, ServerFactory sFactory) {
        List<String> cmdList = new ArrayList<String>();
        ServerFactory serverFactory = sFactory;

        if (url.contains("middleware")) {
            switch (serverFactory) {
            case FIRST:
                log.info("Connecting to the first server");
                cmdList.add("8081");
                break;

            case SECOND:
                log.info("Connecting to the second server");
                cmdList.add("8091");
                break;
            default:
                log.info("log with DEFAULT server");
            }
        }
    }
}

Here is the pom of 3 projects and how they are called: The class stays at the project serverUtilities. The project serverUtilies has a father called Utilities. The project ManageConnections import the project serverUtilies in the way to use the class ServerConnectionFactory but when i try to run it , it give me the exception that i really dont understand.

    **Pom of server Factory. The project where is my class that creates me problems.**
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.server.connection</groupId>
        <artifactId>Utilities</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>serverUtilities</artifactId>
    <packaging>jar</packaging>
    <name>Server Factory Connection</name>


  **Pom of Server Connection that is the father od Server Factory**
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.server.connection</groupId>
    <artifactId>Utilities</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>Utilities</name>
    <modules>
        <module>serverUtilities</module>
    </modules>


    **Pom where server factory is used.**   
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.server.getFactory</groupId>
    <artifactId>ManageConnections</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>Manage Connection Component</name>
    <dependencies>
        <dependency>
            <groupId>com.server.connection</groupId>
            <artifactId>serverUtilities</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
    </dependencies>
Junior Fulcrum
  • 153
  • 1
  • 1
  • 7
  • Please share you code. Most likely this is some anonymous class. Share the `MyClass` code. – akortex Mar 23 '19 at 14:57
  • Usually, NoClassDefFoundError does not mean that the class is not found in the classpath but that the version of bytecode you have compiled against is different than the one that the application found at runtime. https://stackoverflow.com/questions/34413/why-am-i-getting-a-noclassdeffounderror-in-java What are the steps to build the app? – verodigiorgio Mar 23 '19 at 16:38
  • The class ServerConnectionFactory is inside the war that is generated. I simply use clean install with maven and i found the class inside the war, but i dont find the class ServerConnectionFactory$1 at my war. Maybe is that Wildfly that creates problems when generate proxy classes. Someone knows where can i found the proxy classe generated from wildfly? Or when can i found runtime generated classes ? – Junior Fulcrum Mar 23 '19 at 16:52

0 Answers0