[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [xmlblaster] xmlBlaster client as OSGi bundle (eclipse plugin)



Brian Young schrieb:
> I have used xmlBlaster within OSGI based libs before in conjuction with
> Eclipse. Try switching to the context class loader b/f you access
> xmlBlaster code, and then you can switch back to the custom class loader
> afterwards.
> 
>         //need to use context class loader to make xmlBlaster happy
>         Thread current = Thread.currentThread();
>         ClassLoader oldLoader = current.getContextClassLoader();
>         try {
>             current.setContextClassLoader(getClass().getClassLoader());
>             // call library code here
>         } finally {
>             current.setContextClassLoader(oldLoader);
>         }

Uh how ugly. Do I have to put this wrapper in every function I call
xmlBlaster functions?

I tried this, but with no success. Still getting the CCE:

public void start(BundleContext context) throws Exception
    {
        this.bundleContext = context;
        // need to use context class loader to make xmlBlaster happy
        Thread current = Thread.currentThread();
        ClassLoader oldLoader = current.getContextClassLoader();
        try {
            current.setContextClassLoader(getClass().getClassLoader());
            // call library code here
            momConnector = new MOMConnector();
        } finally {
            current.setContextClassLoader(oldLoader);
        }
    }


Ah someone how can help me?