apache/beam · error · RuntimeException

Standard logical type

Error message

Standard logical type '%s' has an of('%s') method, but it is not accessible.

What it means

After finding a static of(%) method via reflection, the invocation may fail with IllegalAccessException; SchemaTranslation rethrows it as RuntimeException stating the of(...) method is not accessible. This happens when the method is non-public or in a non-exported package (JPMS).

Solutions

  1. Make the of() method public (and its enclosing class public).
  2. With JPMS, add opens/exports of the package or run with --add-opens <module>/<package>=ALL-UNNAMED.
  3. Avoid nested private classes for logical types; move to a top-level public class.
  4. Catch the RuntimeException at decode time and surface a clear configuration error.

Example fix

// before
private static MyLogicalType of(String v){...}
// after
public static MyLogicalType of(String v){...}
Defensive patterns

Strategy: validation

Validate before calling

java.lang.reflect.Method m = logicalTypeClass.getMethod("of", argClass);
if (!java.lang.reflect.Modifier.isPublic(m.getModifiers())
    || !java.lang.reflect.Modifier.isPublic(logicalTypeClass.getModifiers()))
  throw new IllegalStateException("of() not accessible");

Prevention

When it happens

Trigger: Decoding a logical type whose of() method is package-private/private, or whose class is in a module that does not export/opens the package to beam-sdks-java-core.

Common situations: JPMS modularized applications without --add-opens; logical type declared inside a non-public class; Kotlin/Scala factory methods with restricted visibility.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/4d12adcc1562988e. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaTranslation.java:433

              // argument is Map
              clazz = Map.class;
            } else if (fieldValue instanceof Row) {
              // argument is Row
              clazz = Row.class;
            }
            String objectName = clazz.getName();
            try {
              return FieldType.logicalType(
                  logicalTypeClass.cast(
                      logicalTypeClass.getMethod("of", clazz).invoke(null, fieldValue)));
            } catch (NoSuchMethodException e) {
              throw new RuntimeException(
                  String.format(
                      "Standard logical type '%s' does not have a static of('%s') method.",
                      urn, objectName),
                  e);
            } catch (IllegalAccessException e) {
              throw new RuntimeException(
                  String.format(
                      "Standard logical type '%s' has an of('%s') method, but it is not accessible.",
                      urn, objectName),
                  e);
            } catch (InvocationTargetException e) {
              throw new RuntimeException(
                  String.format(
                      "Error instantiating logical type '%s' with of('%s') method.",
                      urn, objectName),
                  e);
            }
          } else {
            // Logical type without argument. Construct from constructor without parameter
            try {
              return FieldType.logicalType(logicalTypeClass.getConstructor().newInstance());
            } catch (NoSuchMethodException e) {
              throw new RuntimeException(
                  String.format(

View on GitHub (pinned to 12126d8942)