Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8858587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:51:50+00:00 2026-06-14T14:51:50+00:00

(EDIT: Problem is solved – see details at the end) I want to create

  • 0

(EDIT: Problem is solved – see details at the end)

I want to create a Swing JFrame with a WindowAdapter in an OSGi Bundle. When I do this using SwingUtilities.invokeLater, the WindowAdapter class is not found. Without invokeLater it works.

What do I need to do so that WindowAdapter is found when using invokeLater?
Is invokeLater inappropriate in an OSGi environment?

The details:

I start an Apache Felix framework instance with my custom launcher, install the bundle and start it. My bundle’s start method looks like this:

public void start(BundleContext arg0) throws Exception {
    myFrame = new MyFrame();
    myFrame.open();
}

This is the MyFrame class:

public class MyFrame {
    JFrame mainFrame;

    public void open() {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                openImpl();
            }
        });
        // If called like this it works:
        // openImpl();
    }

    public void openImpl() {
        mainFrame = new JFrame("Title");
        mainFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
        WindowAdapter wa = new WindowAdapter() {
        };
        mainFrame.addWindowListener(wa);
        mainFrame.setSize(800, 600);
        mainFrame.setLocationRelativeTo(null);
        mainFrame.setVisible(true);
    }
}

This is my manifest for the bundle:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.2
Created-By: 1.7.0_03-b05 (Oracle Corporation)
Built-By: Rainer Schwarze
Bundle-Name: DummyBdl
Bundle-Description: Dummy Bundle
Bundle-Vendor: admaDIC
Bundle-Version: 0.0.1
Bundle-Activator: dummybdl.Activator
Import-Package: org.osgi.framework, javax.swing
Export-Package: dummybdl.api
Export-Service: dummybdl.Provider

And this is the stack trace which I get:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1432)
    at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)
    at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    at dummybdl.MyFrame.openImpl(MyFrame.java:24)
    at dummybdl.MyFrame$1.run(MyFrame.java:16)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
    at java.awt.EventQueue.access$000(EventQueue.java:101)
    at java.awt.EventQueue$3.run(EventQueue.java:666)
    at java.awt.EventQueue$3.run(EventQueue.java:664)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Being an OSGi newbie I tried several things to fix it, but couldn’t find a solution so far. So why not make my first question at StackOverflow 🙂

EDIT:

After debugging for half an hour it turns out that the problem was entirely mine:
My code stopped the OSGi framework before openImpl gets called in the EDT.

So the Apache Felix framework marked the BundleWiringImpl instance (see stack trace) as disposed. When my openImpl gets called in the EDT, BundleWiringImpl.getClassLoader returns null because it is marked as disposed. Eventually this leads to the NPE.
(I should have gone the extra steps of posting the 50 lines of my Felix loader which might have made the error obvious.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:51:51+00:00Added an answer on June 14, 2026 at 2:51 pm

    My code stopped the OSGi framework before openImpl gets called in the EDT.

    Without invokeLater openImpl is called immediately and before my other code shuts down the OSGi framework. With invokeLater the call to openImpl is scheduled for later and before that “later” happens, my code shuts down the OSGi framework.

    In that case the Apache Felix framework marked the BundleWiringImpl instance (see stack trace) as disposed. When my openImpl gets called in the EDT, BundleWiringImpl.getClassLoader returns null because it is marked as disposed. Eventually this leads to the NPE.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: This problem has been solved. See below. Hey all. I'm building an iPhone
[EDIT: Problem solved. Please see my answer below.] In my app I call the
Edit: Problem solved I am trying to assign types using variable like this check
EDIT: Problem solved. This was (yet another) situation where the problem wasn't really where
edit: Solved - mod_rewrite was the problem I can't get CI to work as
Edit: This problem was down to me passing the wrong view to the Touch
[Edit: This problem applies only to 32-bit systems. If your computer, your OS and
EDIT: Problem solved... and unrelated to the phrasing of the question... sorry for the
[EDIT]Problem solved, I found the leak. Thank you very much. I'm running a scheduling
EDIT: Problem solved by using $i+1 in function call. I have trouble using variables

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.