[JBoss] WildFly: ClassNotFoundException for Class Inside JAR in EAR During Server Startup

Discussão em 'StackOverflow' iniciado por Stack, Março 20, 2025.

  1. Stack

    Stack Membro Participativo

    I am running my server startup script on WildFly, and it attempts to load a class that performs some startup tasks. However, I am getting a ClassNotFoundException.

    The class is located inside core.jar, which is packaged inside an EAR file. The EAR file contains multiple JARs inside the modules folder.

    startappserver
    running: Error: Could not find or load main class com.example.common.utility.LaunchV
    Caused by: java.lang.ClassNotFoundException: com.example.common.utility.LaunchV
    Error: Could not find or load main class com.example.common.utility.LaunchV
    Caused by: java.lang.ClassNotFoundException: com.example.common.utility.LaunchV
    Part of the Startup Script:

    echo "launch execute string: $JAVA -Xconcurrentio -ms${MIN_MEM} -mx${MAX_MEM} -XX:+HeapDumpOnOutOfMemoryError ${LOCAL_IP_PROP} -DCONFIG_DIR=${CONFIG_DIR} -classpath ${CORE_CLASSPATH} $CORE_PROPERTIES ${LAUNCH_PROPS} ${PART_NAME} ${LAUNCHV_DEBUGON} -Dcore.processid=$$ -DMAX_MEM=$MAX_MEM com.example.common.utility.LaunchV ${NO_USER_CP} $@ 2>&1;"


    How can I ensure that the class is properly loaded during server startup? Any guidance on configuring the classpath or class loading in WildFly would be appreciated.

    Additionally, I am facing another issue with class loading in WildFly. My EAR file contains multiple JARs and a WAR file. However, the class loader for the WAR file is different, and the WAR is unable to access beans from other JARs in the EAR.

    How can I configure class loading so that the WAR can access beans from other JARs in the EAR?

    Any suggestions or best practices for managing class loading in WildFly would be helpful.

    Continue reading...

Compartilhe esta Página