Mathias, You can find the response for this thread here https://lists.apache.org/thread.html/3f544870714a46218a783569d70ed4c4722f479e2dba37e78ac632be@%3Cdev.nifi.apache.org%3E
On Thu, Sep 22, 2016 at 11:49 AM, Bryan Bende <[email protected]> wrote: > Hello, > > Usually this is because the dependencies are not quite right between your > NAR and the NAR where the controller service is. > Your processor project needs a dependency on the API of the controller > service, and your NAR needs a NAR dependency on the NAR where the > controller service implementation is. > > The following show examples of how the dependencies work: > https://cwiki.apache.org/confluence/display/NIFI/Maven+ > Projects+for+Extensions#MavenProjectsforExtensions- > LinkingProcessorsandControllerServices > https://github.com/bbende/nifi-dependency-example > > The typical way to get a reference to the controller service in your > processor is like this: > > final DBCPService dbcpService = context.getProperty(DBCP_ > SERVICE).asControllerService(DBCPService.class); > > Let us know if it is still not working after verifying the dependencies. > > Thanks, > > Bryan > > On Thu, Sep 22, 2016 at 11:38 AM, Mathias Tiberghien < > [email protected]> wrote: > >> Hi, >> >> I’m working on version 0.6.1 of Nifi (I’m not allowed to upgrade in this >> project) and I have to build a Custom Nifi Processor that read a specific >> Excel file and Write the data to Sql. >> >> The process is working fine but I’m facing problem to configure the DBCP >> Controller Service Property (as I have to connect to a sql database, I want >> to use a connection from a Controller Service). >> >> Looking on PutSQL Processor source code I’ve devine a ProperptyDescriptor >> as below: >> >> >> >> public static final PropertyDescriptor *ConnectionPool *= new >> PropertyDescriptor.Builder() >> .name("Connection Pool") >> .description("JDBC Connection to Database") >> .identifiesControllerService(DBCPService.class) >> .required(true) >> .build(); >> >> >> >> The Property appears correctly in my Custom Processor on Nifi but when I >> drop down the Combobox, the list remains empty. I can create a DBCP >> Controller Service trough the Combobox and it appears in the list of my >> services, but not in the combobox (I only see the service id) >> >> >> >> Did I missed something in the dependencies of my project (see Pom.xml >> attached) >> >> >> >> I also tried this: >> >> String connection = "ExistingDBCPControllerServiceName"; >> ControllerServiceLookup lookup = context.getControllerServiceLookup(); >> Set<String> identifiers = lookup.getControllerServiceIde >> ntifiers(ControllerService.class); >> if(identifiers.size()==0)log.error("No identifiers found for >> ControllerService"); >> Iterator<String> it = identifiers.iterator(); >> ControllerService service = null; >> boolean found = false; >> while(it.hasNext()) >> { >> >> String id = it.next(); >> String name = lookup.getControllerServiceName(id); >> service = lookup.getControllerService(id); >> log.warn(String.*format*("Service id: %s, name: %s, class: %s",id, >> name,service.getClass())); >> if(name.equals(connection)) >> { >> found=true; >> } >> if(found)break; >> } >> >> >> >> Usting the ControllerServiceLookup and get a known ControllerService. >> >> When I display the service class, it does not appear as DBCPService but >> as a com.sun.Proxy$Proxy89 class and I cannot cast the service to a >> DBCPService >> >> >> >> If I use the code below: >> >> try >> { >> m = service.getClass().getMethod("getConnection",null); >> Connection conn = (Connection) m.invoke(service,null); >> //Cod >> } >> catch (NoSuchMethodException ex) >> { >> log.error("Method getConnection not found: "+ex.getMessage()); >> } >> >> >> >> I can retrieve the Connection from the Proxy >> >> >> >> I’m not familiar coding in java (I’m a C# developer) but it seems that >> some dependency is missing and that my processor can’t parse processor >> proxy correctly >> >> >> >> I’d be very grateful if you have any clue on this. >> >> >> >> Thanks for your answer, >> >> >> >> Mathias >> >> >> >> *Mathias TIBERGHIEN* >> >> CTO >> >> Cell. : +33(0)6 27 58 13 68 >> >> [image: 64] >> >> 87 Bd Chanzy >> >> 93100 Montreuil >> >> France >> >> >> >> Tel : +33(0)1 42 87 16 57 >> >> *www.code192.com <http://www.code192.com>* >> >> >> >> >> ------------------------------ >> [image: Avast logo] >> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> >> >> L'absence de virus dans ce courrier électronique a été vérifiée par le >> logiciel antivirus Avast. >> www.avast.com >> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> >> >> >
