redisson/redisson · error · IllegalArgumentException

Can't parse config

Error message

Can't parse config

What it means

Thrown by RedissonCache.setRedissonConfig(String config) in the MyBatis cache adapter: loading the named classpath resource and parsing it with Config.fromYAML failed. This usually means the resource does not exist (InputStream is null, which makes fromYAML throw) or its content is not valid Redisson YAML.

Source

Thrown at redisson-mybatis/src/main/java/org/redisson/mybatis/RedissonCache.java:107

    public void setMaxIdleTime(long maxIdleTime) {
        this.maxIdleTime = maxIdleTime;
    }

    public void setMaxSize(int maxSize) {
        this.maxSize = maxSize;
    }

    public ReadWriteLock getReadWriteLock() {
        return null;
    }

    public void setRedissonConfig(String config) {
        Config cfg;
        try {
            InputStream is = getClass().getClassLoader().getResourceAsStream(config);
            cfg = Config.fromYAML(is);
        } catch (Exception e) {
            throw new IllegalArgumentException("Can't parse config", e);
        }

        RedissonClient redisson = Redisson.create(cfg);
        mapCache = getMapCache(id, redisson);
        if (maxSize > 0) {
            mapCache.setMaxSize(maxSize);
        }
    }

    protected RMapCache<Object, Object> getMapCache(String id, RedissonClient redisson) {
        return redisson.getMapCache(id);
    }

    private void check() {
        if (mapCache == null) {
            throw new IllegalStateException("Redisson config is not defined");
        }
    }

View on GitHub (pinned to 91188987c2)

Solutions

  1. Verify the exact resource name passed via the 'redissonConfig' cache property exists at the classpath root
  2. Fix the YAML content (validate against Redisson's Config schema) and rebuild so it lands in target/classes
  3. Use an absolute packaging-safe name and check the artifact contents (jar tf) if running from an uber-jar

Example fix

<!-- before -->
<cache type="org.redisson.mybatis.RedissonCache">
  <property name="redissonConfig" value="config/redisson.yaml"/>
</cache>
<!-- with no such resource -->

<!-- after: file at src/main/resources/redisson.yaml -->
<cache type="org.redisson.mybatis.RedissonCache">
  <property name="redissonConfig" value="redisson.yaml"/>
</cache>
Defensive patterns

Strategy: validation

Validate before calling

String res = "redisson.yaml"; // value of the redissonConfig property
if (getClass().getClassLoader().getResource(res) == null) {
    throw new IllegalStateException("Missing Redisson config resource: " + res);
}

Try / catch

catch (IllegalArgumentException e) when the MyBatis cache initializes; unwrap the cause to distinguish 'resource not found' from 'YAML invalid' and fail startup loudly.

Prevention

When it happens

Trigger: A MyBatis mapper <cache type="org.redisson.mybatis.RedissonCache"/> with a cache property like <property name="redissonConfig" value="redisson.yaml"/> where redisson.yaml is missing from the classpath or is malformed YAML.

Common situations: The Redisson config file is named differently (redisson-config.yaml) or lives outside src/main/resources; typo in the property value; YAML content pasted from docs with invalid indentation; running in a fat JAR where the resource ended up under a different path.

Related errors


AI-assisted analysis of redisson/redisson@91188987c2 (2026-08-14). Data as JSON: /api/errors/3c3f7de1da66d1a4. Report an issue: GitHub.