This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | Unable to load aspectj in netbinox | ||
---|---|---|---|
Product: | platform | Reporter: | bobuse <bobuse> |
Component: | Netigso | Assignee: | Jaroslav Tulach <jtulach> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P4 | ||
Version: | 6.x | ||
Hardware: | Other | ||
OS: | Linux | ||
Issue Type: | DEFECT | Exception Reporter: |
Description
bobuse
2010-02-17 03:20:08 UTC
Hi, I guess that you haven't found time for my report. As this bug is highly blocker for our application, we are ready to invest time on it, but we need some hints to start debug sessions. Do you have ideas for looking to what's wrong ? Thank you Last time I tried, I was on bad internet connection and could not pass the 12MB download step. I'll try it now. If you want to help me, I'll be glad. I expect that you want to debug equinox. Open its sources (I guess import project from eclipse shall work). And then just start debugging your own application. Plus open the source view and add equinox sources as a source roots. That shall be it. It would help to know the stacktrace when your aspect is being loaded, but I don't know how to run the standalone sample. We've found a solution :-) The problem was effectively that the weaving.hook library wasn't loaded from the startup classloader. So I've added this library as wrapped library in the netbinox module, and now my sample is working as excepted. For instance, I've published this patched netbinox on our maven repository, we need to make test on our application. I don't know if this solution is clean enough for you … maybe this requirement is general for the equinox extensions, and you may add a more clever feature. What is the stack trace that loads your hook now? Something along these lines in equinox shall be fixed to not expect the hook be loaded by the same classloader as equinox... I haven't found how to plug equinox sources in Netbeans debugger. I don't remember any specific task that I've done in the past when I did it successfully. I've opened equinox sources in a netbeans project, and putted some breakpoints, but nothing append… if you have some hints, I've no enough time yet for that. Thank you I've redesigned my sample, so to get the module suite: svn co http://svn.simexplorer.org/SimExplorer/misc/aspectj-test cd aspectj-test mvn install It will built my sample equinox bundles and download needed bundles for aspectj, and netbinox. Then you have a netbeans module suite in the sub-directory "netbeans-suite" that is configured to be built with the extracted netbinox. If anyone want inspect it… :-) (In reply to comment #7) > I've redesigned my sample, so to get the module suite: If I do this, we the aspectj work or will it be broken? I still need a stacktrace from successful showing how the aspect class will get loaded. If you get my sources and built the module suite, it may working … aspectj is well loaded when message log "info Starting AspectJ weaving service" is displayed at the begin. The subfolder equinox-product contains a working equinox environment that make aspects working for sure. I've tried to import the aspectj hook sources to debug, but without success … Well, I have the stacktrace of the message "info Starting AspectJ weaving service" when started in raw equinox environment, so with a correct behaviour: [java.lang.Thread.getStackTrace(Thread.java:1436), org.eclipse.equinox.weaving.aspectj.AspectJWeavingActivator.start(AspectJWeavingActivator.java:77), org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:783), java.security.AccessController.doPrivileged(Native Method), org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:774), org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:755), org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:352), org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:370), org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1068), org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:557), org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:464), org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:248), org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:445), org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:227), org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:337)] It was difficult for me to get a correct environment for working with equinox sources in eclipse, but I have found a good way. I have installed aspectj from this update site http://download.eclipse.org/tools/ajdt/35/update including source (in the installation options). Then I have opened the window "Plug-in dev -> Plug-ins", found the bundle org.eclipse.equinox.weaving.aspectj, right-click "Import as->Source project". This afternoon, I'll try to get the stacktrace when started from netbinox. And the stacktrace in netbinox environment is: java.lang.Exception: Stack trace at java.lang.Thread.dumpStack(Thread.java:1206) at org.eclipse.equinox.weaving.aspectj.AspectJWeavingActivator.start(AspectJWeavingActivator.java:77) at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:783) at java.security.AccessController.doPrivileged(Native Method) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:774) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:755) at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:352) at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:370) at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1068) at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:557) at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:464) at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:248) at org.eclipse.osgi.framework.internal.core.EquinoxLauncher.internalStart(EquinoxLauncher.java:281) at org.eclipse.osgi.framework.internal.core.EquinoxLauncher.start(EquinoxLauncher.java:251) at org.eclipse.osgi.launch.Equinox.start(Equinox.java:169) at org.netbeans.core.netigso.Netigso.start(Netigso.java:133) at org.netbeans.NetigsoFramework.turnOn(NetigsoFramework.java:137) at org.netbeans.ModuleManager.enable(ModuleManager.java:928) at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:315) at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:251) at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:283) at org.netbeans.core.startup.Main.getModuleSystem(Main.java:169) at org.netbeans.core.startup.Main.start(Main.java:299) at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:111) at java.lang.Thread.run(Thread.java:619) It is the same when it fails or success, so I assume that the netbeans module system doesn't have enough priority information do load it early. From stacktrace, I can only observe that they differ before entering in org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:248) I don't know if it helps you to understand what's wrong… I've done the same for the module org.eclipse.equinox.weaving.hook: In raw equinox environment: java.lang.Exception: Stack trace at java.lang.Thread.dumpStack(Thread.java:1206) at org.eclipse.equinox.weaving.hooks.AbstractAspectJHook.addHooks(AbstractAspectJHook.java:78) at org.eclipse.osgi.baseadaptor.HookRegistry.loadConfigurators(HookRegistry.java:178) at org.eclipse.osgi.baseadaptor.HookRegistry.initialize(HookRegistry.java:100) at org.eclipse.osgi.baseadaptor.BaseAdaptor.<init>(BaseAdaptor.java:96) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.eclipse.core.runtime.adaptor.EclipseStarter.createAdaptor(EclipseStarter.java:747) at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:282) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:175) at org.eclipse.core.runtime.adaptor.EclipseStarter.main(EclipseStarter.java:150) In netbinox environment: java.lang.Exception: Stack trace at java.lang.Thread.dumpStack(Thread.java:1206) at org.eclipse.equinox.weaving.hooks.AbstractAspectJHook.addHooks(AbstractAspectJHook.java:78) at org.eclipse.osgi.baseadaptor.HookRegistry.loadConfigurators(HookRegistry.java:178) at org.eclipse.osgi.baseadaptor.HookRegistry.initialize(HookRegistry.java:100) at org.eclipse.osgi.baseadaptor.BaseAdaptor.<init>(BaseAdaptor.java:96) at org.eclipse.osgi.framework.internal.core.EquinoxLauncher.internalInit(EquinoxLauncher.java:68) at org.eclipse.osgi.framework.internal.core.EquinoxLauncher.init(EquinoxLauncher.java:38) at org.eclipse.osgi.launch.Equinox.init(Equinox.java:89) at org.netbeans.core.netigso.Netigso.prepare(Netigso.java:110) at org.netbeans.NetigsoFramework.turnOn(NetigsoFramework.java:133) at org.netbeans.ModuleManager.enable(ModuleManager.java:928) at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:315) at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:251) at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:283) at org.netbeans.core.startup.Main.getModuleSystem(Main.java:169) at org.netbeans.core.startup.Main.start(Main.java:299) at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:111) at java.lang.Thread.run(Thread.java:619) [org.eclipse.equinox.weaving.hook] info adding AspectJ hooks ... OK, so I think the problem is in HookRegistry: private void loadConfigurators(ArrayList configurators, ArrayList errors) { for (Iterator iHooks = configurators.iterator();iHooks.hasNext();) { String hookName = (String) iHooks.next(); Class clazz = Class.forName(hookName); it is using Class.forName. That means only classes directly visible by the equinox.jar are accessible. This is not really suitable for modular system and implies that you basically need to load equinox.jar and aspectj weaving module by the same classloader (which you did). If the above code used ClassLoader l = Thread.currentThread().getContextClassLoader(); Class.forName(hookName, true, l); then the loading succeeded even in case the aspectj weaving module would be in its own JAR with dependency on the module providing equinox.jar (your original setup). So right now there does not seem to be anything I can do on our side (except writing a blog). Try to talk to the equinox guys and convince them to load the hooks via context classloader (that will be compatible for them and open up doors to integrate equinox in modular environment). Good luck! Btw. there is buddy classloading (see http://wiki.eclipse.org/Context_Class_Loader_Enhancements), but that is probably not going to work on loading the framework itself. Blog published: http://wiki.apidesign.org/wiki/BootstrappingEquinox Now it is up to you to deal with Equinox team. Thanks a lot for your investigations !! Your conclusions are enlightening. So, I've tried to patch equinox with your proposition, and to made a new archive of netbinox to build my modules suite. I've made some tests, and it seems to work. Thank you very much. Hmmm, in fact, it doesn't work at each time. Do you think that the code you've pointed is the single problem for loading the weaver? Or maybe, I've made a misconfiguration in my modules suite: http://www.simexplorer.org/browser/misc/aspectj-test/netbeans-suite Well, I've added some debug info to the HookRegistry class and get this output: -----------8<---------------------------------------------- Equinox loading a hook: org.eclipse.osgi.internal.baseadaptor.BaseHookConfigurator Equinox loading a hook: org.eclipse.osgi.internal.baseadaptor.DevClassLoadingHook Equinox loading a hook: org.eclipse.core.runtime.internal.adaptor.EclipseStorageHook Equinox loading a hook: org.eclipse.core.runtime.internal.adaptor.EclipseLogHook Equinox loading a hook: org.eclipse.core.runtime.internal.adaptor.EclipseErrorHandler Equinox loading a hook: org.eclipse.core.runtime.internal.adaptor.EclipseAdaptorHook Equinox loading a hook: org.eclipse.core.runtime.internal.adaptor.EclipseClassLoadingHook Equinox loading a hook: org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter Equinox loading a hook: org.eclipse.core.runtime.internal.stats.StatsManager Equinox loading a hook: org.eclipse.osgi.internal.signedcontent.SignedBundleHook Equinox loading a hook: org.eclipse.osgi.internal.composite.CompositeConfigurator Equinox loading a hook: org.eclipse.equinox.weaving.hooks.WeavingHook [org.eclipse.equinox.weaving.hook] info adding AspectJ hooks ... Equinox loading a hook: org.apidesign.netbinox.NetigsoHooks INFO [org.simexplorer.netbinox.example.Activator]: Module started INFO [org.simexplorer.netbinox.example.MyObject]: Object creation Module started. Available modules: com.springsource.org.aspectj.runtime com.springsource.org.aspectj.weaver org.apidesign.netbinox (enabled) org.eclipse.equinox.weaving.aspectj (enabled) org.eclipse.equinox.weaving.hook org.netbeans.bootstrap (enabled) org.netbeans.core.netigso (enabled) org.netbeans.core.osgi org.netbeans.core.startup (enabled) org.netbeans.libs.osgi (enabled) org.openide.filesystems (enabled) org.openide.modules (enabled) org.openide.util (enabled) org.openide.util.lookup (enabled) org.simexplorer.netbinox (enabled) org.simexplorer.netbinox.aspect (enabled) org.simexplorer.netbinox.example (enabled) [org.eclipse.equinox.weaving.aspectj] info Starting AspectJ weaving service ... ---------------------->8------------------------------------------- I don't understand why the weaving service is started too late… But maybe, I should ask the question to the equinox staff ;-) … next week I am working on a fix that will allow anyone to add new additional HookConfigurator. Fixed in 1.16.7 version of Netbinox: http://wiki.apidesign.org/wiki/NetbinoxHook |