[sip-comm-dev] LinkageError...


#1

Hello devs,

I'm trying to override Felix OBR to add some functionnalities. Whenever I
try to implement a specific OSGi interface, I get linkage errors.
For example, I made a class called SCRepositoryAdminImpl implementing
RepositoryAdmin. If I override addRepository, I'll get this linkage error:

java.lang.LinkageError: loader constraint violation in interface itable
initialization: when resolving method
"net.java.sip.communicator.impl.bundlerepository.SCRepositoryAdminImpl.addRepository(Ljava/net/URL;)Lorg/osgi/service/obr/Repository;"
the class loader (instance of
org/apache/felix/framework/searchpolicy/ContentClassLoader) of the current
class,
net/java/sip/communicator/impl/bundlerepository/SCRepositoryAdminImpl, and
the class loader (instance of
org/apache/felix/framework/searchpolicy/ContentClassLoader) for interface
org/osgi/service/obr/RepositoryAdmin have different Class objects for the
type org/osgi/service/obr/Repository used in the signature

If instead of implementing RepositoryAdmin, I extend RepositoryAdminImpl
(From Felix), I won't get any linkage error.

Same thing happens if I make a class called SCReposityImpl. I will get
linkage errors if I implement Repository, but I won't if I extend
RepositoryImpl (from Felix).

Any ideas of how to solve this?

Here's what the manifest looks like:

Bundle-Activator: net.java.sip.communicator.impl.bundlerepository.Activator

Bundle-Name: Temp name

Bundle-Description: Temp desc

Bundle-Vendor: sip-communicator.org

Bundle-Version: 0.0.1

Export-Package: net.java.sip.communicator.service.bundlerepository

Import-Package: org.osgi.framework,

net.java.sip.communicator.service.bundlerepository,

org.apache.felix.bundlerepository,

org.osgi.service.obr

(I put the interfaces in the service package and my implementations in impl
package)

Thank you very much.


#2

I forgot to write the stack trace. Here it goes:

···

[*java*] java.lang.LinkageError: loader constraint violation in interface
itable initialization: when resolving method
"net.java.sip.communicator.impl.bundlerepository.SCRepositoryAdminImpl.addRepository(Ljava/net/URL;)Lorg/osgi/service/obr/Repository;"
the class loader (instance of
org/apache/felix/framework/searchpolicy/ContentClassLoader) of the current
class,
net/java/sip/communicator/impl/bundlerepository/SCRepositoryAdminImpl, and
the class loader (instance of
org/apache/felix/framework/searchpolicy/ContentClassLoader) for interface
org/osgi/service/obr/RepositoryAdmin have different Class objects for the
type org/osgi/service/obr/Repository used in the signature

[*java*] at
net.java.sip.communicator.impl.bundlerepository.Activator.start(*
Activator.java:19*)

[*java*] ERROR: Error starting
reference:file:sc-bundles/bundlerepository.jar (*
org.osgi.framework.BundleException*: Activator start error.)

[*java*] at org.apache.felix.framework.util.SecureAction.startActivator(*
SecureAction.java:589*)

[*java*] at org.apache.felix.framework.Felix._startBundle(*Felix.java:1536
*)

[*java*] at org.apache.felix.framework.Felix.startBundle(*Felix.java:1470*
)

[*java*] at org.apache.felix.framework.Felix.setFrameworkStartLevel(*
Felix.java:1065*)

[*java*] at org.apache.felix.framework.StartLevelImpl.run(*
StartLevelImpl.java:258*)

[*java*] at java.lang.Thread.run(*Thread.java:619*)

2008/6/14 Mathieu Plourde <mat.plourde@gmail.com>:

Hello devs,

I'm trying to override Felix OBR to add some functionnalities. Whenever I
try to implement a specific OSGi interface, I get linkage errors.
For example, I made a class called SCRepositoryAdminImpl implementing
RepositoryAdmin. If I override addRepository, I'll get this linkage error:

java.lang.LinkageError: loader constraint violation in interface itable
initialization: when resolving method
"net.java.sip.communicator.impl.bundlerepository.SCRepositoryAdminImpl.addRepository(Ljava/net/URL;)Lorg/osgi/service/obr/Repository;"
the class loader (instance of
org/apache/felix/framework/searchpolicy/ContentClassLoader) of the current
class,
net/java/sip/communicator/impl/bundlerepository/SCRepositoryAdminImpl, and
the class loader (instance of
org/apache/felix/framework/searchpolicy/ContentClassLoader) for interface
org/osgi/service/obr/RepositoryAdmin have different Class objects for the
type org/osgi/service/obr/Repository used in the signature

If instead of implementing RepositoryAdmin, I extend RepositoryAdminImpl
(From Felix), I won't get any linkage error.

Same thing happens if I make a class called SCReposityImpl. I will get
linkage errors if I implement Repository, but I won't if I extend
RepositoryImpl (from Felix).

Any ideas of how to solve this?

Here's what the manifest looks like:

Bundle-Activator:
net.java.sip.communicator.impl.bundlerepository.Activator

Bundle-Name: Temp name

Bundle-Description: Temp desc

Bundle-Vendor: sip-communicator.org

Bundle-Version: 0.0.1

Export-Package: net.java.sip.communicator.service.bundlerepository

Import-Package: org.osgi.framework,

net.java.sip.communicator.service.bundlerepository,

org.apache.felix.bundlerepository,

org.osgi.service.obr

(I put the interfaces in the service package and my implementations in
impl package)

Thank you very much.


#3

It sounds like you have the same classes visible from two different class loaders. Try to double check to make sure that the OBR packages are only visible from one source (e.g., exposed from the class path or embedded in your bundle).

-> richard

Mathieu Plourde wrote:

···

Hello devs,
I'm trying to override Felix OBR to add some functionnalities. Whenever I try to implement a specific OSGi interface, I get linkage errors.
For example, I made a class called SCRepositoryAdminImpl implementing RepositoryAdmin. If I override addRepository, I'll get this linkage error:

    java.lang.LinkageError: loader constraint violation in interface
    itable initialization: when resolving method
    "net.java.sip.communicator.impl.bundlerepository.SCRepositoryAdminImpl.addRepository(Ljava/net/URL;)Lorg/osgi/service/obr/Repository;"
    the class loader (instance of
    org/apache/felix/framework/searchpolicy/ContentClassLoader) of the
    current class,
    net/java/sip/communicator/impl/bundlerepository/SCRepositoryAdminImpl,
    and the class loader (instance of
    org/apache/felix/framework/searchpolicy/ContentClassLoader) for
    interface org/osgi/service/obr/RepositoryAdmin have different
    Class objects for the type org/osgi/service/obr/Repository used in
    the signature

If instead of implementing RepositoryAdmin, I extend RepositoryAdminImpl (From Felix), I won't get any linkage error.
Same thing happens if I make a class called SCReposityImpl. I will get linkage errors if I implement Repository, but I won't if I extend RepositoryImpl (from Felix).
Any ideas of how to solve this?
Here's what the manifest looks like:

    Bundle-Activator:
    net.java.sip.communicator.impl.bundlerepository.Activator

    Bundle-Name: Temp name

    Bundle-Description: Temp desc

    Bundle-Vendor: sip-communicator.org <http://sip-communicator.org>

    Bundle-Version: 0.0.1

    Export-Package: net.java.sip.communicator.service.bundlerepository

    Import-Package: org.osgi.framework,

    net.java.sip.communicator.service.bundlerepository,

    org.apache.felix.bundlerepository,

    org.osgi.service.obr

  (I put the interfaces in the service package and my implementations in impl package)
Thank you very much.

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