jeecgboot/JeecgBoot · error · RuntimeException

{className} not found!

Error message

{className} not found!

What it means

Thrown by MyClassLoader.getClassByScn when Class.forName cannot find the requested class on the context classloader. The ClassNotFoundException is caught, printed, and rethrown as a RuntimeException with the message '{className} not found!'. This is a generic dynamic-class-loading utility, not security-gated.

Source

Thrown at jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/MyClassLoader.java:17

package org.jeecg.common.util;

import org.jeecg.common.constant.SymbolConstant;

/**
 * @Author  张代浩
 */
public class MyClassLoader extends ClassLoader {
	public static Class getClassByScn(String className) {
		Class myclass = null;
		try {
			//update-begin---author:scott ---date:20260416  for:【PR#9538】Class.forName使用上下文类加载器,增强部署兼容性-----------
			myclass = Class.forName(className, true, Thread.currentThread().getContextClassLoader());
			//update-end---author:scott ---date:20260416  for:【PR#9538】Class.forName使用上下文类加载器,增强部署兼容性-----------
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			throw new RuntimeException(className+" not found!");
		}
		return myclass;
	}

    /**
     * 获得类的全名,包括包名
     * @param object
     * @return
     */
	public static String getPackPath(Object object) {
		// 检查用户传入的参数是否为空
		if (object == null) {
			throw new java.lang.IllegalArgumentException("参数不能为空!");
		}
		// 获得类的全名,包括包名
		String clsName = object.getClass().getName();
		return clsName;
	}

View on GitHub (pinned to 96fb33f5ec)

Solutions

  1. Verify the fully-qualified class name is correct and the class is present in a deployed jar/module.
  2. Ensure the module declaring the class is on the runtime classpath (add the Maven dependency, rebuild).
  3. If the issue is classloader visibility in a packaged jar, confirm the thread context classloader can see the class; load via the specific classloader that owns it.
  4. Catch RuntimeException at the call site and degrade gracefully if dynamic loading is optional.

Example fix

// before
Class<?> clazz = MyClassLoader.getClassByScn(config.getClassName());

// after
Class<?> clazz;
try {
    clazz = MyClassLoader.getClassByScn(config.getClassName());
} catch (RuntimeException e) {
    log.error("动态类 [{}] 未找到,请检查类名与依赖", config.getClassName(), e);
    throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (className == null || className.isBlank()) {
    throw new IllegalArgumentException("className 不能为空");
}

Type guard

null

Try / catch

try {
    Class<?> clazz = MyClassLoader.getClassByScn(fqcn);
} catch (RuntimeException e) {
    log.error("类 [{}] 未找到", fqcn, e);
    throw new IllegalArgumentException("指定的类不存在: " + fqcn, e);
}

Prevention

When it happens

Trigger: Calling MyClassLoader.getClassByScn(fqcn) with a fully-qualified class name that is absent from the runtime classpath, or when the thread context classloader cannot see the class (common in fat-jar / layered deployments).

Common situations: Typo or stale class name in a configuration table; the module containing the class was not included as a dependency; class removed or relocated in a framework upgrade; context classloader differs in a Spring Boot executable jar vs IDE.

Related errors


AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14). Data as JSON: /api/errors/74c86c9c551b5853. Report an issue: GitHub.