Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » buddy classloading troubles
buddy classloading troubles [message #459428] Fri, 01 December 2006 04:01 Go to next message
Eclipse UserFriend
Hi,

I'm having trouble setting up buddy classloading.
I have a couple of plugins which have a dependency hierarchy which I'm
trying to register correctly as buddies.

My case is as follows

Bundle com.mystuff.web calls class JettyRunner in bundle com.mystuff.jetty.
Class JettyRunner creates a jetty Server class instance, which comes
from bundle org.mortbay.jetty, which is dependent on bundle javax.servlet

In manifest files it is set up like this:

com.mystuff.web:
...
Require-Bundle: org.eclipse.core.runtime,
com.winkelz.jetty,
...
Eclipse-BuddyPolicy: registered

com.mystuff.jetty:
....
Require-Bundle: org.eclipse.core.runtime,
org.mortbay.jetty;visibility:=reexport,
javax.servlet;visibility:=reexport
Export-Package: com.mystuff.jetty
Eclipse-BuddyPolicy: registered

org.mortbay.jetty:
Export-Package: org.mortbay.jetty,
...
Require-Bundle: org.mortbay.jetty.util;visibility:=reexport
Eclipse-BuddyPolicy: registered

javax.servlet:
Export-Package: javax.servlet,
javax.servlet.http,
javax.servlet.resources
Eclipse-RegisterBuddy: org.mortbay.jetty, org.mortbay.jetty.util,
com.mystuff.jetty, com.mystuff.web

And this is the exception I get:

java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.mystuff.jetty.JettyRunner.start(JettyRunner.java:35)
at com.mystuff.web.Application.run(Application.java:31)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:78)

When I change the policy in org.mortbay.jetty to 'dependent' everything
works, so I guess something is wrong with my buddy registering, although
I'm lost here.

Any help?

Thanx,
Wouter
Re: buddy classloading troubles [message #459452 is a reply to message #459428] Fri, 01 December 2006 11:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mbayly.telus.net

Apologies if I misunderstand your problem - but at first reading I'm thinking that you are misunderstanding how plug-in dependencies should be set up in Eclipse. Generally, you don't need to worry about Buddy policies for setting up dependencies. Buddy policies are only needed if you have class loading requirements that don't fit the normal Eclipse model.

It sounds like your dependency is something like:
com.mystuff.web
depends on
com.mystuff.jetty
depends on
org.mortbay.jetty
depends on
javax.servlet

So this should be setup using standard Eclipse Require-Bundle dependency management. (See the Required Plug-ins section in the Dependencies tab of the plug-in manifest editor). From your snippets below it looks like you have some of these setup, but I don't see any reference to org.mortbay.jetty depending on javax.servlet for example.

A standard use for using Buddy loading is if a ' generic library' package on which your plug-in depends also has a need to be able to load classes in your package e.g. the standard example is log4j where dependent code may contribute extensions to log4j. In this case log4j is set up with Buddy-Policy: registered and the dependent plugins register themselves with log4j using Eclipse-RegisterBuddy. But the dependent plug-ins also define a dependency on log4j using Require-Bundle.

Check out Alex's article on Eclipse classloading:
http://eclipsezone.com/articles/eclipse-vms/?source=archives

If I misunderstood your problem let me know.
Cheers
Martin
Re: buddy classloading troubles [message #459492 is a reply to message #459452] Sat, 02 December 2006 10:52 Go to previous message
Eclipse UserFriend
Hi Martin,

Thanks for your reply. I didn't paste all the details, but the
dependencies were set right. Also I left some information out now I see
(it was a long day ;-)

I found out what the issue was, I'll post it here for the record.

It was a classic example of buddy loading.
I also have a bundle for wicket, which in the end tries to load a class
from another package, but shouldn't know anything about it, due to the
bundle hierarchy. I solved this using buddy policy registered.

com.mystuff.web starts up jetty, jetty registeres the wicket filter.
The wicket filter tries to load a custom filter from the
com.mystuff.web. Wicket isn't supposed to depend on com.mystuff.web, but
needs a class from it.
So I set Eclipse-BuddyPolicy: registered in wicket and
Eclipse-RegisterBuddy: wicket in com.mystuff.web.

Works like charm now.

Sorry for your trouble.

Wouter


Martin Bayly wrote:
> Apologies if I misunderstand your problem - but at first reading I'm thinking that you are misunderstanding how plug-in dependencies should be set up in Eclipse. Generally, you don't need to worry about Buddy policies for setting up dependencies. Buddy policies are only needed if you have class loading requirements that don't fit the normal Eclipse model.
>
> It sounds like your dependency is something like:
> com.mystuff.web
> depends on
> com.mystuff.jetty
> depends on
> org.mortbay.jetty
> depends on
> javax.servlet
>
> So this should be setup using standard Eclipse Require-Bundle dependency management. (See the Required Plug-ins section in the Dependencies tab of the plug-in manifest editor). From your snippets below it looks like you have some of these setup, but I don't see any reference to org.mortbay.jetty depending on javax.servlet for example.
>
> A standard use for using Buddy loading is if a ' generic library' package on which your plug-in depends also has a need to be able to load classes in your package e.g. the standard example is log4j where dependent code may contribute extensions to log4j. In this case log4j is set up with Buddy-Policy: registered and the dependent plugins register themselves with log4j using Eclipse-RegisterBuddy. But the dependent plug-ins also define a dependency on log4j using Require-Bundle.
>
> Check out Alex's article on Eclipse classloading:
> http://eclipsezone.com/articles/eclipse-vms/?source=archives
>
> If I misunderstood your problem let me know.
> Cheers
> Martin
Previous Topic:Problem with TableContentProvider
Next Topic:Intro and RCP
Goto Forum:
  


Current Time: Wed Mar 19 06:33:04 EDT 2025

Powered by FUDForum. Page generated in 0.03390 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top