Hi, Sorry, I was busy with other topics. I will work on the sample later today.
Regards JB > Le 12 juin 2020 à 08:38, Kushal Gautam <kushal.gau...@gmail.com> a écrit : > > Hi JB: > > Sorry to bug you again. Any solutions or suggestions on this issue? > > I tried a few other things as well, but I am pretty much stuck. > > Thank you. > > Regards, > Kushal. > > On Mon, Jun 8, 2020 at 2:18 PM Kushal Gautam <kushal.gau...@gmail.com> > wrote: > >> Hi JB: >> >> Thanks. >> >> I have already set up a sample project located at >> https://github.com/cooshal/karaf-camel-mail >> >> The project contains a custom karaf distribution ( >> https://github.com/cooshal/karaf-camel-mail/tree/master/asssembly/karaf-assembly >> ). >> >> My bundle is located at >> https://github.com/cooshal/karaf-camel-mail/tree/master/components/imap-consumer >> >> I am using Open JDK 8 for this project. >> >> Kindly, please let me know if I should provide anything more. >> >> Thank you again. >> >> Regards, >> Cooshal. >> >> On Mon, Jun 8, 2020 at 2:11 PM Jean-Baptiste Onofre <j...@nanthrax.net> >> wrote: >> >>> Sure, the easiest is probably to create a sample project. Do you already >>> have one or do you want me to create one ? >>> >>> Regards >>> JB >>> >>>> Le 8 juin 2020 à 13:46, Kushal Gautam <kushal.gau...@gmail.com> a >>> écrit : >>>> >>>> Hi JB: >>>> >>>> Thank you for the pointers. >>>> >>>> However, I do not know where and how exactly should I change the context >>>> loader in my code. >>>> >>>> I tried but I do not know where. >>>> >>>> Could you please help me out? >>>> >>>> Thank you. >>>> >>>> Regards, >>>> Cooshal. >>>> >>>> On Mon, Jun 8, 2020 at 9:34 AM Jean-Baptiste Onofre <j...@nanthrax.net> >>> wrote: >>>> >>>>> You can find some details about similar issue in the following thread: >>>>> >>>>> >>>>> >>> http://karaf.922171.n3.nabble.com/java-mail-inside-Karaf-td4057507.html#a4057524 >>>>> < >>>>> >>> http://karaf.922171.n3.nabble.com/java-mail-inside-Karaf-td4057507.html#a4057524 >>>>>> >>>>> >>>>> Let me know if it doesn’t help, I will fix your bundle for you. >>>>> >>>>> Regards >>>>> JB >>>>> >>>>>> Le 7 juin 2020 à 10:50, Kushal Gautam <kushal.gau...@gmail.com> a >>> écrit >>>>> : >>>>>> >>>>>> Hi again: >>>>>> >>>>>> I have the following error when I try to start my bundle in karaf: >>>>>> >>>>>> Ignoring converter type: >>> org.apache.camel.converter.AttachmentConverter >>>>> as >>>>>> a dependent class could not be found: java.lang.NoClassDefFoundError: >>>>>> javax/activation/DataHandler >>>>>> java.lang.NoClassDefFoundError: javax/activation/DataHandler >>>>>> at java.lang.Class.getDeclaredMethods0(Native Method) ~[?:?] >>>>>> at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[?:?] >>>>>> at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[?:?] >>>>>> at >>>>>> >>>>> >>> org.apache.camel.impl.converter.AnnotationTypeConverterLoader.loadConverterMethods(AnnotationTypeConverterLoader.java:262) >>>>>> [62:org.apache.camel.camel-core:2.20.3] >>>>>> at >>>>>> >>>>> >>> org.apache.camel.impl.converter.AnnotationTypeConverterLoader.load(AnnotationTypeConverterLoader.java:130) >>>>>> [62:org.apache.camel.camel-core:2.20.3] >>>>>> at >>>>>> >>>>> >>> org.apache.camel.impl.converter.BaseTypeConverterRegistry.loadCoreTypeConverters(BaseTypeConverterRegistry.java:632) >>>>>> [62:org.apache.camel.camel-core:2.20.3] >>>>>> at >>>>>> >>>>> >>> org.apache.camel.core.osgi.OsgiTypeConverter.createRegistry(OsgiTypeConverter.java:218) >>>>>> [60:org.apache.camel.camel-blueprint:2.20.3] >>>>>> at >>>>>> >>>>> >>> org.apache.camel.core.osgi.OsgiTypeConverter.getDelegate(OsgiTypeConverter.java:197) >>>>>> [60:org.apache.camel.camel-blueprint:2.20.3] >>>>>> at >>>>>> >>>>> >>> org.apache.camel.core.osgi.OsgiTypeConverter.mandatoryConvertTo(OsgiTypeConverter.java:124) >>>>>> [60:org.apache.camel.camel-blueprint:2.20.3] >>>>>> at >>>>>> >>>>> >>> org.apache.camel.impl.CamelPostProcessorHelper.getInjectionPropertyValue(CamelPostProcessorHelper.java:278) >>>>>> [62:org.apache.camel.camel-core:2.20.3] >>>>>> at >>>>>> >>>>> >>> org.apache.camel.impl.DefaultCamelBeanPostProcessor.injectFieldProperty(DefaultCamelBeanPostProcessor.java:211) >>>>>> [62:org.apache.camel.camel-core:2.20.3] >>>>>> at >>>>>> >>>>> >>> org.apache.camel.impl.DefaultCamelBeanPostProcessor$1.doWith(DefaultCamelBeanPostProcessor.java:171) >>>>>> [62:org.apache.camel.camel-core:2.20.3] >>>>>> at >>>>>> >>>>> >>> org.apache.camel.util.ReflectionHelper.doWithFields(ReflectionHelper.java:74) >>>>>> [62:org.apache.camel.camel-core:2.20.3] >>>>>> at >>>>>> >>>>> >>> org.apache.camel.impl.DefaultCamelBeanPostProcessor.injectFields(DefaultCamelBeanPostProcessor.java:167) >>>>>> [62:org.apache.camel.camel-core:2.20.3] >>>>>> at >>>>>> >>>>> >>> org.apache.camel.impl.DefaultCamelBeanPostProcessor.postProcessBeforeInitialization(DefaultCamelBeanPostProcessor.java:82) >>>>>> [62:org.apache.camel.camel-core:2.20.3] >>>>>> at >>>>>> >>>>> >>> org.apache.camel.impl.DefaultInjector.newInstance(DefaultInjector.java:48) >>>>>> [62:org.apache.camel.camel-core:2.20.3] >>>>>> at >>>>>> >>>>> >>> org.apache.camel.blueprint.PackageScanRouteBuilderFinder.instantiateBuilder(PackageScanRouteBuilderFinder.java:110) >>>>>> [60:org.apache.camel.camel-blueprint:2.20.3] >>>>>> at >>>>>> >>>>> >>> org.apache.camel.blueprint.PackageScanRouteBuilderFinder.appendBuilders(PackageScanRouteBuilderFinder.java:72) >>>>>> [60:org.apache.camel.camel-blueprint:2.20.3] >>>>>> at >>>>>> >>>>> >>> org.apache.camel.blueprint.CamelContextFactoryBean.findRouteBuildersByPackageScan(CamelContextFactoryBean.java:325) >>>>>> [60:org.apache.camel.camel-blueprint:2.20.3] >>>>>> at >>>>>> >>>>> >>> org.apache.camel.core.xml.AbstractCamelContextFactoryBean.findRouteBuilders(AbstractCamelContextFactoryBean.java:1087) >>>>>> [60:org.apache.camel.camel-blueprint:2.20.3] >>>>>> at >>>>>> >>>>> >>> org.apache.camel.core.xml.AbstractCamelContextFactoryBean.setupRoutes(AbstractCamelContextFactoryBean.java:450) >>>>>> [60:org.apache.camel.camel-blueprint:2.20.3] >>>>>> at >>>>>> >>>>> >>> org.apache.camel.blueprint.CamelContextFactoryBean.afterPropertiesSet(CamelContextFactoryBean.java:355) >>>>>> [60:org.apache.camel.camel-blueprint:2.20.3] >>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] >>>>>> at >>>>>> >>>>> >>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) >>>>>> ~[?:?] >>>>>> at >>>>>> >>>>> >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) >>>>>> ~[?:?] >>>>>> at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:331) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:838) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:591) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:703) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:666) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:81) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:90) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:360) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.blueprint.container.BlueprintRepository.createInstance(BlueprintRepository.java:338) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.blueprint.container.BlueprintRepository.create(BlueprintRepository.java:152) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.blueprint.container.BlueprintContainerImpl.getComponentInstance(BlueprintContainerImpl.java:788) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.camel.blueprint.handler.CamelNamespaceHandler$CamelDependenciesFinder.process(CamelNamespaceHandler.java:988) >>>>>> [60:org.apache.camel.camel-blueprint:2.20.3] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.blueprint.container.BlueprintContainerImpl.processProcessors(BlueprintContainerImpl.java:552) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:397) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:278) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:299) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:268) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:264) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:254) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422) >>>>>> [43:org.apache.aries.blueprint.core:1.9.0] >>>>>> at >>>>>> >>>>> >>> org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1179) >>>>>> [?:?] >>>>>> at >>>>>> >>>>> >>> org.apache.felix.framework.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:730) >>>>>> [?:?] >>>>>> at >>>>>> >>>>> >>> org.apache.felix.framework.EventDispatcher.fireBundleEvent(EventDispatcher.java:485) >>>>>> [?:?] >>>>>> at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4579) >>>>> [?:?] >>>>>> at org.apache.felix.framework.Felix.startBundle(Felix.java:2174) [?:?] >>>>>> at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998) >>> [?:?] >>>>>> at >>>>>> >>>>> >>> org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) >>>>>> [7:org.apache.felix.fileinstall:3.6.4] >>>>>> at >>>>>> >>>>> >>> org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) >>>>>> [7:org.apache.felix.fileinstall:3.6.4] >>>>>> at >>>>>> >>>>> >>> org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1221) >>>>>> [7:org.apache.felix.fileinstall:3.6.4] >>>>>> at >>>>>> >>>>> >>> org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:515) >>>>>> [7:org.apache.felix.fileinstall:3.6.4] >>>>>> at >>>>>> >>>>> >>> org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) >>>>>> [7:org.apache.felix.fileinstall:3.6.4] >>>>>> at >>>>>> >>>>> >>> org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) >>>>>> [7:org.apache.felix.fileinstall:3.6.4] >>>>>> Caused by: java.lang.ClassNotFoundException: >>> javax.activation.DataHandler >>>>>> not found by org.apache.camel.camel-core [62] >>>>>> at >>>>>> >>>>> >>> org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1639) >>>>>> ~[?:?] >>>>>> at >>>>>> >>>>> >>> org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80) >>>>>> ~[?:?] >>>>>> at >>>>>> >>>>> >>> org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2053) >>>>>> ~[?:?] >>>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:352) ~[?:?] >>>>>> >>>>>> Just to test out, I also tried including javax.activation in the >>>>>> dependencies >>>>>> >>>>>> <dependency> >>>>>> <groupId>javax.activation</groupId> >>>>>> <artifactId>activation</artifactId> >>>>>> <version>1.1</version> >>>>>> </dependency> >>>>>> >>>>>> and embedding it in the bundle >>>>>> >>>>>> <build> >>>>>> <plugins> >>>>>> <plugin> >>>>>> <groupId>org.apache.felix</groupId> >>>>>> <artifactId>maven-bundle-plugin</artifactId> >>>>>> <extensions>true</extensions> >>>>>> <configuration> >>>>>> <instructions> >>>>>> <Embed-Dependency>activation</Embed-Dependency> >>>>>> <Import-Package> >>>>>> *;resolution:=optional >>>>>> </Import-Package> >>>>>> </instructions> >>>>>> </configuration> >>>>>> </plugin> >>>>>> </plugins> >>>>>> </build> >>>>>> >>>>>> but, either ways, it does not work. >>>>>> >>>>>> Have I misconfigured anything wrong, in this case? >>>>>> >>>>>> Any inputs/pointers would be very helpful. >>>>>> >>>>>> >>>>>> Thank you. >>>>>> >>>>>> Regards, >>>>>> Cooshal. >>>>>> >>>>>> On Thu, Jun 4, 2020 at 3:05 PM Jean-Baptiste Onofre <j...@nanthrax.net> >>>>> wrote: >>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> How are you looking for the attachment ? In the class loader >>> resource or >>>>>>> using path ? >>>>>>> >>>>>>> I guess your attachement files are not found (either because it’s not >>>>>>> private package of your bundle, or not imported correctly). >>>>>>> >>>>>>> Regards >>>>>>> JB >>>>>>> >>>>>>>> Le 4 juin 2020 à 15:03, Kushal Gautam <kushal.gau...@gmail.com> a >>>>> écrit >>>>>>> : >>>>>>>> >>>>>>>> Camel Version: 2.20.3 >>>>>>>> Java: Open JDK 1.8.0_242 >>>>>>>> Karaf: 4.2.0 >>>>>>>> >>>>>>>> Hi: >>>>>>>> >>>>>>>> Currently, I am using camel-mail to fetch mails via IMAP. >>>>>>>> >>>>>>>> The route is pretty simple and looks like: >>>>>>>> >>>>>>>> from("imaps://{{IMAP_SERVER_URL}}" >>>>>>>> + "?username={{IMAP_EMAIL_USER}}" >>>>>>>> + "&password={{IMAP_EMAIL_PASS}}" >>>>>>>> + "&unseen=true" >>>>>>>> + "&delete=false" >>>>>>>> + "&initialDelay=100" >>>>>>>> + "&delay={{IMAP_POLL_DURATION}}") >>>>>>>> ..... >>>>>>>> >>>>>>>> My custom processor looks something like below (most of the stuffs >>>>> taken >>>>>>>> from the attachments example): >>>>>>>> >>>>>>>> ... >>>>>>>> @Override >>>>>>>> public void process(Exchange exchange) throws Exception { >>>>>>>> >>>>>>>> exchange.getIn().setHeader("HAS_ATTACHMENTS", false); >>>>>>>> >>>>>>>> Map<String, DataHandler> attachments = >>>>>>>> exchange.getIn().getAttachments(); >>>>>>>> >>>>>>>> if (attachments.size() > 0) { >>>>>>>> for (String name : attachments.keySet()) { >>>>>>>> DataHandler dh = attachments.get(name); >>>>>>>> // get the file name >>>>>>>> String filename = dh.getName(); >>>>>>>> >>>>>>>> System.out.println(filename); >>>>>>>> >>>>>>>> // check if the attachment is an xml file >>>>>>>> // if not continue to another attachment >>>>>>>> if(!filename.endsWith(".xml")) { >>>>>>>> continue; >>>>>>>> } >>>>>>>> >>>>>>>> System.out.println("email has an xml attachment"); >>>>>>>> >>>>>>>> // get the content and convert it to byte[] >>>>>>>> byte[] data = exchange >>>>>>>> .getContext() >>>>>>>> .getTypeConverter() >>>>>>>> .convertTo(byte[].class, dh.getInputStream()); >>>>>>>> >>>>>>>> exchange.getIn().setHeader("FILE_NAME", filename); >>>>>>>> exchange.getIn().setHeader("HAS_ATTACHMENTS", true); >>>>>>>> >>>>>>>> exchange.getIn().setBody(data); >>>>>>>> break; >>>>>>>> } >>>>>>>> } >>>>>>>> ... >>>>>>>> >>>>>>>> If I send an email with some attachments, this code works perfectly >>>>> fine >>>>>>>> when I execute it via Netbeans. But, attachments.size() returns 0 >>> for >>>>> the >>>>>>>> same code and same email inside Karaf. >>>>>>>> >>>>>>>> Do I need to configure something specific for this? >>>>>>>> >>>>>>>> Any inputs on this would be helpful. >>>>>>>> >>>>>>>> Thanks, >>>>>>>> Cooshal. >>>>>>> >>>>>>> >>>>> >>>>> >>> >>>