24 九月 2024 20:49:22,727 ERROR [main] (org.apache.flume.channel.ChannelProcessor.configureInterceptors:115)  - Builder class not found. Exception follows.
java.lang.ClassNotFoundException: com.atguigu.fast_food.interceptor.TimestampAndTableNameInterceptor$Builder
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[?:1.8.0_65]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_65]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[?:1.8.0_65]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_65]
	at java.lang.Class.forName0(Native Method) ~[?:1.8.0_65]
	at java.lang.Class.forName(Class.java:264) ~[?:1.8.0_65]
	at org.apache.flume.interceptor.InterceptorBuilderFactory.newInstance(InterceptorBuilderFactory.java:48) ~[flume-ng-core-1.10.1.jar:1.10.1]
	at org.apache.flume.channel.ChannelProcessor.configureInterceptors(ChannelProcessor.java:111) ~[flume-ng-core-1.10.1.jar:1.10.1]
	at org.apache.flume.channel.ChannelProcessor.configure(ChannelProcessor.java:82) ~[flume-ng-core-1.10.1.jar:1.10.1]
	at org.apache.flume.conf.Configurables.configure(Configurables.java:41) ~[flume-ng-core-1.10.1.jar:1.10.1]
	at org.apache.flume.node.AbstractConfigurationProvider.loadSources(AbstractConfigurationProvider.java:345) ~[flume-ng-node-1.10.1.jar:1.10.1]
	at org.apache.flume.node.AbstractConfigurationProvider.getConfiguration(AbstractConfigurationProvider.java:108) ~[flume-ng-node-1.10.1.jar:1.10.1]
	at org.apache.flume.node.Application.main(Application.java:491) ~[flume-ng-node-1.10.1.jar:1.10.1]
24 九月 2024 20:49:22,734 ERROR [main] (org.apache.flume.node.AbstractConfigurationProvider.loadSources:358)  - Source r1 has been removed due to an error during configuration
org.apache.flume.FlumeException: Interceptor.Builder not found.
	at org.apache.flume.channel.ChannelProcessor.configureInterceptors(ChannelProcessor.java:116) ~[flume-ng-core-1.10.1.jar:1.10.1]
	at org.apache.flume.channel.ChannelProcessor.configure(ChannelProcessor.java:82) ~[flume-ng-core-1.10.1.jar:1.10.1]
	at org.apache.flume.conf.Configurables.configure(Configurables.java:41) ~[flume-ng-core-1.10.1.jar:1.10.1]
	at org.apache.flume.node.AbstractConfigurationProvider.loadSources(AbstractConfigurationProvider.java:345) ~[flume-ng-node-1.10.1.jar:1.10.1]
	at org.apache.flume.node.AbstractConfigurationProvider.getConfiguration(AbstractConfigurationProvider.java:108) ~[flume-ng-node-1.10.1.jar:1.10.1]
	at org.apache.flume.node.Application.main(Application.java:491) ~[flume-ng-node-1.10.1.jar:1.10.1]
Caused by: java.lang.ClassNotFoundException: com.atguigu.fast_food.interceptor.TimestampAndTableNameInterceptor$Builder
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[?:1.8.0_65]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_65]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[?:1.8.0_65]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_65]
	at java.lang.Class.forName0(Native Method) ~[?:1.8.0_65]
	at java.lang.Class.forName(Class.java:264) ~[?:1.8.0_65]
	at org.apache.flume.interceptor.InterceptorBuilderFactory.newInstance(InterceptorBuilderFactory.java:48) ~[flume-ng-core-1.10.1.jar:1.10.1]
	at org.apache.flume.channel.ChannelProcessor.configureInterceptors(ChannelProcessor.java:111) ~[flume-ng-core-1.10.1.jar:1.10.1]
	... 5 more

如图所示

根据报错信息,com.atguigu.fast_food.interceptor.TimestampAndTableNameInterceptor$Builder 无法被正确加载,导致在配置 Source 时出现错误。

同时,

错误信息中显示了 java.lang.ClassNotFoundException: com.atguigu.fast_food.interceptor.TimestampAndTableNameInterceptor$Builder,这表明 Flume 在加载拦截器 Builder 类时找不到该类。

1.那既然找不到Builder 类说明要检查一下自定义的拦截器代码是否写对

*最容易出错的地方,继承builder接口写build类时,忘记加static

2.代码没有写错,那需要看一下拦截器的配置写对没有

报错说是

com.atguigu.fast_food.flume.interceptor.TimestampAndTableNameInterceptor

而在拦截器配置文件中却写的是

com.atguigu.fast_food.interceptor.TimestampAndTableNameInterceptor$Builder

原来错的地方那么简单,只是写成路径了,把他改回去就行

再次运行

问题解决

所以一定要好好检查配置文件是否写对了没!

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐