3 Replies Latest reply on Jun 11, 2014 8:30 PM by Freeman(Yue) Fang

    Registering JavaMail as OSGi Service

    Muhammad Sohail Newbie

      Greetings,

       

      I am newbie to both Java and JBoss Fuse world.

       

      Following the footsteps of registering JDBC data sources, I was trying to register a mail smtp in the same fashion. I am hot deploying the following. After deployment I do not see anything under Registered Services for this deployment.

       

      <?xml version="1.0" encoding="UTF-8"?>

      <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">

       

        <bean id="mailSourceLive" class="javax.mail.Session">

            <property name="mail.smtp.host" value="mysmptpip"/>

            <property name="mail.smtp.port" value="25"/>

        </bean>

       

        <service auto-export="interfaces" ref="mailSourceLive">

          <service-properties>

            <entry key="osgi.jndi.service.name" value="java:mail/MailServer"/>

          </service-properties>

        </service>

      </blueprint>


      Would appreciate any pointers.


      Regards,

      Sohail

        • 1. Re: Registering JavaMail as OSGi Service
          Freeman(Yue) Fang Master

          Hi,

           

          Did you see any exception in the log?

          Class java.mail.Session doesn't implement any interface, this probably is the culprit.

           

          Freeman

          1 of 1 people found this helpful
          • 2. Re: Re: Registering JavaMail as OSGi Service
            Muhammad Sohail Newbie

            Hello Freeman,

             

            Thanks for the response. This is the exception that is appearing ... really beating up myself for not looking at the log in the first place.

             

            17:12:34,192 | ERROR | edhat-379/deploy | BlueprintContainerImpl           | 9 - org.apache.aries.blueprint.core - 1.0.1.redhat-610379 | Unable to start blueprint container for bundle mailsources.xml

            org.osgi.service.blueprint.container.ComponentDefinitionException: org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to find a matching constructor on class javax.mail.Session for arguments [] when instanciating bean mailSourceLive

                at org.apache.aries.blueprint.container.ServiceRecipe.createService(ServiceRecipe.java:305)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]

                at org.apache.aries.blueprint.container.ServiceRecipe.internalGetService(ServiceRecipe.java:257)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]

                at org.apache.aries.blueprint.container.ServiceRecipe.internalGetService(ServiceRecipe.java:244)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]

                at org.apache.aries.blueprint.container.ServiceRecipe.getClasses(ServiceRecipe.java:377)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]

                at org.apache.aries.blueprint.container.ServiceRecipe.register(ServiceRecipe.java:184)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]

                at org.apache.aries.blueprint.container.BlueprintContainerImpl.registerServices(BlueprintContainerImpl.java:698)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]

                at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:373)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]

                at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:261)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]

                at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:270)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]

                at org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:233)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]

                at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)[11:org.apache.aries.util:1.0.1.redhat-610379]

                at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)[11:org.apache.aries.util:1.0.1.redhat-610379]

                at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)[11:org.apache.aries.util:1.0.1.redhat-610379]

                at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)[11:org.apache.aries.util:1.0.1.redhat-610379]

                at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)[11:org.apache.aries.util:1.0.1.redhat-610379]

                at org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1103)[org.apache.felix.framework-4.0.3.redhat-610379.jar:]

                at org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:696)[org.apache.felix.framework-4.0.3.redhat-610379.jar:]

                at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:484)[org.apache.felix.framework-4.0.3.redhat-610379.jar:]

                at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4650)[org.apache.felix.framework-4.0.3.redhat-610379.jar:]

                at org.apache.felix.framework.Felix$4.run(Felix.java:2123)[org.apache.felix.framework-4.0.3.redhat-610379.jar:]

                at org.apache.felix.framework.Felix.runInContext(Felix.java:2147)[org.apache.felix.framework-4.0.3.redhat-610379.jar:]

                at org.apache.felix.framework.Felix.startBundle(Felix.java:2121)[org.apache.felix.framework-4.0.3.redhat-610379.jar:]

                at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)[org.apache.felix.framework-4.0.3.redhat-610379.jar:]

                at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1247)[7:org.apache.felix.fileinstall:3.3.11.redhat-610379]

                at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1219)[7:org.apache.felix.fileinstall:3.3.11.redhat-610379]

                at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:508)[7:org.apache.felix.fileinstall:3.3.11.redhat-610379]

                at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:291)[7:org.apache.felix.fileinstall:3.3.11.redhat-610379]

            Caused by: org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to find a matching constructor on class javax.mail.Session for arguments [] when instanciating bean mailSourceLive

                at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:336)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]

                at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:806)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]

                at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]

                at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]

                at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)[:1.6.0_21]

                at java.util.concurrent.FutureTask.run(FutureTask.java:138)[:1.6.0_21]

                at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]

                at org.apache.aries.blueprint.di.RefRecipe.internalCreate(RefRecipe.java:62)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]

                at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:106)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]

                at org.apache.aries.blueprint.container.ServiceRecipe.createService(ServiceRecipe.java:290)[9:org.apache.aries.blueprint.core:1.0.1.redhat-610379]

                ... 26 more


            Is there a particular class that I should be including in the blueprint file?


            Regards,

            Sohail

            • 3. Re: Registering JavaMail as OSGi Service
              Freeman(Yue) Fang Master

              Hi,

               

              Class java.mail.Session doesn't have public constructor, you need init-method = "getInstance" to call the factory method to create the instance if you really need it.

               

              Freeman