mariomueller
I'm new here

Pushing data into an external datasource on generation

Jump to solution

Hi folks,

I'm trying to hook on the generation (full and partly) to push some entities to a CouchDB instance. I've created a library module and some classes to ease the work and keep the script task small and simple. I've exposed both classes (a Configuration and an Activator Class) in a <public> componentent and added all required jars in a library component. Unfortunately I get a ClassNotFound Exception on execution of the script as additional task of the "Generate full" or "Generate partly" jobs.

Anybody any clues?

This is the script, which is to be executed after the generate task:

//! groovy

def activatorCls = Class.forName("de.mario.firstspirit.publisher.couchdb.Activator")

def configurationCls = Class.forName("de.mario.firstspirit.publisher.couchdb.Configuration")

def cfg = configurationCls.newInstance();

cfg.setCouchHost("localhost");

cfg.setCouchPort(5984);

cfg.setCouchUser("admin");

cfg.setCouchPass("admin");

cfg.setCouchDbName("test");

cfg.setUseHttps(false);

def act = activatorCls.newInstance();

act.setGc(context);

act.setConnection(connection);

act.createCouchDBServerFromConfiguration(cfg);

act.runDataSourceExport();

This is a part of my module.xml

<components>

                    <public>

                              <name>CouchDBActivator</name>

                              <description>ActivatorImpl</description>

                              <version>1</version>

                              <class>de.mario.firstspirit.publisher.couchdb.Activator</class>

                    </public>

                    <public>

                              <name>CouchDBConfiguration</name>

                              <description>ConfigurationImpl</description>

                              <version>1</version>

                              <class>de.mario.firstspirit.publisher.couchdb.Configuration</class>

                    </public>

                    <library>

                              <name>CouchDBPublisher</name>

                              <scope>server</scope>

                              <hidden>false</hidden>

                              <resources>

                                        <resource>lib/couchdb.jar</resource>

                                        <resource>lib/slf4j-api-1.6.1.jar</resource>

                                        <resource>lib/svenson-1.3.8.jar</resource>

                                        <resource>lib/jcouchdb-1.0.1-1.jar</resource>

                                        <resource>lib/httpclient-4.0.jar</resource>

                                        <resource>lib/httpcore-4.0.1.jar</resource>

                                        <resource>lib/commons-codec-1.3.jar</resource>

                                        <resource>lib/commons-beanutils-1.8.0.jar</resource>

                              </resources>

                    </library>

          </components>

0 Kudos
1 Solution

Accepted Solutions
Peter_Jodeleit
Crownpeak employee

Could you try "classLoader.loadClass(..)" instead of "Class.forName(..)"?

Peter

View solution in original post

0 Kudos
2 Replies
Peter_Jodeleit
Crownpeak employee

Could you try "classLoader.loadClass(..)" instead of "Class.forName(..)"?

Peter
0 Kudos

This was the right hint Smiley Wink

Thanks!

0 Kudos