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
- Make the of() method public (and its enclosing class public).
- With JPMS, add opens/exports of the package or run with --add-opens <module>/<package>=ALL-UNNAMED.
- Avoid nested private classes for logical types; move to a top-level public class.
- 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
- Declare logical type classes and of() as public top-level members.
- In JPMS apps, opens the logical-type packages to beam-core.
- Avoid private nested classes for logical types.
- Run reflective decode in a test environment matching production module settings.
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
- Standard logical type
- AutoValue builder class
- Can not call prepareRun
- cannot register Coder : does not have an accessible method…
- cannot register Coder : method named 'of' with arguments…
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)