Topic NoSuchComponentException error when reading Job file in Java

mani started the topic:
2017-09-19 15:02

NoSuchComponentException error when reading Job file in Java

Hi,

Am trying to use DataCleaner 5.1.5 as part of Java app. But while reading the analysis file, seeing below error. Can you please help how to get around this.

org.datacleaner.job.NoSuchComponentException: No such FilterType descriptor: Compare

Code used to read is as below:

InputStream inputStream = new FileInputStream("file.analysis.xml");
JaxbJobReader jobReader = new JaxbJobReader(configuration);
AnalysisJob analysisJob = jobReader.read(inputStream);

Thank you.
Dennis replied:
2017-09-20 09:31
Hmmm... Sounds like either the basic-filters jar hasn't been loaded properly, or that the component scanning hasn't been set up.

When you're creating the configuration, try to use this (along with other configurations you need, of course):
final DescriptorProvider descriptorProvider =
new ClasspathScanDescriptorProvider().scanPackage("org.datacleaner.beans", true);
final DataCleanerConfiguration config = new DataCleanerConfigurationImpl().withDatastoreCatalog(datastoreCatalog)
.withEnvironment(new DataCleanerEnvironmentImpl().withDescriptorProvider(descriptorProvider));

If you don't want everything available, but only specific components, you can use the SimpleDescriptorProvider instead.
mani replied:
2017-09-20 22:46
Hi,

I was using below code to get configuration.

InputStream inputStream = new FileInputStream("conf.xml");
JaxbConfigurationReader configurationReader = new JaxbConfigurationReader();
DataCleanerConfiguration configuration = configurationReader.read(inputStream);

To use the code suggested by you, can you please help how to set "datastoreCatalog" variable as this is not defined in code shared. And can you please help know where should we be referring conf.xml if using the code shared by you above.
Dennis replied:
2017-09-21 09:50
Ah, you can base the new configuration on the existing one, then you should get all the configuration you already set:
final DataCleanerConfiguration newConfig = new DataCleanerConfigurationImpl(oldConfig)
.withEnvironment(new DataCleanerEnvironmentImpl(oldConfig.getEnvironment())
.withDescriptorProvider(descriptorProvider));

You can also put it directly in conf.xml:
<configuration>
...
<descriptor-providers>
<classpath-scanner>
<package recursive="true">org.datacleaner</package>
</classpath-scanner>
</descriptor-providers>
...
</configuration>

If you want to set it manually instead, you can create an instance of org.datacleaner.user.DatastoreCatalogImpl:
final Datastore datastore1 = new CsvDatastore("ds1", "testfile.csv");
final Datastore datastore2 = new JdbcDatastore("ds2", "jdbc:jtds:sqlserver://localhost:1433/test", "testuser", "testpw", true);
final DatastoreCatalog datastoreCatalog = new DatastoreCatalogImpl(Arrays.asList(datastore1, datastore2);

I hope that helps! :)

BR,
Dennis
You are not signed in.
You need to be signed in to participate in the discussion.