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>