[sip-comm-dev] java.lang.NullPointerException, bundleContext = null


#1

Hi! I created Search.java class inside net.java.sip.communicator.launcher.
This class uses SIPAccountRegWizard.signin(userName, passWord) so I copied
the classes of net.java.sip.communicator.plugin.sipaacregwizz into
net.java.sip.communicator.launcher because importing
net.java.sip.communicator.plugin.sipaacregwizz gives an NoClassDefError.
Now the problem is it's throwing a java.lang.NullPointerException on the
RED line:

// code inside public class SIPAccRegWizzActivator
public static ProtocolProviderFactory getSIPProtocolProviderFactory() throws
Exception
    {

        ServiceReference[] serRefs = null;

        String osgiFilter =
            "(" + ProtocolProviderFactory.PROTOCOL + "=" + ProtocolNames.SIP
                + ")";
        System.out.println("osgiFilter in .getSIPProtProviderFactory=");
        System.out.println(osgiFilter);

        System.out.println("check value of bundleContext ==");
        System.out.println(bundleContext);

        try
        {
            System.out.println("check PPF.class.getname()");
            System.out.println(ProtocolProviderFactory.class.getName());
            //serRefs =bundleContext.getServiceReferences(null, osgiFilter);
            //System.out.println(serRefs);
            serRefs
=bundleContext.getServiceReferences(ProtocolProviderFactory.class.getName(),
osgiFilter);
            .........................

Apparently, the bundleContext is null..
Can anyone help me please..
Thanks!


#2

Hey matet,

The code that you extracted from the SIP account wizard is meant to run
inside OSGi and moving it to the launcher package is therefore going to
break it.

You should think about turning your extension into an OSGi bundle instead.

Hope this helps
Emil

matet sacro-lacap wrote:

···

Hi! I created Search.java class inside net.java.sip.communicator.launcher.
This class uses SIPAccountRegWizard.signin(userName, passWord) so I
copied the classes of net.java.sip.communicator.plugin.sipaacregwizz
into net.java.sip.communicator.launcher because importing
net.java.sip.communicator.plugin.sipaacregwizz gives an
NoClassDefError. Now the problem is it's throwing a
java.lang.NullPointerException on the RED line:

// code inside public class SIPAccRegWizzActivator
public static ProtocolProviderFactory getSIPProtocolProviderFactory()
throws Exception
    {

        ServiceReference[] serRefs = null;

        String osgiFilter =
            "(" + ProtocolProviderFactory.PROTOCOL + "=" + ProtocolNames.SIP
                + ")";
        System.out.println("osgiFilter in .getSIPProtProviderFactory=");
        System.out.println(osgiFilter);

        System.out.println("check value of bundleContext ==");
        System.out.println(bundleContext);

        try
        {
            System.out.println("check PPF.class.getname()");
            System.out.println(ProtocolProviderFactory.class.getName());
            //serRefs =bundleContext.getServiceReferences(null, osgiFilter);
            //System.out.println(serRefs);
            serRefs
=bundleContext.getServiceReferences(ProtocolProviderFactory.class.getName(),
osgiFilter);
            .........................

Apparently, the bundleContext is null..
Can anyone help me please..
Thanks!

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#3

Thanks a lot. I'll do that..

···

On Fri, Feb 27, 2009 at 2:24 PM, Emil Ivov <emcho@sip-communicator.org>wrote:

Hey matet,

The code that you extracted from the SIP account wizard is meant to run
inside OSGi and moving it to the launcher package is therefore going to
break it.

You should think about turning your extension into an OSGi bundle instead.

Hope this helps
Emil

matet sacro-lacap wrote:
> Hi! I created Search.java class inside
net.java.sip.communicator.launcher.
> This class uses SIPAccountRegWizard.signin(userName, passWord) so I
> copied the classes of net.java.sip.communicator.plugin.sipaacregwizz
> into net.java.sip.communicator.launcher because importing
> net.java.sip.communicator.plugin.sipaacregwizz gives an
> NoClassDefError. Now the problem is it's throwing a
> java.lang.NullPointerException on the RED line:
>
> // code inside public class SIPAccRegWizzActivator
> public static ProtocolProviderFactory getSIPProtocolProviderFactory()
> throws Exception
> {
>
> ServiceReference[] serRefs = null;
>
> String osgiFilter =
> "(" + ProtocolProviderFactory.PROTOCOL + "=" +
ProtocolNames.SIP
> + ")";
> System.out.println("osgiFilter in .getSIPProtProviderFactory=");
> System.out.println(osgiFilter);
>
>
> System.out.println("check value of bundleContext ==");
> System.out.println(bundleContext);
>
> try
> {
> System.out.println("check PPF.class.getname()");
> System.out.println(ProtocolProviderFactory.class.getName());
> //serRefs =bundleContext.getServiceReferences(null,
osgiFilter);
> //System.out.println(serRefs);
> serRefs
>
=bundleContext.getServiceReferences(ProtocolProviderFactory.class.getName(),
> osgiFilter);
> .........................
>
> Apparently, the bundleContext is null..
> Can anyone help me please..
> Thanks!
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#4

Thanks! Now its working.. :slight_smile:
there's just a bit of a prob.. I was able to connect with Mysql before when
my codes are in net.java.comm.launcher but now that my codes are in
.plugin.sipaccregwizz, I can't connect to the database anymore.. It's giving
me the java.lang.ClassNotFoundException: com.mysql.jdbc.Driver error..

I have already included the mysql connector bin.jar in the lib directory and
in the classpath.. :frowning:

···

On Fri, Feb 27, 2009 at 2:24 PM, Emil Ivov <emcho@sip-communicator.org>wrote:

Hey matet,

The code that you extracted from the SIP account wizard is meant to run
inside OSGi and moving it to the launcher package is therefore going to
break it.

You should think about turning your extension into an OSGi bundle instead.

Hope this helps
Emil

matet sacro-lacap wrote:
> Hi! I created Search.java class inside
net.java.sip.communicator.launcher.
> This class uses SIPAccountRegWizard.signin(userName, passWord) so I
> copied the classes of net.java.sip.communicator.plugin.sipaacregwizz
> into net.java.sip.communicator.launcher because importing
> net.java.sip.communicator.plugin.sipaacregwizz gives an
> NoClassDefError. Now the problem is it's throwing a
> java.lang.NullPointerException on the RED line:
>
> // code inside public class SIPAccRegWizzActivator
> public static ProtocolProviderFactory getSIPProtocolProviderFactory()
> throws Exception
> {
>
> ServiceReference[] serRefs = null;
>
> String osgiFilter =
> "(" + ProtocolProviderFactory.PROTOCOL + "=" +
ProtocolNames.SIP
> + ")";
> System.out.println("osgiFilter in .getSIPProtProviderFactory=");
> System.out.println(osgiFilter);
>
>
> System.out.println("check value of bundleContext ==");
> System.out.println(bundleContext);
>
> try
> {
> System.out.println("check PPF.class.getname()");
> System.out.println(ProtocolProviderFactory.class.getName());
> //serRefs =bundleContext.getServiceReferences(null,
osgiFilter);
> //System.out.println(serRefs);
> serRefs
>
=bundleContext.getServiceReferences(ProtocolProviderFactory.class.getName(),
> osgiFilter);
> .........................
>
> Apparently, the bundleContext is null..
> Can anyone help me please..
> Thanks!
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net