[jitsi-users] Adding a jar file to Jitsi runtime classpath


#1

I have a need to add a jar file to Jitsi, and I've tried everything I can
think of in Eclipse to get it on the runtime classpath, but I suppose the
problem arises from how felix locates and loads classes. It is failing with
a ClassNotFoundException.

I found an answer on StackOverflow that sounded promising, to add my jar to
the jitsi/lib and edit nbproject/project.xml to add it to the <classpath
mode="compile"> lists, but it also refers to a jitsi.eml file that does not
seem to exist in the Jitsi project tree.

Appreciate any suggestions.

···

--
Ed Jankiewicz


#2

Hi,

Jitsi Desktop uses osgi and bundles. Every bundle loads in its own
classloader, so it doesn't have access to outside world if you don't
tell it to do that. So if you want to use something from outside the
bundle you need to import its package in the manifest. But whatever
you import must be exported somewhere. The other option is to put your
lib in the bundle you want to use it, there are plenty of examples
inside ant's build.xml.

Regards
damencho

···

On Wed, Apr 19, 2017 at 9:59 PM, Ed Jankiewicz <ejjank@gmail.com> wrote:

I have a need to add a jar file to Jitsi, and I've tried everything I can
think of in Eclipse to get it on the runtime classpath, but I suppose the
problem arises from how felix locates and loads classes. It is failing with
a ClassNotFoundException.

I found an answer on StackOverflow that sounded promising, to add my jar to
the jitsi/lib and edit nbproject/project.xml to add it to the <classpath
mode="compile"> lists, but it also refers to a jitsi.eml file that does not
seem to exist in the Jitsi project tree.

Appreciate any suggestions.

--
Ed Jankiewicz

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


#3

thanks Damian - but I think I need some more specifics.

The bundle I want to include a jar or jars into is bundle-netaddr.

do I edit the netaddr.manifest.mf I see in the
net.java.sip.communicator.impl.netaddr?

where do my jars have to be staged?

What do you mean by "must be exported somewhere?

Maybe the second suggestion is easier, but what do you mean by putting the
lib in the bundle?

···

On Thu, Apr 20, 2017 at 1:07 PM, Damian Minkov <damencho@jitsi.org> wrote:

Hi,

Jitsi Desktop uses osgi and bundles. Every bundle loads in its own
classloader, so it doesn't have access to outside world if you don't
tell it to do that. So if you want to use something from outside the
bundle you need to import its package in the manifest. But whatever
you import must be exported somewhere. The other option is to put your
lib in the bundle you want to use it, there are plenty of examples
inside ant's build.xml.

Regards
damencho

On Wed, Apr 19, 2017 at 9:59 PM, Ed Jankiewicz <ejjank@gmail.com> wrote:
> I have a need to add a jar file to Jitsi, and I've tried everything I can
> think of in Eclipse to get it on the runtime classpath, but I suppose the
> problem arises from how felix locates and loads classes. It is failing
with
> a ClassNotFoundException.
>
> I found an answer on StackOverflow that sounded promising, to add my jar
to
> the jitsi/lib and edit nbproject/project.xml to add it to the <classpath
> mode="compile"> lists, but it also refers to a jitsi.eml file that does
not
> seem to exist in the Jitsi project tree.
>
> Appreciate any suggestions.
>
> --
> Ed Jankiewicz
>
> _______________________________________________
> users mailing list
> users@jitsi.org
> Unsubscribe instructions and other list options:
> http://lists.jitsi.org/mailman/listinfo/users

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

--
Ed Jankiewicz


#4

Hi,

Look at smack lib bundle, how it includes some jars and exporting some
packages in the manifest:
https://github.com/jitsi/jitsi/blob/master/build.xml#L1447 and the
other bundles like protocol-jabber are importing packages in their
manifest file.
Check out and this bundle how it is including some jars in it:
https://github.com/jitsi/jitsi/blob/master/build.xml#L1298

There are plenty of examples inside build.xml.

Cheers
damencho

···

On Thu, Apr 20, 2017 at 4:41 PM, Ed Jankiewicz <ejjank@gmail.com> wrote:

thanks Damian - but I think I need some more specifics.

The bundle I want to include a jar or jars into is bundle-netaddr.

do I edit the netaddr.manifest.mf I see in the
net.java.sip.communicator.impl.netaddr?

where do my jars have to be staged?

What do you mean by "must be exported somewhere?

Maybe the second suggestion is easier, but what do you mean by putting the
lib in the bundle?

On Thu, Apr 20, 2017 at 1:07 PM, Damian Minkov <damencho@jitsi.org> wrote:

Hi,

Jitsi Desktop uses osgi and bundles. Every bundle loads in its own
classloader, so it doesn't have access to outside world if you don't
tell it to do that. So if you want to use something from outside the
bundle you need to import its package in the manifest. But whatever
you import must be exported somewhere. The other option is to put your
lib in the bundle you want to use it, there are plenty of examples
inside ant's build.xml.

Regards
damencho

On Wed, Apr 19, 2017 at 9:59 PM, Ed Jankiewicz <ejjank@gmail.com> wrote:
> I have a need to add a jar file to Jitsi, and I've tried everything I
> can
> think of in Eclipse to get it on the runtime classpath, but I suppose
> the
> problem arises from how felix locates and loads classes. It is failing
> with
> a ClassNotFoundException.
>
> I found an answer on StackOverflow that sounded promising, to add my jar
> to
> the jitsi/lib and edit nbproject/project.xml to add it to the <classpath
> mode="compile"> lists, but it also refers to a jitsi.eml file that does
> not
> seem to exist in the Jitsi project tree.
>
> Appreciate any suggestions.
>
> --
> Ed Jankiewicz
>
> _______________________________________________
> users mailing list
> users@jitsi.org
> Unsubscribe instructions and other list options:
> http://lists.jitsi.org/mailman/listinfo/users

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

--
Ed Jankiewicz

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


#5

Damian - thanks. I was not aware of the need for bundles in Jitsi. That
was helpful. However, I'm still going around in circles due to the
complexity of the process. I spent the last several days getting the bundle
exported from my development environment, and making enough changes to
various properties files and build files to get Jitsi to even start, but I
still get the class not found at runtime when the Jitsi code attempts to
construct the class I added.

2017-04-24 15:48:53.677 SEVERE: [556]
impl.gui.main.call.CallManager.run().2609 The call could not be created:
java.lang.NoClassDefFoundError: com/xxx/xxx/xxx/MyClass

[stack]

Caused by: java.lang.ClassNotFoundException: com.xxx.xxx.xxx.MyClass not
found by net.java.sip.communicator.netaddr [90]
at
org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1574)
at
org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79)
at
org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
[project and class name obscured for proprietary reasons]

Some details:

The Jitsi source parts I've tinkered with are
jitsi/src/net/java/sip/communicator/impl/netaddr
NetworkAddressManagerServiceImpl.java and
jitsi/src/net/java/sip/communicator/service/netaddr
NetworkAddressManagerService.java
my bundle MDGSbundle_1.0.0.jar I put in jitsi/lib/installer-exclude
in jitsi/build.xml I added a line to copy that too {bundles.dest} which is
jitsi/sc-bundles
added my class to the list in
jitsi/src/net/java/sip/communicator/service/protocol/media/protocol.media.mf
added the bundle to the classpath in nbproject/project.xml

the code in my class refers to a couple other jars, which I included in the
bundle, and listed the referenced classes under "uses" in the manifest for
the bundle.

Admittedly, I do not have a working knowledge of OSGi, but it seems like a
simple matter of getting a proper bundle built, correct manifest, and
sufficient tinkers to Jitsi properties and build files. At this point I
can't determine which of those I have hosed. Appreciate any further
suggestions.

···

On Thu, Apr 20, 2017 at 5:50 PM, Damian Minkov <damencho@jitsi.org> wrote:

Hi,

Look at smack lib bundle, how it includes some jars and exporting some
packages in the manifest:
https://github.com/jitsi/jitsi/blob/master/build.xml#L1447 and the
other bundles like protocol-jabber are importing packages in their
manifest file.
Check out and this bundle how it is including some jars in it:
https://github.com/jitsi/jitsi/blob/master/build.xml#L1298

There are plenty of examples inside build.xml.

Cheers
damencho

On Thu, Apr 20, 2017 at 4:41 PM, Ed Jankiewicz <ejjank@gmail.com> wrote:
>
> thanks Damian - but I think I need some more specifics.
>
> The bundle I want to include a jar or jars into is bundle-netaddr.
>
> do I edit the netaddr.manifest.mf I see in the
> net.java.sip.communicator.impl.netaddr?
>
> where do my jars have to be staged?
>
> What do you mean by "must be exported somewhere?
>
>
> Maybe the second suggestion is easier, but what do you mean by putting
the
> lib in the bundle?
>
>
> On Thu, Apr 20, 2017 at 1:07 PM, Damian Minkov <damencho@jitsi.org> > wrote:
>>
>> Hi,
>>
>> Jitsi Desktop uses osgi and bundles. Every bundle loads in its own
>> classloader, so it doesn't have access to outside world if you don't
>> tell it to do that. So if you want to use something from outside the
>> bundle you need to import its package in the manifest. But whatever
>> you import must be exported somewhere. The other option is to put your
>> lib in the bundle you want to use it, there are plenty of examples
>> inside ant's build.xml.
>>
>> Regards
>> damencho
>>
>>
>>
>> On Wed, Apr 19, 2017 at 9:59 PM, Ed Jankiewicz <ejjank@gmail.com> > wrote:
>> > I have a need to add a jar file to Jitsi, and I've tried everything I
>> > can
>> > think of in Eclipse to get it on the runtime classpath, but I suppose
>> > the
>> > problem arises from how felix locates and loads classes. It is failing
>> > with
>> > a ClassNotFoundException.
>> >
>> > I found an answer on StackOverflow that sounded promising, to add my
jar
>> > to
>> > the jitsi/lib and edit nbproject/project.xml to add it to the
<classpath
>> > mode="compile"> lists, but it also refers to a jitsi.eml file that
does
>> > not
>> > seem to exist in the Jitsi project tree.
>> >
>> > Appreciate any suggestions.
>> >
>> > --
>> > Ed Jankiewicz
>> >
>> > _______________________________________________
>> > users mailing list
>> > users@jitsi.org
>> > Unsubscribe instructions and other list options:
>> > http://lists.jitsi.org/mailman/listinfo/users
>>
>> _______________________________________________
>> users mailing list
>> users@jitsi.org
>> Unsubscribe instructions and other list options:
>> http://lists.jitsi.org/mailman/listinfo/users
>
>
>
>
> --
> Ed Jankiewicz
>
> _______________________________________________
> users mailing list
> users@jitsi.org
> Unsubscribe instructions and other list options:
> http://lists.jitsi.org/mailman/listinfo/users

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

--
Ed Jankiewicz