nifi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Thomsen <mikerthom...@gmail.com>
Subject Mixing ScriptEngine w/ controller services
Date Fri, 02 Nov 2018 12:38:50 GMT
I have a working relationship between a controller service and a processor,
but the processor uses a user-supplied Groovy script to massage some data.
The ScriptEngine is used to make a CompiledScript. I then have a pattern
that looks like this:

    @Override
    public void onTrigger(ProcessContext context, ProcessSession session)
throws ProcessException {
        FlowFile input = session.get();
        if (input == null) {
            return;
        }

        try (InputStream is = session.read(input)) {
            RecordReader reader = readerFactory.createRecordReader(input,
is, getLogger());

            Bindings bindings = engine.createBindings();
            bindings.put("READER", reader);
            bindings.put("SOME_SERVICE", someService);

            script.eval(bindings);

            is.close();

            session.transfer(input, REL_SUCCESS);
        } catch (Exception ex) {
            getLogger().error("Could not build segments.", ex);
            session.transfer(input, REL_FAILURE);
        }
    }

When I run the processor, I get a ScriptException whose ultimate cause is:

Caused by: java.lang.ClassNotFoundException: com.test.DAO
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)

Is there any way I can configure the classloader for the processor to be
able to work with the one used for the controller service so the script has
the ability to access the entire classpath from the controller service nar?

Thanks,

Mike

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message