[jitsi-dev] Creating bundle to use MetaContactListService


#1

Hi!

I have a small problem with creating own custom bundle which uses
MetaContactListService. I created this class with uses BundleActivator
interface :

public class CustomActivator2 implements BundleActivator {

    public static BundleContext bundleContext;
    private static MetaContactListService metaContactListService;

    public void start(BundleContext bc) throws Exception {
        CustomActivator2.bundleContext = bc;
        try {
            metaContactListService = new MetaContactListServiceImpl();

bundleContext.registerService(MetaContactListService.class.getName(),
metaContactListService, null);
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }

    public void stop(BundleContext bc) throws Exception {
    }

    public static MetaContactListService getMetaContastList() {
        if (metaContactListService == null) {
            metaContactListService
                    = ServiceUtils.getService(
                            bundleContext,
                            MetaContactListService.class);
        }
        return metaContactListService;
    }
}

I also added a few lines to build.xml like this one :

    <!--BUNDLE-CUSTOM-->
    <target name="bundle-custom">
        <jar compress="false" destfile="${bundles.dest}/custom.jar"

manifest="${src}/net/java/sip/communicator/impl/custom/custom.manifest.mf">

            <zipfileset dir="${dest}/net/java/sip/communicator/impl/custom"
                            prefix="net/java/sip/communicator/impl/custom"/>
        </jar>
    </target>

During the Jitsi start and invoking this bundle i receive this message :

java.lang.NoClassDefFoundError:
net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl
     [java] at
net.java.sip.communicator.impl.custom.CustomActivator2.start(CustomActivator2.java:29)
     [java] at
org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:629)
     [java] at
org.apache.felix.framework.Felix.activateBundle(Felix.java:1904)
     [java] at org.apache.felix.framework.Felix.startBundle(Felix.java:1822)
     [java] at
org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1192)
     [java] at
org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:266)
     [java] at java.lang.Thread.run(Thread.java:745)
     [java] Caused by: java.lang.ClassNotFoundException:
net.java.sip.communicator.impl.contactlist.MetaContactListServiceImpl not
found by net.java.sip.communicator.custom [198]
     [java] at
org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:812)
     [java] at
org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:72)
     [java] at
org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1807)
     [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

When I add missing import net.java.sip.communicator.impl.contactlist to
manifest file I receive this message :

org.osgi.framework.BundleException: Unresolved constraint in bundle
net.java.sip.communicator.custom [198]: Unable to resolve 198.0: missing
requirement [198.0] package;
(package=net.java.sip.communicator.impl.contactlist)
     [java] at
org.apache.felix.framework.Felix.resolveBundle(Felix.java:3564)
     [java] at org.apache.felix.framework.Felix.startBundle(Felix.java:1797)
     [java] at
org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1192)
     [java] at
org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:266)
     [java] at java.lang.Thread.run(Thread.java:745)
     [java] ERROR: Bundle net.java.sip.communicator.custom [198] Error
starting reference:file:sc-bundles/custom.jar
(org.osgi.framework.BundleException: Unresolved constraint in bundle
net.java.sip.communicator.custom [198]: Unable to resolve 198.0: missing
requirement [198.0] package;
(package=net.java.sip.communicator.impl.contactlist))

There is any work around how to make this bundle to work and be able to get
contacts from Jitsi using MetaContactListService. Much appreciated for any
help!

Best regards,
Łukasz


#2

Hi,

you are importing the wrong pakage. Metacontact list service is
registered with package:
net.java.sip.communicator.service.contactlist. (The same package you
have imported in the Activator class).
If your plugin bundle loads before the contaclist one, you will need a
service changed listener to wait for registering of the contact list,
there are plenty of examples in the code for both, the import and the
service changed listener.

Regards
damencho

···

On Tue, Apr 29, 2014 at 11:31 AM, Lukasz Ciesluk <lukaszciesluk@gmail.com> wrote:

Hi!

I have a small problem with creating own custom bundle which uses
MetaContactListService. I created this class with uses BundleActivator
interface :

public class CustomActivator2 implements BundleActivator {

    public static BundleContext bundleContext;
    private static MetaContactListService metaContactListService;

    public void start(BundleContext bc) throws Exception {
        CustomActivator2.bundleContext = bc;
        try {
            metaContactListService = new MetaContactListServiceImpl();

bundleContext.registerService(MetaContactListService.class.getName(),
metaContactListService, null);
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }

    public void stop(BundleContext bc) throws Exception {
    }

    public static MetaContactListService getMetaContastList() {
        if (metaContactListService == null) {
            metaContactListService
                    = ServiceUtils.getService(
                            bundleContext,
                            MetaContactListService.class);
        }
        return metaContactListService;
    }
}

I also added a few lines to build.xml like this one :

    <!--BUNDLE-CUSTOM-->
    <target name="bundle-custom">
        <jar compress="false" destfile="${bundles.dest}/custom.jar"

manifest="${src}/net/java/sip/communicator/impl/custom/custom.manifest.mf">

            <zipfileset dir="${dest}/net/java/sip/communicator/impl/custom"
                            prefix="net/java/sip/communicator/impl/custom"/>
        </jar>
    </target>

During the Jitsi start and invoking this bundle i receive this message :

java.lang.NoClassDefFoundError:
net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl
     [java] at
net.java.sip.communicator.impl.custom.CustomActivator2.start(CustomActivator2.java:29)
     [java] at
org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:629)
     [java] at
org.apache.felix.framework.Felix.activateBundle(Felix.java:1904)
     [java] at org.apache.felix.framework.Felix.startBundle(Felix.java:1822)
     [java] at
org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1192)
     [java] at
org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:266)
     [java] at java.lang.Thread.run(Thread.java:745)
     [java] Caused by: java.lang.ClassNotFoundException:
net.java.sip.communicator.impl.contactlist.MetaContactListServiceImpl not
found by net.java.sip.communicator.custom [198]
     [java] at
org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:812)
     [java] at
org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:72)
     [java] at
org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1807)
     [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

When I add missing import net.java.sip.communicator.impl.contactlist to
manifest file I receive this message :

org.osgi.framework.BundleException: Unresolved constraint in bundle
net.java.sip.communicator.custom [198]: Unable to resolve 198.0: missing
requirement [198.0] package;
(package=net.java.sip.communicator.impl.contactlist)
     [java] at
org.apache.felix.framework.Felix.resolveBundle(Felix.java:3564)
     [java] at org.apache.felix.framework.Felix.startBundle(Felix.java:1797)
     [java] at
org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1192)
     [java] at
org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:266)
     [java] at java.lang.Thread.run(Thread.java:745)
     [java] ERROR: Bundle net.java.sip.communicator.custom [198] Error
starting reference:file:sc-bundles/custom.jar
(org.osgi.framework.BundleException: Unresolved constraint in bundle
net.java.sip.communicator.custom [198]: Unable to resolve 198.0: missing
requirement [198.0] package;
(package=net.java.sip.communicator.impl.contactlist))

There is any work around how to make this bundle to work and be able to get
contacts from Jitsi using MetaContactListService. Much appreciated for any
help!

Best regards,
Łukasz

_______________________________________________
dev mailing list
dev@jitsi.org
Unsubscribe instructions and other list options:
http://lists.jitsi.org/mailman/listinfo/dev