Jazz Register Log in
Jazz Forum Welcome to the Jazz Community Forum

Welcome to the Jazz Community Forum

Connect and collaborate with IBM Engineering experts and users

Cannot use inner class as configuration properties validator class

Using an inner class:
public class ScheduledTask extends AbstractAutoScheduledTask {
    [...]
    public class ConfigurationPropertyValidator extends AbstractConfigurationPropertyValidator {
        [...]
    }
}
as validator class for configuration properties:
<prerequisites>
    <configurationProperties validatorClass="ScheduledTask$ConfigurationPropertyValidator">
    [...]

throws a class instantiation exception:

java.lang.InstantiationException: ScheduledTask$ConfigurationPropertyValidator
at java.lang.J9VMInternals.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1558)
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:184)
at com.ibm.team.repository.service.internal.registry.ClientLocalizingRegistryStrategy.createExecutableExtension(ClientLocalizingRegistryStrategy.java:56)
at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:904)
at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
at com.ibm.team.repository.service.internal.registry.ClientLocalizingConfigurationElement.createExecutableExtension(ClientLocalizingConfigurationElement.java:137)
at com.ibm.team.repository.common.transport.AbstractElementDescriptor.createInstance(AbstractElementDescriptor.java:254)
at com.ibm.team.repository.common.transport.internal.registry.ConfigurationPropertiesElementDescriptor.createValidatorInstance(ConfigurationPropertiesElementDescriptor.java:41)
... 174 more
If outer class simply implements the configuration properties validator interface, then methods cannot use services due to:
com.ibm.team.repository.common.transport.internal.registry.ServiceNotFoundException: The service 'ScheduledTask@7d757d75' failed to find the required service 'interface com.ibm.team.repository.common.service.IContributorService'.  Check <prerequisites> in plugin.xml.
        at com.ibm.team.repository.service.AbstractService.getService(AbstractService.java:788)
        at ScheduledTask.validateProperties(ScheduledTask.java:202)
even if these required services are defined in plugin.xml:
<prerequisites>
    [...]
    <requiredService interface="com.ibm.team.repository.common.service.IContributorService" />
</prerequisites>
Any advice?
Thanks in advance.
Cheers.

0 votes


Accepted answer

Permanent link
If outer class simply implements the configuration properties validator interface, then methods cannot use services [...]

We figured out we have to implement IConfigurationPropertyValidator2 instead of IConfigurationPropertyValidator if we need services on our validator class.

public Map<String, IStatus> validateProperties( Map<String, Object> properties, boolean fast, Map<String, Object> services) {
    IContributorService contributorService = (IContributorService) services.get(IContributorService.class.getName());
(Nooby mistake since the same approach is required for accessing properties!)

Ralph Schoon selected this answer as the correct answer

0 votes


2 other answers

Permanent link

 Hi SEC,


Defining IContributorService as a required interface is the way to go if you are working with IContributor related data. 
Have a look at our Secure User Property Store on GitHub which is also using a validator class:
  • Validator Class - implementation of the validator
  • plugin.xml - contains the plugin definition including the requiredService declaration and the validator class usage
  • MANIFEST.MF - ensure that you have imported all required packages
Depending on your needs, you might implement IConfigurationPropertyValidator instead of extending AbstractConfigurationPropertyValidator.

0 votes


Permanent link
Defining IContributorService as a required interface is the way to go if you are working with IContributor related data. 
Yep, we need it to validate a property which have to contain user ID.

Depending on your needs, you might implement IConfigurationPropertyValidator instead of extending AbstractConfigurationPropertyValidator.
We already tried to implement IConfigurationPropertyValidator on the same class of our scheduled task; citing:
If outer class simply implements the configuration properties validator interface, then methods cannot use services [...]
Do you mean we could implement IConfigurationPropertyValidator instead of exteding AbstractConfigurationPropertyValidator on the inner class?

Have a look at our Secure User Property Store on GitHub which is also using a validator class
We saw the example you linked, but it's a stand-alone class. Instead, we are trying to use an inner class as configuration property validator in our existing class for a scheduled task.
Anyway, thank you Lukas for your answer.
Cheers.

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,985

Question asked: Nov 08 '17, 10:06 a.m.

Question was seen: 2,469 times

Last updated: Nov 13 '17, 10:27 a.m.

Confirmation Cancel Confirm