Rob Anderson
Rob Anderson

Reputation: 2407

OSGi - Activator can't access internal packages of the Bundle

I'm trying to run a small EMF-based application on Apache Felix. Felix is running on a Android Device. I'm using Eclipse but without bnd and without maven.

I got a EMF Bundle that exports the packages of:

org.eclipse.emf.common_droid-2.7.0.v20120127-1122.jar
org.eclipse.emf.ecore_droid-2.7.0.v20120127-1122.jar
org.eclipse.emf.ecore.xmi_droid-2.7.0.v20120127-1122.jar

The Structure of my Plugin-Project:

[+] src
---> com.androidosgi.notifier
---> com.androidosgi.notifier.notification
---> com.androidosgi.notifier.notification.impl
---> com.androidosgi.notifier.notification.util
[+] META-INF
---> MANIFEST.MF
Notification-1.0.ecore
Notification-1.0.ecorediag
Notification-1.0.ecorert
NotificationComponent.xmi

The Activator is in com.androidosgi.notifier.

The MANIFEST.MF:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Notification Testing
Bundle-SymbolicName: com.androidosgi.notifier
Bundle-Version: 12.6.5
Bundle-Activator: com.androidosgi.notifier.Activator
Bundle-Vendor: Homer Simpson
Import-Package: 
 com.androidosgi.notifier.notification,
 com.androidosgi.notifier.notification.impl,
 com.androidosgi.notifier.notification.util,
 org.eclipse.emf.common,
 org.eclipse.emf.common.archive,
 org.eclipse.emf.common.command,
 org.eclipse.emf.common.notify,
 org.eclipse.emf.common.notify.impl,
 org.eclipse.emf.common.util,
 org.eclipse.emf.ecore,
 org.eclipse.emf.ecore.impl,
 org.eclipse.emf.ecore.plugin,
 org.eclipse.emf.ecore.resource,
 org.eclipse.emf.ecore.resource.impl,
 org.eclipse.emf.ecore.util,
 org.eclipse.emf.ecore.xmi,
 org.eclipse.emf.ecore.xmi.impl,
 org.eclipse.emf.ecore.xmi.util,
 org.eclipse.emf.ecore.xml.namespace,
 org.eclipse.emf.ecore.xml.namespace.impl,
 org.eclipse.emf.ecore.xml.namespace.util,
 org.eclipse.emf.ecore.xml.type,
 org.eclipse.emf.ecore.xml.type.impl,
 org.eclipse.emf.ecore.xml.type.internal,
 org.eclipse.emf.ecore.xml.type.util,
 org.osgi.framework;version="1.3.0"
Bundle-ClassPath: .
Export-Package: com.androidosgi.notifier;x-internal:=true,
 com.androidosgi.notifier.notification;x-internal:=true,
 com.androidosgi.notifier.notification.impl;x-internal:=true,
 com.androidosgi.notifier.notification.util;x-internal:=true

Before I installed the bundle on the OSGi, I "dexed" it and added the classes.dex to the bundle.

If I try to start i get: NoClassDefFoundError enter image description here

Any ideas or solutions ? :) Thanks

Upvotes: 0

Views: 787

Answers (3)

Rob Anderson
Rob Anderson

Reputation: 2407

Ok 50% is done ;-) It is running on a computer (Java 1.6) (but still not on Android) ! The NoClassDefFoundError Error caused in my case by the missing versioning stuff. I added the version in every package in the exporting EMF-Bundle(b1). I also added the version ranges on every package at the importing Notifier-Bundle(b2). Looks like that is very important to set the versions. I also removed:

com.androidosgi.notifier.notification, com.androidosgi.notifier.notification.impl, com.androidosgi.notifier.notification.util,

from the imports of the Bundle(b2) and all export from (b2). Its running now on Apache Felix.

Uhh, I also added

Import-Package: org.xml.sax.helpers;version="[0.0.0.1_006_JavaSE,3.0.0)"

to the manifest of the Bundle (b1), the EMF-Bundle.

My next problem is that the exports of the standard systembundle in android seems to be diffrent as it is on a normal computer (used the command "headers" to find out). I will start a new Question for that an post the link here.

Upvotes: 0

pooh
pooh

Reputation: 662

I suppose you have already checked the obvious things: * The class NotificationFactory is present inside the bundle * There are no typos in the name and path * The class is not in an internal jar or smth like that * The activator is found successfully by the system? * You have tried removing the imports?

The only more bizarre thing I can propose to check is whether maybe the problem is not with NotificationFactory itself, but with some class it uses. I've had such cases in other setups where the ClassNotFound was actually for another class inside the reported class.

Try for example moving the activator in the com.androidosgi.notifier.notification package - just as a check whether it will be found at all. In this way you will know whether the problem is with the package or with the class itself.

Upvotes: 0

Neil Bartlett
Neil Bartlett

Reputation: 23958

EMF will not run on Felix, or any OSGi framework other than Equinox. See the following bug that I raised about this a long time ago: https://bugs.eclipse.org/bugs/show_bug.cgi?id=328227

You have to use a re-packaging of EMF that does the OSGi declarations properly. I have this on GitHub but it is slightly stale now, i.e. it packages an old version of EMF. See: https://github.com/njbartlett/emf-osgi

UPDATE: I was too hasty, that probably wasn't the right answer. It looks like you already repackaged EMF.

I suspect that the answer is you're importing the package com.androidosgi.notifier.notification and its subpackages, but those are probably packages inside your bundle. You should not import packages that are actually part of your bundle.

Upvotes: 0

Related Questions