Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
194 views
in Technique[技术] by (71.8m points)

Apache Nifi can not load MySQL driver

I want to try to connect with MySQL using processor ConvertJSONToSQL and I added mysql-connector-java-5.1.34.jar to my lib folder in nifi folder and in DBCPConnectionPool 1.12.1 I put path to this lib and I'm getting error

2021-02-04 13:41:07,810 WARN [Timer-Driven Process Thread-10] o.a.n.controller.tasks.ConnectableTask Administratively Yielding ConvertJSONToSQL[id=6ecb1fe7-0177-1000-ae33-4a73671a1c31] due to uncaught Exception: org.apache.nifi.controller.service.ControllerServiceDisabledException: Cannot invoke method public default java.sql.Connection org.apache.nifi.dbcp.DBCPService.getConnection(java.util.Map) throws org.apache.nifi.processor.exception.ProcessException on Controller Service with identifier 6ed1aaef-0177-1000-327b-2291fb935dc5 because the Controller Service's State is currently ENABLING
org.apache.nifi.controller.service.ControllerServiceDisabledException: Cannot invoke method public default java.sql.Connection org.apache.nifi.dbcp.DBCPService.getConnection(java.util.Map) throws org.apache.nifi.processor.exception.ProcessException on Controller Service with identifier 6ed1aaef-0177-1000-327b-2291fb935dc5 because the Controller Service's State is currently ENABLING
    at org.apache.nifi.controller.service.StandardControllerServiceInvocationHandler.invoke(StandardControllerServiceInvocationHandler.java:97)
    at com.sun.proxy.$Proxy145.getConnection(Unknown Source)
    at org.apache.nifi.processors.standard.ConvertJSONToSQL.lambda$onTrigger$0(ConvertJSONToSQL.java:317)
    at com.github.benmanes.caffeine.cache.BoundedLocalCache.lambda$doComputeIfAbsent$14(BoundedLocalCache.java:2380)
    at java.base/java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1908)
    at com.github.benmanes.caffeine.cache.BoundedLocalCache.doComputeIfAbsent(BoundedLocalCache.java:2378)
    at com.github.benmanes.caffeine.cache.BoundedLocalCache.computeIfAbsent(BoundedLocalCache.java:2361)
    at com.github.benmanes.caffeine.cache.LocalCache.computeIfAbsent(LocalCache.java:108)
    at com.github.benmanes.caffeine.cache.LocalManualCache.get(LocalManualCache.java:62)
    at org.apache.nifi.processors.standard.ConvertJSONToSQL.onTrigger(ConvertJSONToSQL.java:315)
    at org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27)
    at org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1174)
    at org.apache.nifi.controller.tasks.ConnectableTask.invoke(ConnectableTask.java:213)
    at org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:117)
    at org.apache.nifi.engine.FlowEngine$2.run(FlowEngine.java:110)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
2021-02-04 13:41:08,528 INFO [NiFi Web Server-24] o.a.n.c.s.StandardProcessScheduler Stopping ConvertJSONToSQL[id=6ecb1fe7-0177-1000-ae33-4a73671a1c31]
2021-02-04 13:41:08,528 INFO [NiFi Web Server-24] o.a.n.controller.StandardProcessorNode Stopping processor: ConvertJSONToSQL[id=6ecb1fe7-0177-1000-ae33-4a73671a1c31]
2021-02-04 13:41:08,528 INFO [Timer-Driven Process Thread-6] o.a.n.c.s.TimerDrivenSchedulingAgent Stopped scheduling ConvertJSONToSQL[id=6ecb1fe7-0177-1000-ae33-4a73671a1c31] to run
2021-02-04 13:41:08,591 INFO [Flow Service Tasks Thread-1] o.a.nifi.controller.StandardFlowService Saved flow controller org.apache.nifi.controller.FlowController@233d998a // Another save pending = false
2021-02-04 13:41:11,192 INFO [pool-12-thread-1] o.a.n.c.r.WriteAheadFlowFileRepository Initiating checkpoint of FlowFile Repository
2021-02-04 13:41:11,192 INFO [pool-12-thread-1] o.a.n.c.r.WriteAheadFlowFileRepository Successfully checkpointed FlowFile Repository with 21 records in 0 milliseconds
2021-02-04 13:41:24,853 ERROR [Timer-Driven Process Thread-6] o.a.n.c.s.StandardControllerServiceNode StandardControllerServiceNode[service=DBCPConnectionPool[id=6ed1aaef-0177-1000-327b-2291fb935dc5], versionedComponentId=null, processGroup=StandardProcessGroup[identifier=6ebbd937-0177-1000-c7b8-264fbb3c4621,name=CSVReaderDbWriter], active=true] Failed to invoke @OnEnabled method due to org.apache.nifi.reporting.InitializationException: Can't load Database Driver: {}
org.apache.nifi.reporting.InitializationException: Can't load Database Driver
    at org.apache.nifi.dbcp.DBCPConnectionPool.getDriverClassLoader(DBCPConnectionPool.java:467)
    at org.apache.nifi.dbcp.DBCPConnectionPool.onConfigured(DBCPConnectionPool.java:406)
    at jdk.internal.reflect.GeneratedMethodAccessor637.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:142)
    at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:130)
    at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:75)
    at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotation(ReflectionUtils.java:52)
    at org.apache.nifi.controller.service.StandardControllerServiceNode$2.run(StandardControllerServiceNode.java:432)
    at org.apache.nifi.engine.FlowEngine$2.run(FlowEngine.java:110)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:398)
    at org.apache.nifi.dbcp.DBCPConnectionPool.getDriverClassLoader(DBCPConnectionPool.java:456)
    ... 16 common frames omitted
question from:https://stackoverflow.com/questions/66054305/apache-nifi-can-not-load-mysql-driver

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-api-changes.html

changes in mysql driver 8:

The name of the class that implements java.sql.Driver in MySQL Connector/J has changed from com.mysql.jdbc.Driver to com.mysql.cj.jdbc.Driver. The old class name has been deprecated.


you are using jar library v5.x. so, you have to use com.mysql.jdbc.Driver


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...