1

I'm trying to create a custom input event receiver based on wso2cep 4.0.0 documentation and the decompiled version of filetail input event receiver from cep/repository/components/plugins.(https://docs.wso2.com/display/CEP400/Building+Custom+Event+Receivers).

So far I've managed to add all the classes from the decompiled version, and build a project based on that. After I've copied it in cep_home/repository/components/dropins, I tried to launch CEP server and then I've encountered this:

[2015-12-04 14:00:31,483] ERROR {org.wso2.carbon.event.input.adapter.multiplefiletail.internal.ds.MultipleFileTailEventAdapterServiceDS} -  Cannot create the MultipleFile input event adapter service!
java.util.MissingResourceException: Can't find bundle for base name org.wso2.carbon.event.input.adapter.multiplefiletail.i18n.Resources, locale en_US
        at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1499)
        at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1322)
        at java.util.ResourceBundle.getBundle(ResourceBundle.java:795)
        at org.wso2.carbon.event.input.adapter.multiplefiletail.MultipleFileTailEventAdapterFactory.<init>(MultipleFileTailEventAdapterFactory.java:20)
        at org.wso2.carbon.event.input.adapter.multiplefiletail.internal.ds.MultipleFileTailEventAdapterServiceDS.activate(MultipleFileTailEventAdapterServiceDS.java:25)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
        at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
        at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
        at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
        at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
        at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
        at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
        at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
        at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:451)
        at org.wso2.carbon.core.init.CarbonServerManager.initializeCarbon(CarbonServerManager.java:517)
        at org.wso2.carbon.core.init.CarbonServerManager.start(CarbonServerManager.java:219)
        at org.wso2.carbon.core.internal.CarbonCoreServiceComponent.activate(CarbonCoreServiceComponent.java:91)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
        at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
        at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
        at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
        at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
        at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
        at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
        at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
        at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
        at org.eclipse.equinox.http.servlet.internal.Activator.registerHttpService(Activator.java:81)
        at org.eclipse.equinox.http.servlet.internal.Activator.addProxyServlet(Activator.java:60)
        at org.eclipse.equinox.http.servlet.internal.ProxyServlet.init(ProxyServlet.java:40)
        at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.init(DelegationServlet.java:38)
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5262)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5550)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)}

The error emerges at line: private ResourceBundle resourceBundle = ResourceBundle.getBundle("org.wso2.carbon.event.input.adapter.multiplefiletail.i18n.Resources", Locale.getDefault());

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.event.input.adapter.core.InputEventAdapter;
import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration;
import org.wso2.carbon.event.input.adapter.core.InputEventAdapterFactory;
import org.wso2.carbon.event.input.adapter.core.Property;

public class MultipleFileTailEventAdapterFactory
extends InputEventAdapterFactory
{
    private static final Log log = LogFactory.getLog(MultipleFileTailEventAdapterFactory.class);
    private ResourceBundle resourceBundle = ResourceBundle.getBundle("org.wso2.carbon.event.input.adapter.multiplefiletail.i18n.Resources", Locale.getDefault());

    public String getType()
    {
        return "multiplefile-tail";
    }

    public List<String> getSupportedMessageFormats()
    {
        List<String> supportInputMessageTypes = new ArrayList();
        supportInputMessageTypes.add("text");
        return supportInputMessageTypes;
    }

    public List<Property> getPropertyList()
    {
        List<Property> propertyList = new ArrayList();

        log.info("Method call:MultipleFileEventReceiver::getInputMessageProperties()");

        Property filePath = new Property("filepath");
        filePath.setDisplayName(this.resourceBundle.getString("filepath"));
        filePath.setRequired(true);
        filePath.setHint(this.resourceBundle.getString("filepathHint"));
        propertyList.add(filePath);

        Property filePattern = new Property("filepattern");
        filePattern.setDisplayName(this.resourceBundle.getString("filepattern"));
        filePattern.setRequired(true);
        filePattern.setHint(this.resourceBundle.getString("filepatternHint"));
        propertyList.add(filePattern);

        Property procFolder = new Property("procfolder");
        procFolder.setDisplayName(this.resourceBundle.getString("procfolder"));
        procFolder.setRequired(true);
        procFolder.setHint(this.resourceBundle.getString("procfolderHint"));
        propertyList.add(procFolder);

        Property streamDefinitionProperty = new Property("separator");
        streamDefinitionProperty.setDisplayName("separator");
        streamDefinitionProperty.setRequired(true);
        streamDefinitionProperty.setHint(this.resourceBundle.getString("separatorHint"));
        propertyList.add(streamDefinitionProperty);

        Property numberFields = new Property("numberFields");
        numberFields.setDisplayName(this.resourceBundle.getString("numberFields"));
        numberFields.setRequired(true);
        numberFields.setHint(this.resourceBundle.getString("numberFieldsHint"));
        propertyList.add(numberFields);

        return propertyList;
    }

    public String getUsageTips()
    {
        return this.resourceBundle.getString("file.usage.tips");
    }

    public InputEventAdapter createEventAdapter(InputEventAdapterConfiguration eventAdapterConfiguration, Map<String, String> globalProperties)
    {
        return new MultipleFileTailEventAdapter(eventAdapterConfiguration, globalProperties);
    }

I don't understand why in the original compiled adapter that class is the same and it works and in my case it doesn't.

Can anybody help me?? Thank you very much!

(If you need any other information about this problem, tell me in comments, thanks)

Community
  • 1
  • 1
Eugen Popescu
  • 33
  • 1
  • 7
  • Is Resources.properties file there, under resources, as in https://github.com/wso2/carbon-analytics-common/blob/master/components/event-receiver/event-input-adapters/org.wso2.carbon.event.input.adapter.filetail/src/main/resources/org/wso2/carbon/event/input/adapter/filetail/i18n/Resources.properties ? – Dilini Dec 05 '15 at 16:54
  • Hi, beside the comments with copyright, licensed to apache etc. It is almost the same I modifid some things to suit my adapter, tomorrow I can add it if you wish. Thanks – Eugen Popescu Dec 06 '15 at 20:31
  • so, this is my Resources.properties: `filepath=Source Files Folder filepathHint=This is the folder containing event files filepattern=File Pattern filepatternHint=This is the pattern of the files to be processed procfolder=Processed Files Folder procfolderHint=This is the folder where processed event files are moved to separator=Field Separator separatorHint=This is the field separator in the respective file numberFields=Number of Fields numberFieldsHint=Number of Fields in the respective file` which is located in the same place like in the link you've provided. – Eugen Popescu Dec 07 '15 at 07:58
  • Hi, I made a mistake, the resources folder doesn't match with the path from ServiceDS, now it's working..thanks. – Eugen Popescu Dec 07 '15 at 11:18
  • Hi, Glad that you got it to work :) – Dilini Dec 07 '15 at 12:04
  • ...and can I suggest you to add your finding as an answer since that resolved your issue..? – Dilini Dec 07 '15 at 12:12

1 Answers1

1

After some more research and thanks to Dilini (Thank you!) I've managed to find that the error appeared because I incorrectly configured the Resources folder, it was

src/main/resources/org/wso2/event/adapter/multiplefiletail/i18n/Resources

instead of

src/main/resources/org/wso2/carbon/event/input/adapter/multiplefiletail/i18n/Resources

like it was configured in MultipleFileTailEventAdapterFactory class, where the error emerged. Hope it helps!

Eugen Popescu
  • 33
  • 1
  • 7