Todd Nist wrote:
Thanks for the assistance and suggestion.  I created a separate simple
custom loader as you suggested and everything worked.  I then looked
into the differences between the simple launcher and the one being
embedded in our application.  Not sure if you recall my post the other
day about the use of bootdelegation, I had turned on the property and
never removed it.  :o(

So simply removing it took care of the problems.

Sorry for the wasted cycles.  Your support is greatly appreciated.  I
will be sure never to use the boot delegation again.  ;o)

Heck, I'm just happy you got it working! :-)

-> richard

Regards,
Todd
-----Original Message-----
From: Richard S. Hall [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 26, 2007 8:23 AM
To: [email protected]
Subject: Re: Class load error with embedded bundle



Todd Nist wrote:
Richard,

Sure, I will be glad to.  The only problem is that the embedded
instance
is inside of an ear that is deployed in to a J2EE application server,
JBoss or OC4J.  There is a servlet that is defined in the web.xml that
starts up the embedded instance of Felix and binds the Activator
associated with Felix to the JNDI tree for access by EJBs. Do you have JBoss installed?
It is a maven build process so I can issue a clean before packaging it
up.  I will get it zipped up now just let me know  if you still want
it
based on the linkage with EJBs.

Actually, no, I don't have any EE stuff on my machine...if you can tell me explicitly what I need to do to get it all working, then I am willing

to look into it. However, it will probably take me more time to do in this case since I cannot just quickly look at it...

Would it be possible to reproduce in a smaller fashion by just creating a simple custom launcher?

-> richard

Regards,
Todd

-----Original Message-----
From: Richard S. Hall [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 26, 2007 8:01 AM
To: [email protected]
Subject: Re: Class load error with embedded bundle

Would it be possible for you to zip your embedded setup into a single directory that I can extract and execute it so that I can see the
issue
for myself?

If so, please send it to me privately...

-> richard

Todd Nist wrote:
Richard,

I started Felix as you suggested, deployed and started the bundles in
question:

Welcome to Felix.
=================

Enter profile name: test2

DEBUG: WIRE: 1.0 -> org.osgi.service.packageadmin ->
DEBUG: WIRE: 1.0 -> org.osgi.service.startlevel -> 0
DEBUG: WIRE: 1.0 -> org.ungoverned.osgi.service.shel
DEBUG: WIRE: 1.0 -> org.osgi.framework -> 0
DEBUG: WIRE: 1.0 -> org.apache.felix.shell -> 1.0
DEBUG: WIRE: 2.0 -> org.osgi.framework -> 0
DEBUG: WIRE: 2.0 -> org.apache.felix.shell -> 1.0
-> DEBUG: WIRE: 3.0 -> org.osgi.service.obr -> 3.0
DEBUG: WIRE: 3.0 -> org.osgi.framework -> 0
DEBUG: WIRE: 3.0 -> org.apache.felix.shell -> 1.0
DEBUG: WIRE: 4.0 -> org.osgi.framework -> 0
Starting the ESP BaseBundleActivator:
DEBUG: WIRE: 5.0 -> org.osgi.framework -> 0
DEBUG: WIRE: 6.0 -> org.osgi.framework -> 0
DEBUG: WIRE: 7.0 -> com.lggi.esp.serviceimpl -> 7.0
DEBUG: WIRE: 7.0 -> com.lggi.esp.osgi.services -> 5.0
DEBUG: WIRE: 7.0 -> org.osgi.framework -> 0
DEBUG: WIRE: 7.0 -> com.lggi.esp.osgi.entity -> 6.0
DEBUG: WIRE: 7.0 -> com.lggi.esp.osgi -> 4.0
Starting the ESP BaseBundleActivator:
Starting the ServiceImplActivator
shutdown
-> Stopping the BaseBundleActivator:
Stopping the ServiceImplActivator
Stopping the BaseBundleActivator:

In the embedded environment, the bundles com.lggi.esp.osgi.entity and
com.lggi.esp.osgi.services are part of the
org.osgi.framework.system.packages:

    configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES,
        "org.osgi.framework; version=1.3.0,"
        + "org.osgi.service.packageadmin; version=1.2.0,"
        + "org.osgi.service.startlevel; version=1.0.0,"
        + "org.osgi.service.url; version=1.0.0,"
        + "com.lggi.esp.osgi.services; version=1.0.0,"
        + "com.lggi.esp.osgi.entity; version=1.0.0");

The other two bundles, com.lggi.esp.services and
com.lggi.esp.serviceimpl, are deployed as part of the AUTO_START_PROP

configMap.put(FelixConstants.AUTO_START_PROP +
".1","file:///D:\\development\\Brunswick-Maven\\spike\\embedded-osgi\\co
m.lggi.esp.osgi\\target\\osgi-base-1.0.0.jar "
         +

"file:///D:\\development\\Brunswick-Maven\\spike\\embedded-osgi\\Leica-O
SGi-ServiceImpl-Bundle\\target\\osgi-service-impl-1.0.0.jar");

The manifest for the com.lggi.esp.osgi looks as follows:

    Manifest-Version: 1.0
    Bundle-ManifestVersion: 2
    Bundle-Name: com.lggi.esp.osgi
    Bundle-SymbolicName: com.lggi.esp.osgi
    Bundle-Version: 1.0.0
    Bundle-Activator: com.lggi.esp.osgi.BaseBundleActivator
    Bundle-Localization: plugin
    Export-Package: com.lggi.esp.osgi
    Import-Package: org.osgi.framework;version="1.3.0"

All that is in the export package, com.lggi.esp.osgi, is a class,
BaseBundleActivator that is being extended by the
ServiceImplBundleActivator in the com.lggi.esp.serviceimpl bundle.
The
planed purpose of the BaseBundleActivator is to encapsulate logic
that
is specific to our application and make it available to sub types.
As
shown earlier, the manifest looks like this for the
com.lggi.esp.serviceimpl bundle:

    Manifest-Version: 1.0
    Bundle-ManifestVersion: 2
    Bundle-Name: Leica Service Implementation
    Bundle-SymbolicName: com.lggi.esp.serviceimpl
    Bundle-Version: 1.0.0
    Bundle-Localization: plugin
    Bundle-Activator:
com.lggi.esp.serviceimpl.ServiceImplBundleActivator
    Export-Package: com.lggi.esp.serviceimpl
    Import-Package: com.lggi.esp.serviceimpl,
     com.lggi.esp.osgi,
     com.lggi.esp.osgi.entity,
     com.lggi.esp.osgi.services,
     org.osgi.framework;version="1.3.0"

The ServiceImplBundleActivator class looks as follows:

package com.lggi.esp.serviceimpl;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;

import com.lggi.esp.osgi.BaseBundleActivator;

import com.lggi.esp.osgi.services.UserManager;
/**
 * Activator class for the plugin.
 * @author admin
 */
public class ServiceImplBundleActivator extends BaseBundleActivator {
        /**
* */
    private static final long serialVersionUID =
9037128141796077810L;
    /**
         * Attribute specifying context attribute.
         */
        private BundleContext context = null;
        /**
         * Attribute for service registration.
         */
        private ServiceRegistration serRegistration = null;
        
    /**
     * Method to start the bundle.
     */
    public void start(BundleContext context){
        super.start(context);
        System.out.println("Starting the ServiceImplActivator");
        this.context = context;
        UserManagerImpl impl = new UserManagerImpl();
        //Register the property lookup service and save
        //the service registration.
        serRegistration = context.registerService(
        UserManager.class.getName(), impl, null);
    }
        /**
         * Method to stop the bundle.
         */
    public void stop(BundleContext context) {
        super.stop(context);
        System.out.println("Stopping the ServiceImplActivator");
        serRegistration.unregister ();
        context = null;         
    }
    /**
     * Method to get the bundle context.
     * @return BundleContext object.
     */
    public BundleContext getContext() {
        return context;
    }
}

The BaseBundleActivator class from bundle com.lggi.esp.osgi looks as
follows:

package com.lggi.esp.osgi;


import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceListener;

import java.io.Serializable;

/**
 * Base Activator to access OSGi bundle context.
 * @author admin
 *
 */
public class BaseBundleActivator implements BundleActivator,
ServiceListener, Serializable {
    /**
* */
    private static final long serialVersionUID =
-4834198125321168105L;
    /**
     * Attribute specifying context attribute.
     */
    private BundleContext context = null;
/**
     * Method to start the bundle.
     */
    public void start(BundleContext p_Context) {
        System.out.println("Starting the ESP BaseBundleActivator:");
        context = p_Context;
    }
/**
     * Method to stop the bundle.
     */
    public void stop(BundleContext p_Context) {
        System.out.println("Stopping the BaseBundleActivator:");
        context = null;
    }
/**
     * Method to get the bundle context.
     * @return BundleContext object.
     */
    public BundleContext getContext() {
        return context;
    }
/**
     * Method to get all bundles in the OSGi registry.
     */
    public Bundle[] getAllBundles() {
        return context.getBundles();
    }
/**
     * Implements ServiceListener.serviceChanged().
     * Prints the details of any service event from the framework.
     * @param event the fired service event.
    **/
    public void serviceChanged(ServiceEvent event) {
        String[] objectClass = (String[])

event.getServiceReference().getProperty("objectClass");
if (event.getType() == ServiceEvent.REGISTERED) {
            System.out.println(
                "Ex1: Service of type " + objectClass[0] + "
registered.");
        } else if (event.getType() == ServiceEvent.UNREGISTERING) {
            System.out.println(
                "Ex1: Service of type " + objectClass[0] + "
unregistered.");
        } else if (event.getType() == ServiceEvent.MODIFIED) {
            System.out.println(
                "Ex1: Service of type " + objectClass[0] + "
modified.");
        }
    }
}

Finally, the class that starts the imbedded instance of Felix looks
like
this:

package com.lggi.esp.osgi;


import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceListener;

import java.io.Serializable;

/**
 * Base Activator to access OSGi registry.
 * @author admin
 *
 */
public class BaseBundleActivator implements BundleActivator,
ServiceListener, Serializable {
    /**
* */
    private static final long serialVersionUID =
-4834198125321168105L;
    /**
     * Attribute specifying context attribute.
     */
    private BundleContext context = null;
/**
     * Method to start the bundle.
     */
    public void start(BundleContext p_Context) {
        System.out.println("Starting the ESP BaseBundleActivator:");
        context = p_Context;
    }
/**
     * Method to stop the bundle.
     */
    public void stop(BundleContext p_Context) {
        System.out.println("Stopping the BaseBundleActivator:");
        context = null;
    }
/**
     * Method to get the bundle context.
     * @return BundleContext object.
     */
    public BundleContext getContext() {
        return context;
    }
/**
     * Method to get all bundles in the OSGi registry.
     */
    public Bundle[] getAllBundles() {
        return context.getBundles();
    }
/**
     * Implements ServiceListener.serviceChanged().
     * Prints the details of any service event from the framework.
     * @param event the fired service event.
    **/
    public void serviceChanged(ServiceEvent event) {
        String[] objectClass = (String[])

event.getServiceReference().getProperty("objectClass");
if (event.getType() == ServiceEvent.REGISTERED) {
            System.out.println(
                "Ex1: Service of type " + objectClass[0] + "
registered.");
        } else if (event.getType() == ServiceEvent.UNREGISTERING) {
            System.out.println(
                "Ex1: Service of type " + objectClass[0] + "
unregistered.");
        } else if (event.getType() == ServiceEvent.MODIFIED) {
            System.out.println(
                "Ex1: Service of type " + objectClass[0] + "
modified.");
        }
    }
}

Thanks in advance for the assistance.

Regards,
Todd
-----Original Message-----
From: Richard S. Hall [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 26, 2007 3:44 AM
To: [email protected]
Subject: Re: Class load error with embedded bundle

[I gave this thread a subject...]

The first question I have is, does the bundle work when deployed into
a
non-embedded Felix (i.e., from the Felix shell)?

-> richard

Todd Nist wrote:
I am having problems with deploying a bundle when embedding Felix. I
do
not believe that it has anything to do with the fact that it is
embedded.
I have the following manifest:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Leica Service Implementation
Bundle-SymbolicName: com.lggi.esp.serviceimpl
Bundle-Version: 1.0.0
Bundle-Localization: plugin
Bundle-Activator:
com.lggi.esp.serviceimpl.ServiceImplBundleActivator
Export-Package: com.lggi.esp.serviceimpl
Import-Package: com.lggi.esp.serviceimpl,
 com.lggi.esp.osgi,
 com.lggi.esp.osgi.entity,
 com.lggi.esp.osgi.services,
 org.osgi.framework;version="1.3.0"

I have validated that the jar file containing the bundle does in
fact
contain the class
"com.lggi.esp.serviceimpl.ServiceImplBundleActivator".
When I go to deploy this bundle I get the following exception:

17:01:46,036 INFO  [STDOUT] ---Starting up Felix OSGi Container
18---
17:01:46,192 INFO  [STDOUT] Starting the BaseBundleActivator:
17:01:46,302 INFO  [STDOUT] DEBUG: WIRE: 1.0 -> org.osgi.framework
->
0
17:01:46,302 INFO  [STDOUT] Starting the ESP BaseBundleActivator:
17:01:46,302 INFO  [STDOUT] DEBUG: WIRE: 2.0 ->
com.lggi.esp.serviceimpl
-> 2.0
17:01:46,302 INFO  [STDOUT] DEBUG: WIRE: 2.0 ->
com.lggi.esp.osgi.services -> 0
17:01:46,302 INFO  [STDOUT] DEBUG: WIRE: 2.0 -> org.osgi.framework
->
0
17:01:46,302 INFO  [STDOUT] DEBUG: WIRE: 2.0 ->
com.lggi.esp.osgi.entity
-> 0
17:01:46,302 INFO  [STDOUT] DEBUG: WIRE: 2.0 -> com.lggi.esp.osgi ->
1.0
17:01:46,302 INFO  [STDOUT] WARNING: *** Package
'com.lggi.esp.serviceimpl' is i
mported by bundle 2 from bundle 2, but the exported package from
bundle
2 does n
ot contain the requested class
'com.lggi.esp.serviceimpl.ServiceImplBundleActiva
tor'. Please verify that the class name is correct in the importing
bundle 2 and
/or that the exported package is correctly bundled in 2. ***
(java.lang.ClassNot
FoundException: *** Package 'com.lggi.esp.serviceimpl' is imported
by
bundle 2 f
rom bundle 2, but the exported package from bundle 2 does not
contain
the reques
ted class 'com.lggi.esp.serviceimpl.ServiceImplBundleActivator'.
Please
verify t
hat the class name is correct in the importing bundle 2 and/or that
the
exported
 package is correctly bundled in 2. ***)
17:01:46,302 INFO  [STDOUT] ERROR: Error starting
file:///D:\development\Brunswi

ck-Maven\spike\embedded-osgi\Leica-OSGi-ServiceImpl-Bundle\target\osgi-s
ervice-i
mpl-1.0.0.jar (org.osgi.framework.BundleException: Not found:
com.lggi.esp.servi
ceimpl.ServiceImplBundleActivator)
17:01:46,302 ERROR [STDERR] java.lang.ClassNotFoundException:
com.lggi.esp.servi
ceimpl.ServiceImplBundleActivator
17:01:46,302 ERROR [STDERR]     at
org.apache.felix.framework.Felix.createBundle
Activator(Felix.java:3242)
17:01:46,302 ERROR [STDERR]     at
org.apache.felix.framework.Felix._startBundle
(Felix.java:1304)
17:01:46,302 ERROR [STDERR]     at
org.apache.felix.framework.Felix.startBundle(
Felix.java:1243)
17:01:46,302 ERROR [STDERR]     at
org.apache.felix.framework.Felix.setFramework
StartLevel(Felix.java:838)
17:01:46,302 ERROR [STDERR]     at
org.apache.felix.framework.StartLevelImpl.run
(StartLevelImpl.java:256)
17:01:46,302 ERROR [STDERR]     at
java.lang.Thread.run(Thread.java:595)
17:01:46,317 INFO  [STDOUT] value =
osgi-server-ear-0.5/OSGiControllerBean/remot
e
17:01:46,317 INFO  [STDOUT] {JNDI NAME =
osgi-server-ear-0.5/OSGiControllerBean/
remote }
17:01:46,458 INFO  [STDOUT] Total No of Bundles deployed
[EJBContainer]:
[ 3 ]
17:01:46,458 INFO  [STDOUT] Bundle Name =>
org.apache.felix.framework
state => 3
2
17:01:46,458 INFO  [STDOUT] Bundle Name => com.lggi.esp.osgi state
=>
32
17:01:46,458 INFO  [STDOUT] Bundle Name => com.lggi.esp.serviceimpl
state => 4


If I crack open the bundle, I can see the class at:

osgi-service-impl-1.0.0.jar\com\lggi\esp\serviceimpl\ServiceImplBundleAc
tivator.class


Any ideas on what is going on here?

Regards,
Todd


Reply via email to