concept exception in category osgi

appears as: n exception, exception, exception, An exception, exceptions
OSGi in Depth

This is an excerpt from Manning's book OSGi in Depth.

The helloworld.client2 bundle isn’t able to import the package manning.osgi.helloworld.client. You’ll get an exception when you try to use a class whose package hasn’t been exported, even though you try to import it. Thus, we can validate that the code is indeed restricted.

Figure 4.10. Bundle client_1.0.0 gets the same class Parent from two different bundles and thus likely causes an exception.

Continuing with our scenario, let’s say that you want the log auditor to inform the credit score application when it fails to log the login request event, thus indicating that the credit score application should stop. To accomplish this, could the log auditor just raise an exception? No, an exception raised by a subscriber is caught by the EventAdmin, which may log it, but otherwise simply moves on to the next subscriber in the list, as shown in figure 6.10.

Figure 6.10. An exception from a subscriber doesn’t stop the dispatching of events.
public void start(BundleContext bundleContext) throws Exception {

    BundleListener bundleListener = // ...

    bundleContext.addBundleListener(bundleListener);

    // ...
}
OSGi in Action: Creating Modular Applications in Java

This is an excerpt from Manning's book OSGi in Action: Creating Modular Applications in Java.

  • If the class is from a package starting with java., the parent class loader is asked for the class. If the class is found, it’s used. If there is no such class, the search ends with an exception.
  • If the class is from a package imported by the bundle, the framework asks the exporting bundle for the class. If the class is found, it’s used. If there is no such class, the search ends with an exception.
  • The bundle class path is searched for the class. If it’s found, it’s used. If there is no such class, the search ends with an exception.
  • The first thing you should do when debugging a class-loading exception is look and see if the exception is ClassNotFoundException or NoClassDefFoundError. A subtle difference between these two types will help you understand why the exception occurred and how to fix it.

    Exception occurred: java.lang.NullPointerException (uncaught)
        "thread=AWT-EventQueue-0", java.awt.EventDispatchThread.run(),
            line=156 bci=152
    
    AWT-EventQueue-0[1] where
    
      [1] java.awt.EventDispatchThread.run (EventDispatchThread.java:156)