-
1. Re: Adding external jar files to OSGI bundle (Getting NoClassDefFountError)
bosschaert Jul 26, 2012 6:51 AM (in response to raghu.ganapam)1 of 1 people found this helpfulHi Raghu,
I just tried this out with the attached BundleUsingEmbeddedJar_1.0.0.jar and it works fine for me. When the bundle is started I'm seeing the code in the embedded jar correctly being invoked:
{code}11:44:53,744 INFO [stdout] (management-handler-thread - 4) In activator of bundle embedding jar
11:44:53,744 INFO [stdout] (management-handler-thread - 4) Invoking someOtherMethod(){code}
the output Invoking someOtherMethod() comes out of the embedded jar.
The attached bundle contains its source code too ... hope it works for you as well.
-
2. Re: Adding external jar files to OSGI bundle (Getting NoClassDefFountError)
thomas.diesler Jul 26, 2012 8:10 AM (in response to raghu.ganapam)You can turn on DEBUG log and show us what's happening. If there is nothing obvious, turn on TRACE logging for org.jboss.modules. This gives you very low level classloading details. It is possible that your class cannot get defined for some reason, in which case the CNFE might not point to the root of the problem.
-
3. Re: Adding external jar files to OSGI bundle (Getting NoClassDefFountError)
raghu.ganapam Jul 27, 2012 6:33 AM (in response to bosschaert)Thank you very much David,
Now my bundle is able to access jars, but we are getting below exception when we try to call webservice. i would like to attach complete bundle with source code and also attach the complete server output but not able to do attachments , could you please help me how to attach a jar.
Pasting entire log here, sorry for the inconvience. Please help me
Calling "C:\Raghu Personal on 10.140.1.218\Mobile\OpenSource\jboss-as-7.1.1.Final\jboss-as-7.1.1.Final\bin\standalone.conf.bat"
===============================================================================JBoss Bootstrap Environment
JBOSS_HOME: C:\Raghu Personal on 10.140.1.218\Mobile\OpenSource\jboss-as-7.1.1.Final\jboss-as-7.1.1.Final
JAVA: C:\Program Files\Java\jdk1.6.0_21\bin\java
JAVA_OPTS: -XX:+TieredCompilation -Dprogram.name=standalone.bat -Xms64M -Xmx512M -XX:MaxPermSize=256M -Dsun.rmi.dgc.client.gcInterval=3600000
-Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djb
oss.server.default.config=standalone.xml===============================================================================
15:35:12,485 INFO [org.jboss.modules] JBoss Modules version 1.1.1.GA
15:35:12,610 INFO [org.jboss.msc] JBoss MSC version 1.0.2.GA
15:35:12,657 INFO [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting
15:35:13,313 INFO [org.xnio] XNIO Version 3.0.3.GA
15:35:13,313 INFO [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
15:35:13,329 INFO [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
15:35:13,329 INFO [org.jboss.remoting] JBoss Remoting version 3.2.3.GA
15:35:13,344 INFO [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
15:35:13,391 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 31) JBAS010280: Activating Infinispan subsystem.
15:35:13,407 INFO [org.jboss.as.configadmin] (ServerService Thread Pool -- 26) JBAS016200: Activating ConfigAdmin Subsystem
15:35:13,407 INFO [org.jboss.as.security] (ServerService Thread Pool -- 44) JBAS013101: Activating Security Subsystem
15:35:13,407 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem
15:35:13,422 INFO [org.jboss.as.osgi] (ServerService Thread Pool -- 39) JBAS011940: Activating OSGi Subsystem
15:35:13,454 INFO [org.jboss.as.connector] (MSC service thread 1-1) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)
15:35:13,454 INFO [org.jboss.as.security] (MSC service thread 1-5) JBAS013100: Current PicketBox version=4.0.7.Final
15:35:13,422 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
15:35:13,516 INFO [org.jboss.as.naming] (MSC service thread 1-3) JBAS011802: Starting Naming Service
15:35:13,516 INFO [org.jboss.as.mail.extension] (MSC service thread 1-1) JBAS015400: Bound mail session [java:jboss/mail/Default]
15:35:13,641 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver classorg.h2.Driver (version 1.3)
15:35:13,704 INFO [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-7) Starting Coyote HTTP/1.1 on http--127.0.0.1-8080
15:35:13,735 INFO [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-2) JBoss Web Services - Stack CXF Server 4.0.2.GA
15:35:13,969 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-8) JBAS015012: Started FileSystemDeploymentService for directory C:\RaghuPersonal on 10.140.1.218\Mobile\OpenSource\jboss-as-7.1.1.Final\jboss-as-7.1.1.Final\standalone\deployments
15:35:13,969 INFO [org.jboss.as.remoting] (MSC service thread 1-1) JBAS017100: Listening on /127.0.0.1:4447
15:35:13,969 INFO [org.jboss.as.remoting] (MSC service thread 1-4) JBAS017100: Listening on /127.0.0.1:9999
15:35:14,172 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
15:35:14,188 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015876: Starting deployment of "raghuosgi2.jar"
15:35:14,250 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-4) JBossOSGi Framework Core - 1.1.8.Final
15:35:14,282 INFO [org.jboss.as] (MSC service thread 1-5) JBAS015951: Admin console listening on http://127.0.0.1:9990
15:35:14,282 ERROR [org.jboss.as] (MSC service thread 1-5) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 1985ms - Started 151 of 227services (1 services failed or missing dependencies, 74 services are passive or on-demand)
15:35:14,672 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-6) Install bundle: system.bundle:0.0.0
15:35:14,938 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-3) Install bundle: javax.transaction.api:0.0.0
15:35:14,985 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-6) Install bundle: org.apache.felix.log:1.0.0
15:35:14,985 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-2) Install bundle: jboss-osgi-logging:1.0.0
15:35:15,016 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-4) Install bundle: jbosgi-http-api:1.0.5
15:35:15,016 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-1) Install bundle: jboss-as-osgi-configadmin:7.1.1.Final
15:35:15,032 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-7) Install bundle: org.apache.felix.configadmin:1.2.8
15:35:15,344 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-5) Install bundle: osgi.enterprise:4.2.0.201003190513
15:35:15,438 INFO [org.jboss.osgi.framework.internal.StartLevelPlugin] (MSC service thread 1-2) Starting bundles for start level: 1
15:35:15,454 INFO [org.jboss.osgi.framework.internal.HostBundleState] (MSC service thread 1-2) Bundle started: jbosgi-http-api:1.0.5
15:35:15,454 INFO [org.jboss.osgi.framework.internal.HostBundleState] (MSC service thread 1-2) Bundle started: osgi.enterprise:4.2.0.201003190513
15:35:15,454 INFO [org.jboss.osgi.framework.internal.HostBundleState] (MSC service thread 1-2) Bundle started: jboss-as-osgi-configadmin:7.1.1.Final
15:35:15,454 INFO [org.jboss.osgi.framework.internal.HostBundleState] (MSC service thread 1-2) Bundle started: jboss-osgi-logging:1.0.0
15:35:15,469 INFO [org.jboss.osgi.framework.internal.HostBundleState] (MSC service thread 1-2) Bundle started: org.apache.felix.log:1.0.0
15:35:15,469 INFO [org.jboss.osgi.framework.internal.HostBundleState] (MSC service thread 1-2) Bundle started: javax.transaction.api:0.0.0
15:35:15,485 INFO [org.jboss.osgi.framework.internal.HostBundleState] (MSC service thread 1-2) Bundle started: org.apache.felix.configadmin:1.2.8
15:35:15,485 INFO [org.jboss.osgi.framework.internal.FrameworkActive] (MSC service thread 1-2) OSGi Framework started
15:35:15,501 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-4) Install bundle: RaghuOSGI:1.0.0.qualifier
15:35:15,813 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "raghuosgi2.jar"
15:35:15,907 INFO [stdout] (MSC service thread 1-4) Raghu OSGI
15:35:15,907 WARN [org.jboss.modules] (MSC service thread 1-4) Failed to define class org.apache.axis.client.Service in Module"deployment.RaghuOSGI:1.0.0.qualifier" from Service Module Loader: java.lang.LinkageError: Failed to link org/apache/axis/client/Service (Module
"deployment.RaghuOSGI:1.0.0
.qualifier" from Service Module Loader)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:396)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:243)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:73)
at org.jboss.modules.FilteredLocalLoader.loadClassLocal(FilteredLocalLoader.java:46)
at org.jboss.modules.Module.loadModuleClass(Module.java:517)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:182)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.6.0_21]
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) [rt.jar:1.6.0_21]
at java.lang.ClassLoader.defineClass(ClassLoader.java:616) [rt.jar:1.6.0_21]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) [rt.jar:1.6.0_21]
at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:327)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:391)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:243)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:73)
at org.jboss.modules.FilteredLocalLoader.loadClassLocal(FilteredLocalLoader.java:46)
at org.jboss.modules.Module.loadModuleClass(Module.java:517)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:182)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
at raghuosgi.Activator.start(Activator.java:34)
at org.jboss.osgi.framework.internal.HostBundleState.transitionToActive(HostBundleState.java:300)
at org.jboss.osgi.framework.internal.HostBundleState.startInternal(HostBundleState.java:223)
at org.jboss.osgi.framework.internal.AbstractBundleState.start(AbstractBundleState.java:494)
at org.jboss.as.osgi.deployment.BundleStartTracker$1.processService(BundleStartTracker.java:144)
at org.jboss.as.osgi.deployment.BundleStartTracker$1.transition(BundleStartTracker.java:119)
at org.jboss.msc.service.ServiceControllerImpl.invokeListener(ServiceControllerImpl.java:1416)
at org.jboss.msc.service.ServiceControllerImpl.access$2700(ServiceControllerImpl.java:49)
at org.jboss.msc.service.ServiceControllerImpl$ListenerTask.run(ServiceControllerImpl.java:1954)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_21]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_21]
at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_21]
Caused by: java.lang.NoClassDefFoundError: javax/naming/Referenceable
at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.6.0_21]
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) [rt.jar:1.6.0_21]
at java.lang.ClassLoader.defineClass(ClassLoader.java:616) [rt.jar:1.6.0_21]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) [rt.jar:1.6.0_21]
at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:327)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:391)
... 39 more
Caused by: java.lang.ClassNotFoundException: javax.naming.Referenceable from [Module "deployment.RaghuOSGI:1.0.0.qualifier" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
... 45 more15:35:16,063 WARN [org.jboss.modules] (MSC service thread 1-4) Failed to define class com.qwest.qci.wlws.InventoryService_ServiceLocator in Module
"deployment.RaghuOSGI:1.0.0.qualifier" from Service Module Loader: java.lang.LinkageError: Failed to link com/qwest/qci/wlws/InventoryService_ServiceLoc
ator (Module "deployment.RaghuOSGI:1.0.0.qualifier" from Service Module Loader)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:396)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:243)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:73)
at org.jboss.modules.FilteredLocalLoader.loadClassLocal(FilteredLocalLoader.java:46)
at org.jboss.modules.Module.loadModuleClass(Module.java:517)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:182)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
at raghuosgi.Activator.start(Activator.java:34)
at org.jboss.osgi.framework.internal.HostBundleState.transitionToActive(HostBundleState.java:300)
at org.jboss.osgi.framework.internal.HostBundleState.startInternal(HostBundleState.java:223)
at org.jboss.osgi.framework.internal.AbstractBundleState.start(AbstractBundleState.java:494)
at org.jboss.as.osgi.deployment.BundleStartTracker$1.processService(BundleStartTracker.java:144)
at org.jboss.as.osgi.deployment.BundleStartTracker$1.transition(BundleStartTracker.java:119)
at org.jboss.msc.service.ServiceControllerImpl.invokeListener(ServiceControllerImpl.java:1416)
at org.jboss.msc.service.ServiceControllerImpl.access$2700(ServiceControllerImpl.java:49)
at org.jboss.msc.service.ServiceControllerImpl$ListenerTask.run(ServiceControllerImpl.java:1954)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_21]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_21]
at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_21]
Caused by: java.lang.NoClassDefFoundError: org/apache/axis/client/Service
at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.6.0_21]
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) [rt.jar:1.6.0_21]
at java.lang.ClassLoader.defineClass(ClassLoader.java:616) [rt.jar:1.6.0_21]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) [rt.jar:1.6.0_21]
at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:327)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:391)
... 22 more
Caused by: java.lang.ClassNotFoundException: org.apache.axis.client.Service from [Module "deployment.RaghuOSGI:1.0.0.qualifier" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
... 28 more15:35:16,188 ERROR [org.jboss.as.osgi] (MSC service thread 1-4) JBAS011900: Cannot start bundle: RaghuOSGI:1.0.0.qualifier:
org.osgi.framework.BundleException: Cannot start bundle: RaghuOSGI:1.0.0.qualifier
at org.jboss.osgi.framework.internal.HostBundleState.transitionToActive(HostBundleState.java:328) [jbosgi-framework-core-1.1.8.Final.jar:1.1.8.Final]
at org.jboss.osgi.framework.internal.HostBundleState.startInternal(HostBundleState.java:223) [jbosgi-framework-core-1.1.8.Final.jar:1.1.8.Final]
at org.jboss.osgi.framework.internal.AbstractBundleState.start(AbstractBundleState.java:494) [jbosgi-framework-core-1.1.8.Final.jar:1.1.8.Final]
at org.jboss.as.osgi.deployment.BundleStartTracker$1.processService(BundleStartTracker.java:144) [jboss-as-osgi-service-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.osgi.deployment.BundleStartTracker$1.transition(BundleStartTracker.java:119) [jboss-as-osgi-service-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl.invokeListener(ServiceControllerImpl.java:1416) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl.access$2700(ServiceControllerImpl.java:49) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$ListenerTask.run(ServiceControllerImpl.java:1954) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_21]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_21]
at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_21]
Caused by: java.lang.NoClassDefFoundError: com/qwest/qci/wlws/InventoryService_ServiceLocator
at raghuosgi.Activator.start(Activator.java:34)
at org.jboss.osgi.framework.internal.HostBundleState.transitionToActive(HostBundleState.java:300) [jbosgi-framework-core-1.1.8.Final.jar:1.1.8.Final]
... 10 more
Caused by: java.lang.ClassNotFoundException: com.qwest.qci.wlws.InventoryService_ServiceLocator from [Module "deployment.RaghuOSGI:1.0.0.qualifier" fromService Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.1.GA]
... 12 moreRegards,
Raghu Ganapam
-
4. Re: Adding external jar files to OSGI bundle (Getting NoClassDefFountError)
raghu.ganapam Jul 27, 2012 6:45 AM (in response to raghu.ganapam)adding MANIFEST.mf and code
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: RaghuOSGI
Bundle-SymbolicName: RaghuOSGI
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: raghuosgi.Activator
Import-Package: org.osgi.framework;version="1.3.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ClassPath: jboss-jaxrpc-api_1.1_spec-1.0.1.Final-redhat-1.jar,axis-1.4.1.jar,qciwsclient.jar,wsdl4j.jar,commons-logging-1.1.1.jar,commons-discovery-0.2.jar,.package raghuosgi;
import java.net.URL;
import java.util.List;import javax.xml.namespace.QName;
import javax.xml.rpc.Stub;
import javax.xml.rpc.handler.HandlerInfo;
import javax.xml.rpc.handler.HandlerRegistry;import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;import com.qwest.qci.wlws.InventoryServiceSoapBindingStub;
import com.qwest.qci.wlws.InventoryService_Service;
import com.qwest.qci.wlws.InventoryService_ServiceLocator;
import com.qwest.qcinv.serviceobject.InventoryRequestSO;
import com.qwest.qcinv.serviceobject.InventoryResponseSO;public class Activator implements BundleActivator {
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
System.out.println("Raghu OSGI");
InventoryServiceSoapBindingStub stub = null;
InventoryService_Service qciService = null;
String endPoint = "http://qctrl-itv2.dev.qintra.com/qcinvService/InventoryService";
try {
InventoryService_ServiceLocator locator = new InventoryService_ServiceLocator();
HandlerRegistry hr = locator.getHandlerRegistry();
QName portName = new QName("http://qctrl-itv2.dev.qintra.com/qcinvService/InventoryService", "CmfProfileAccessSoapPort");
List handlerChain = hr.getHandlerChain(portName);
HandlerInfo hi = new HandlerInfo();
//hi.setHandlerClass(ArtisSoapHandler.class);
handlerChain.add(hi);
hr.setHandlerChain(portName, handlerChain);
if (endPoint != "") {
//locator.setCmfProfileAccessSoapPortEndpointAddress(endPoint);
locator.setInventoryServiceSoapPortEndpointAddress(endPoint);
}
URL wsdlURL = new URL("http://qctrl-itv2.dev.qintra.com/qcinvService/InventoryService?wsdl");
if (locator.getInventoryServiceSoapPort().getClass() == InventoryServiceSoapBindingStub.class) {
stub = (InventoryServiceSoapBindingStub) locator.getInventoryServiceSoapPort(wsdlURL);
stub._setProperty("axis.connection.timeout", 60000);
if (endPoint != "") {
stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, endPoint);
}
}
InventoryRequestSO tollFreeRequest = new InventoryRequestSO();
InventoryResponseSO tollfreeResponse = stub.getInventorySummary(tollFreeRequest);
} catch (Exception e) {
e.printStackTrace();
}
}
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
System.out.println("Goodbye World!!");
}}
-
5. Re: Adding external jar files to OSGI bundle (Getting NoClassDefFountError)
bosschaert Jul 27, 2012 7:41 AM (in response to raghu.ganapam)This may not solve all of your exceptions, but I see the following:
Caused by: java.lang.ClassNotFoundException: javax.naming.Referenceable from [Module "deployment.RaghuOSGI:1.0.0.qualifier" from Service Module Loader]
This is caused by the fact that you don't import this package. javax subpackages need to be imported just like any other package if they are not provided by the bundle itself, so you need to change your manifest to:
Import-Package: javax.naming,org.osgi.framework
-
6. Re: Adding external jar files to OSGI bundle (Getting NoClassDefFountError)
raghu.ganapam Jul 27, 2012 9:30 AM (in response to bosschaert)Thanks for your reply. i have added required packages in MANIFEST
Import-Package: org.w3c.dom,org.w3c.dom.bootstrap,org.w3c.dom.css,org.w3c.dom.events,org.w3c.dom.html,org.w3c.dom.ls,org.w3c.dom.ranges,org.w3c.dom.stylesheets,org.w3c.dom.traversal,org.w3c.dom.views,org.w3c.dom.xpath,javax.naming,javax.naming.directory,javax.naming.event,javax.naming.ldap,javax.naming.spi, org.osgi.framework;version="1.3.0"
Now i am getting below exception. Please help.
18:52:54,633 INFO [org.jboss.as.remoting] (MSC service thread 1-3) JBAS017100: Listening on /127.0.0.1:9999
18:52:54,836 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
18:52:54,852 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015876: Starting deployment of "raghuosgi9.jar"
18:52:54,961 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-4) JBossOSGi Framework Core - 1.1.8.Final
18:52:54,992 INFO [org.jboss.as] (MSC service thread 1-6) JBAS015951: Admin console listening on http://127.0.0.1:9990
18:52:54,992 ERROR [org.jboss.as] (MSC service thread 1-6) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 2062ms - Started 151 of 227 services (1 services failed or missing dependencies, 74 services are passive or on-demand)
18:52:55,367 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-3) Install bundle: system.bundle:0.0.0
18:52:55,680 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-2) Install bundle: javax.transaction.api:0.0.0
18:52:55,680 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-3) Install bundle: jboss-osgi-logging:1.0.0
18:52:55,695 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-4) Install bundle: org.apache.felix.log:1.0.0
18:52:55,695 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-7) Install bundle: jboss-as-osgi-configadmin:7.1.1.Final
18:52:55,727 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-8) Install bundle: org.apache.felix.configadmin:1.2.8
18:52:55,727 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-5) Install bundle: jbosgi-http-api:1.0.5
18:52:55,977 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-1) Install bundle: osgi.enterprise:4.2.0.201003190513
18:52:56,102 INFO [org.jboss.osgi.framework.internal.StartLevelPlugin] (MSC service thread 1-6) Starting bundles for start level: 1
18:52:56,102 INFO [org.jboss.osgi.framework.internal.HostBundleState] (MSC service thread 1-6) Bundle started: jbosgi-http-api:1.0.5
18:52:56,102 INFO [org.jboss.osgi.framework.internal.HostBundleState] (MSC service thread 1-6) Bundle started: osgi.enterprise:4.2.0.201003190513
18:52:56,102 INFO [org.jboss.osgi.framework.internal.HostBundleState] (MSC service thread 1-6) Bundle started: jboss-as-osgi-configadmin:7.1.1.Final
18:52:56,117 INFO [org.jboss.osgi.framework.internal.HostBundleState] (MSC service thread 1-6) Bundle started: jboss-osgi-logging:1.0.0
18:52:56,117 INFO [org.jboss.osgi.framework.internal.HostBundleState] (MSC service thread 1-6) Bundle started: org.apache.felix.log:1.0.0
18:52:56,117 INFO [org.jboss.osgi.framework.internal.HostBundleState] (MSC service thread 1-6) Bundle started: javax.transaction.api:0.0.0
18:52:56,180 INFO [org.jboss.osgi.framework.internal.HostBundleState] (MSC service thread 1-6) Bundle started: org.apache.felix.configadmin:1.2.8
18:52:56,180 INFO [org.jboss.osgi.framework.internal.FrameworkActive] (MSC service thread 1-6) OSGi Framework started
18:52:56,195 INFO [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-8) Install bundle: RaghuOSGI:1.0.0.qualifier
18:52:56,227 ERROR [org.jboss.osgi.framework.internal.FrameworkEventsPlugin] (MSC service thread 1-2) Framework ERROR: org.osgi.framework.BundleException: Cannot resolve bundle resModule: [RaghuOSGI:1.0.0.qualifier]
at org.jboss.osgi.framework.internal.ResolverPlugin.resolve(ResolverPlugin.java:157) [jbosgi-framework-core-1.1.8.Final.jar:1.1.8.Final]
at org.jboss.osgi.framework.internal.AbstractBundleState.ensureResolved(AbstractBundleState.java:551) [jbosgi-framework-core-1.1.8.Final.jar:1.1.8.Final]
at org.jboss.osgi.framework.internal.HostBundleState.startInternal(HostBundleState.java:211) [jbosgi-framework-core-1.1.8.Final.jar:1.1.8.Final]
at org.jboss.osgi.framework.internal.AbstractBundleState.start(AbstractBundleState.java:494) [jbosgi-framework-core-1.1.8.Final.jar:1.1.8.Final]
at org.jboss.as.osgi.deployment.BundleStartTracker$1.processService(BundleStartTracker.java:144) [jboss-as-osgi-service-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.osgi.deployment.BundleStartTracker$1.transition(BundleStartTracker.java:119) [jboss-as-osgi-service-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl.invokeListener(ServiceControllerImpl.java:1416) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl.access$2700(ServiceControllerImpl.java:49) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$ListenerTask.run(ServiceControllerImpl.java:1954) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_21]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_21]
at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_21]
Caused by: org.jboss.osgi.resolver.XResolverException: Unable to resolve Module[RaghuOSGI:1.0.0.qualifier]: missing requirement [Module[RaghuOSGI:1.0.0.qualifier]] package; (package=org.w3c.dom.css)
at org.jboss.osgi.resolver.felix.FelixResolver.resolveInternal(FelixResolver.java:117) [jbosgi-resolver-felix-1.0.13.Final.jar:1.0.13.Final]
at org.jboss.osgi.resolver.spi.AbstractResolver.resolve(AbstractResolver.java:149) [jbosgi-resolver-spi-1.0.13.Final.jar:1.0.13.Final]
at org.jboss.osgi.framework.internal.ResolverPlugin.resolve(ResolverPlugin.java:155) [jbosgi-framework-core-1.1.8.Final.jar:1.1.8.Final]
... 11 more
18:52:56,258 ERROR [org.jboss.as.osgi] (MSC service thread 1-2) JBAS011900: Cannot start bundle: RaghuOSGI:1.0.0.qualifier: org.osgi.framework.BundleException: Cannot resolve bundle: RaghuOSGI:1.0.0.qualifier
at org.jboss.osgi.framework.internal.HostBundleState.startInternal(HostBundleState.java:212) [jbosgi-framework-core-1.1.8.Final.jar:1.1.8.Final]
at org.jboss.osgi.framework.internal.AbstractBundleState.start(AbstractBundleState.java:494) [jbosgi-framework-core-1.1.8.Final.jar:1.1.8.Final]
at org.jboss.as.osgi.deployment.BundleStartTracker$1.processService(BundleStartTracker.java:144) [jboss-as-osgi-service-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.osgi.deployment.BundleStartTracker$1.transition(BundleStartTracker.java:119) [jboss-as-osgi-service-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl.invokeListener(ServiceControllerImpl.java:1416) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl.access$2700(ServiceControllerImpl.java:49) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$ListenerTask.run(ServiceControllerImpl.java:1954) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_21]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_21]
at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_21]
18:52:56,258 ERROR [RaghuOSGI] (Thread-66) FrameworkEvent ERROR: org.apache.felix.log.LogException: org.osgi.framework.BundleException: Cannot resolve bundle resModule: [RaghuOSGI:1.0.0.qualifier]
at org.jboss.osgi.framework.internal.ResolverPlugin.resolve(ResolverPlugin.java:157)
at org.jboss.osgi.framework.internal.AbstractBundleState.ensureResolved(AbstractBundleState.java:551)
at org.jboss.osgi.framework.internal.HostBundleState.startInternal(HostBundleState.java:211)
at org.jboss.osgi.framework.internal.AbstractBundleState.start(AbstractBundleState.java:494)
at org.jboss.as.osgi.deployment.BundleStartTracker$1.processService(BundleStartTracker.java:144)
at org.jboss.as.osgi.deployment.BundleStartTracker$1.transition(BundleStartTracker.java:119)
at org.jboss.msc.service.ServiceControllerImpl.invokeListener(ServiceControllerImpl.java:1416)
at org.jboss.msc.service.ServiceControllerImpl.access$2700(ServiceControllerImpl.java:49)
at org.jboss.msc.service.ServiceControllerImpl$ListenerTask.run(ServiceControllerImpl.java:1954)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_21]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_21]
at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_21]
Caused by: org.apache.felix.log.LogException: org.jboss.osgi.resolver.XResolverException: Unable to resolve Module[RaghuOSGI:1.0.0.qualifier]: missing requirement [Module[RaghuOSGI:1.0.0.qualifier]] package; (package=org.w3c.dom.css)
at org.jboss.osgi.resolver.felix.FelixResolver.resolveInternal(FelixResolver.java:117)
at org.jboss.osgi.resolver.spi.AbstractResolver.resolve(AbstractResolver.java:149)
at org.jboss.osgi.framework.internal.ResolverPlugin.resolve(ResolverPlugin.java:155)
... 11 more
18:52:56,352 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "raghuosgi9.jar"
Regards,
Raghu Ganapam
-
7. Re: Adding external jar files to OSGI bundle (Getting NoClassDefFountError)
bosschaert Jul 27, 2012 9:36 AM (in response to raghu.ganapam)Hi Raghu,
You're importing the org.w3c.dom.css package, so you need a bundle that provides this package. While the JRE provides some org.w3c.dom.* packages, it does not provide this one AFAIK.
David
-
8. Re: Adding external jar files to OSGI bundle (Getting NoClassDefFountError)
raghu.ganapam Jul 30, 2012 10:40 AM (in response to bosschaert)Hi David,
Thanks for your reply.
Now i am getting below excpetion. i am trying to call webservice by using axis2 client code. To import required packages in MANIFEST, I am not seeing Axis2 packages. It is showing only axis packages.. Could you please help me how to resolve this. Thanks in advance.
17:13:43,439 INFO [stdout] (HttpManagementService-threads - 8) Hello World!!
17:13:43,439 WARN [org.jboss.modules] (HttpManagementService-threads - 8) Failed to define class com.qwest.www.webservices
etollfree/MobileAppStub (Module "deployment.CallPlanJar:1.0.0" from Service Module Loader)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:396)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:243)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:73)
at org.jboss.modules.FilteredLocalLoader.loadClassLocal(FilteredLocalLoader.java:46)
at org.jboss.modules.FilteredLocalLoader.loadClassLocal(FilteredLocalLoader.java:46)
at org.jboss.modules.Module.loadModuleClass(Module.java:527)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:182)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
at callplan.Activator.start(Activator.java:17)
at org.jboss.osgi.framework.internal.HostBundleState.transitionToActive(HostBundleState.java:321)
at org.jboss.osgi.framework.internal.HostBundleState.startInternal(HostBundleState.java:245)
at org.jboss.osgi.framework.internal.AbstractBundleState.start(AbstractBundleState.java:485)
at org.jboss.as.osgi.management.BundleResourceHandler.handleOperation(BundleResourceHandler.java:145)
at org.jboss.as.osgi.management.BundleResourceHandler.executeRuntimeStep(BundleResourceHandler.java:99)
at org.jboss.as.controller.AbstractRuntimeOnlyHandler$1.execute(AbstractRuntimeOnlyHandler.java:90)
at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:397)
at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:284)
at org.jboss.as.controller.AbstractOperationContext.completeStep(AbstractOperationContext.java:211)
at org.jboss.as.controller.ModelControllerImpl$DefaultPrepareStepHandler.execute(ModelControllerImpl.java:473)
at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:397)
at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:284)
at org.jboss.as.controller.AbstractOperationContext.completeStep(AbstractOperationContext.java:211)
at org.jboss.as.controller.ModelControllerImpl.internalExecute(ModelControllerImpl.java:126)
at org.jboss.as.controller.ModelControllerImpl.execute(ModelControllerImpl.java:111)
at org.jboss.as.controller.ModelControllerImpl$1.execute(ModelControllerImpl.java:316)
at org.jboss.as.controller.ModelControllerImpl$1.execute(ModelControllerImpl.java:306)
at org.jboss.as.domain.http.server.DomainApiHandler.processRequest(DomainApiHandler.java:319)
at org.jboss.as.domain.http.server.DomainApiHandler.doHandle(DomainApiHandler.java:225)
at org.jboss.as.domain.http.server.DomainApiHandler.handle(DomainApiHandler.java:232)
at org.jboss.as.domain.http.server.security.SubjectAssociationHandler.handle(SubjectAssociationHandler.java:51)
at org.jboss.com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:78)
at org.jboss.sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:69)
at org.jboss.com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:81)
at org.jboss.sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:710)
at org.jboss.com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:78)
at org.jboss.as.domain.http.server.RealmReadinessFilter.doFilter(RealmReadinessFilter.java:54)
at org.jboss.com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:81)
at org.jboss.sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:682)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_21]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_21]
at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_21]
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: java.lang.NoClassDefFoundError: org/apache/axis2/client/Stub
at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.6.0_21]
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) [rt.jar:1.6.0_21]
at java.lang.ClassLoader.defineClass(ClassLoader.java:616) [rt.jar:1.6.0_21]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) [rt.jar:1.6.0_21]
at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:327)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:391)
... 45 more
Caused by: java.lang.ClassNotFoundException: org.apache.axis2.client.Stub from [Module "deployment.CallPlanJar:1.0.0" from
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
... 51 more
Regards,
Raghu
-
9. Re: Adding external jar files to OSGI bundle (Getting NoClassDefFountError)
bosschaert Aug 6, 2012 3:28 PM (in response to raghu.ganapam)Hi Raghu,
So your code needs the org.apache.axis2.client.Stub class. Following good OSGi practise it should Import-Package the org.apache.axis2.client package and you should deploy a bundle that exports this package.
As you have been embedding jars, this would also be an option, although I would recommend using the Import-Package approach.
I would recommend taking a look at the OSGi tutorials here: http://www.osgi.org/Technology/HowOSGi or alternatively the book 'OSGi in Action' has a lot of detail on how the OSGi classloading works: http://www.manning.com/hall/