languagetool-org/languagetool · error · IllegalArgumentException

Cannot use premiumOnly=true with non-premium version

Error message

Cannot use premiumOnly=true with non-premium version

What it means

The 'premiumOnly' server property restricts the server to premium rules/features. It is only valid in a premium build of LanguageTool (checked via Premium.isPremiumVersion()); setting it on the free/open-source build throws this IllegalArgumentException.

Source

Thrown at languagetool-server/src/main/java/org/languagetool/server/HTTPServerConfig.java:417

          throw new IllegalArgumentException("Use of cacheTTLSeconds without also setting cacheSize has no effect.");
        }
        cacheTTLSeconds = Integer.parseInt(getOptionalProperty(props, "cacheTTLSeconds", "300"));
        maxErrorsPerWordRate = Float.parseFloat(getOptionalProperty(props, "maxErrorsPerWordRate", "0"));
        suggestionsEnabled = Boolean.parseBoolean(getOptionalProperty(props, "suggestionsEnabled", "true"));
        maxSpellingSuggestions = Integer.parseInt(getOptionalProperty(props, "maxSpellingSuggestions", "0"));
        blockedReferrers = Arrays.asList(getOptionalProperty(props, "blockedReferrers", "").split(",\\s*"));
        setTrustedSources(getOptionalProperty(props, "trustedSources", null));
        String premiumAlwaysValue = props.getProperty("premiumAlways");
        if (premiumAlwaysValue != null) {
          premiumAlways = Boolean.parseBoolean(premiumAlwaysValue.trim());
          if (premiumAlways) {
            System.out.println("*** Running in PREMIUM-ALWAYS mode");
          }
        }
        premiumOnly = Boolean.valueOf(getOptionalProperty(props, "premiumOnly", "false").trim());
        if (premiumOnly) {
          if (!Premium.isPremiumVersion()) {
            throw new IllegalArgumentException("Cannot use premiumOnly=true with non-premium version");
          }
          System.out.println("*** Running in PREMIUM-ONLY mode");
        }
        anonymousAccessAllowed = Boolean.valueOf(getOptionalProperty(props, "anonymousAccessAllowed", "true").trim());
        if (!anonymousAccessAllowed) {
          System.out.println("*** Running in RESTRICTED-ACCESS mode");
        }

        redisHost = getOptionalProperty(props, "redisHost", null);
        redisPort = Integer.parseInt(getOptionalProperty(props, "redisPort", "6379"));
        redisDatabase = Integer.parseInt(getOptionalProperty(props, "redisDatabase", "0"));
        redisUseSSL = Boolean.valueOf(getOptionalProperty(props, "redisUseSSL", "true").trim());
        redisPassword = getOptionalProperty(props, "redisPassword", null);
        redisDictTTL = Integer.parseInt(getOptionalProperty(props, "redisDictTTLSeconds", "600"));
        redisTimeout = Integer.parseInt(getOptionalProperty(props, "redisTimeoutMilliseconds", "100"));
        redisConnectionTimeout = Integer.parseInt(getOptionalProperty(props, "redisConnectionTimeoutMilliseconds", "5000"));

        redisCertificate = getOptionalProperty(props, "redisCertificate", null);

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Remove 'premiumOnly=true' from server.properties when running the free version
  2. Obtain and deploy the premium LanguageTool build/license if premium-only mode is genuinely required
  3. Audit config files copied from premium environments and strip premium-specific keys

Example fix

// before (server.properties)
premiumOnly=true

// after (server.properties)
# premiumOnly removed for non-premium build
Defensive patterns

Strategy: validation

Validate before calling

if (Boolean.parseBoolean(props.getProperty("premiumOnly", "false")) && !isPremiumBuild()) {
    throw new IllegalStateException("premiumOnly=true requires the premium LanguageTool build");
}

Try / catch

try {
    serverConfig = new HTTPServerConfig(props);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("premiumOnly")) {
        props.remove("premiumOnly");
        serverConfig = new HTTPServerConfig(props);
    } else { throw e; }
}

Prevention

When it happens

Trigger: Starting the HTTP server with 'premiumOnly=true' in server.properties while running the standard (non-premium) LanguageTool distribution.

Common situations: Copy-pasting a premium server's configuration to a community/oss deployment; enabling premium flags while evaluating LanguageTool without a premium license.

Related errors


AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06). Data as JSON: /api/errors/d3bfc6c983c31430. Report an issue: GitHub.