{"record":{"id":"b6f8315d25c804fe","repo":"alibaba/spring-cloud-alibaba","slug":"sentinel-starter-datasource-datasourcename-fie","errorCode":null,"errorMessage":"[Sentinel Starter] DataSource {dataSourceName} field: {fieldName} invoke error","messagePattern":"\\[Sentinel Starter\\] DataSource (.+?) field: (.+?) invoke error","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-sentinel/src/main/java/com/alibaba/cloud/sentinel/custom/SentinelDataSourceHandler.java","lineNumber":121,"sourceCode":"\t\t\t\t\t\t\t\t+ \" build error: \" + e.getMessage(), e);\n\t\t\t\t\t}\n\t\t\t\t});\n\t}\n\n\tprotected BeanDefinitionBuilder parseBeanDefinition(final AbstractDataSourceProperties dataSourceProperties,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tString dataSourceName) {\n\t\tMap<String, Object> propertyMap = Arrays\n\t\t\t\t.stream(dataSourceProperties.getClass().getDeclaredFields())\n\t\t\t\t.filter(field -> !field.isSynthetic())\n\t\t\t\t.collect(HashMap::new, (m, v) -> {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tv.setAccessible(true);\n\t\t\t\t\t\tm.put(v.getName(), v.get(dataSourceProperties));\n\t\t\t\t\t}\n\t\t\t\t\tcatch (IllegalAccessException e) {\n\t\t\t\t\t\tlog.error(\"[Sentinel Starter] DataSource \" + dataSourceName\n\t\t\t\t\t\t\t\t+ \" field: \" + v.getName() + \" invoke error\");\n\t\t\t\t\t\tthrow new RuntimeException(\n\t\t\t\t\t\t\t\t\"[Sentinel Starter] DataSource \" + dataSourceName\n\t\t\t\t\t\t\t\t\t\t+ \" field: \" + v.getName() + \" invoke error\",\n\t\t\t\t\t\t\t\te);\n\t\t\t\t\t}\n\t\t\t\t}, HashMap::putAll);\n\t\tpropertyMap.put(CONVERTER_CLASS_FIELD, dataSourceProperties.getConverterClass());\n\t\tpropertyMap.put(DATA_TYPE_FIELD, dataSourceProperties.getDataType());\n\n\t\tBeanDefinitionBuilder builder = BeanDefinitionBuilder\n\t\t\t\t.genericBeanDefinition(dataSourceProperties.getFactoryBeanName());\n\n\t\tpropertyMap.forEach((propertyName, propertyValue) -> {\n\t\t\tField field = ReflectionUtils.findField(dataSourceProperties.getClass(),\n\t\t\t\t\tpropertyName);\n\t\t\tif (null == field) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (DATA_TYPE_FIELD.equals(propertyName)) {","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/alibaba/spring-cloud-alibaba/blob/115d5901102009492e05d5ec18c3f79cad4077d0/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-sentinel/src/main/java/com/alibaba/cloud/sentinel/custom/SentinelDataSourceHandler.java#L103-L139","documentation":"SentinelDataSourceHandler reflects over the fields of a configured DataSource properties object (e.g. FileDataSourceProperties, NacosDataSourceProperties) to read its values and build a bean definition. If reflective field access is denied, it wraps the IllegalAccessException in a RuntimeException naming the data source and the offending field. This is a JVM access-control failure during datasource initialization.","triggerScenarios":"Running under a strict SecurityManager or a module system (JPMS) that denies setAccessible(true) on the properties class. A custom DataSourceProperties subclass whose fields cannot be made accessible. Certain JDK versions that block reflective access to non-public fields of internal/packaged classes.","commonSituations":"Upgrading the JDK to one that enforces strong encapsulation by default. Adding a SecurityManager policy. Defining a custom datasource properties class with private fields in a sealed/non-open package.","solutions":["Ensure the properties class fields are accessible: open the containing package to spring-cloud-alibaba or make fields public.","If using a SecurityManager, grant 'suppressAccessChecks' / ReflectPermission for the datasource properties classes.","Add JVM opens for the module/package hosting the custom properties, e.g. --add-opens your.module/com.example=ALL-UNNAMED.","Avoid subclassing with fields the framework cannot reflect on; prefer the built-in datasource property types."],"exampleFix":"// before (custom properties with inaccessible private fields)\npublic class MyDataSourceProperties { private String endpoint; }\n// after\npublic class MyDataSourceProperties { public String endpoint; }","handlingStrategy":"validation","validationCode":"void ensureFieldsAccessible(Class<?> props) {\n  for (java.lang.reflect.Field f : props.getDeclaredFields()) {\n    if (java.lang.reflect.Modifier.isPrivate(f.getModifiers()) && !canSetAccessible(f))\n      throw new IllegalStateException(\"Field \" + f.getName() + \" of \" + props.getName() + \" is not reflectively accessible\");\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Open the package hosting custom datasource properties to the framework.","Avoid private fields on custom properties classes used by Sentinel.","On JDK 17+, add the required --add-opens."],"tags":["sentinel","datasource","reflection","jvm-security"],"backgroundTag":null,"analyzedSha":"115d5901102009492e05d5ec18c3f79cad4077d0","analyzedAt":"2026-08-14T04:47:13.900Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}