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.getControllerServiceIdentifiers(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



87 Bd Chanzy

93100 Montreuil

France



Tel : +33(0)1 42 87 16 57

 <http://www.code192.com> www.code192.com





---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel 
antivirus Avast.
https://www.avast.com/antivirus
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0";
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd";>
    <modelVersion>4.0.0</modelVersion>

    <groupId>code192.nifi.processors</groupId>
    <artifactId>NiceExcelReader</artifactId>
    <version>0.1</version>
    <packaging>nar</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
        <nifi.version>0.6.1</nifi.version>
        <source.skip>true</source.skip>
        <maven.javadoc.skip>true</maven.javadoc.skip>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-api</artifactId>
            <version>${nifi.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-utils</artifactId>
            <version>${nifi.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-processor-utils</artifactId>
            <version>${nifi.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-dbcp-service-api</artifactId>
            <version>${nifi.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.14</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.14</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.7</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.nifi</groupId>
                <artifactId>nifi-nar-maven-plugin</artifactId>
                <version>1.0.0-incubating</version>
                <extensions>true</extensions>
                <configuration>
                    <finalName>code192 - ${artifactId}-${version}</finalName>
                </configuration>
            </plugin>
        </plugins>
    </build>


</project>

Reply via email to