Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AJDT » LTW not working in Eclipse Juno(Class not found exceptions when starting weaving hook and caching.)
LTW not working in Eclipse Juno [message #988307] Thu, 29 November 2012 10:54 Go to next message
Helge Mising name is currently offline Helge Mising name
Messages: 17
Registered: October 2010
Junior Member
Dear all,

I have a problem with load-time weaving and equinox aspects.

My setup is the following: I have a supplemented bundle 'B' and a bundle 'A' containing an aspect. According to http://java.dzone.com/articles/aspect-oriented-programming I created bundle A as OSGi bundle on the Equinox framework and converted it to an AspectJ project. According to http://wiki.eclipse.org/Equinox_Weaving_QuickStart I have :

1) AJDT (2.2.1.e42x-RELEASE-20120921-1400) and Equinox Weaving (Equinox Weaving SDK 1.0.200.I20120427-0800) installed in my Eclipse Juno (20120620-1657)
2) defined the aspect in a package
3) configured my Manifest.MF to:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: A
Bundle-SymbolicName: a.a
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.aspectj.runtime,
 b.b;bundle-version="1.0.0",
Export-Package: a.a;aspects="AspectA"
Eclipse-SupplementBundle: b.b;bundle-version="1.0.0"


4) in the plug-ins tab off my run configuration (for an Eclipse application) I made sure that the following plugins are selected:
org.aspectj.weaver (Start Level: default Auto-Start: default)
org.eclipse.equinox.weaving.aspectj (Start Level: 2 Auto-Start: true)
org.eclipse.equinox.weaving.caching (Start Level: default Auto-Start: default)
org.eclipse.equinox.weaving.hook (Start Level: default Auto-Start: false)


5) I added the following VM arguments:
-Dosgi.framework.extensions=org.eclipse.equinox.weaving.hook
-Dorg.aspectj.osgi.verbose=true
-Dorg.aspectj.weaver.showWeaveInfo=true

My problem is that LTW cannot be performed. The bundles org.eclipse.equinox.weaving.hook cannot be found and the bundle org.eclipse.equinox.weaving.caching cannot be started, what results in ClassNotFoundException and NoClassDefFoundError exceptions, see the trace below.

What do I have to do or what did I configured wrongly?

I have the impression that the erroneous behavior is caused by step four. First, I am not sure if I should run my code as an Eclipse application or if I should choose an OSGi framework application? Second, I cannot modify the Auto-Start for the org.eclipse.equinox.weaving.hook from false to true or to default. I observe that unlike the other plugins the *.hook plugin has a violet not a blue plugin icon. I do not know what this means but perhaps it is important. Is there anyone using AJDT and LTW in Eclipse Juno who could help me out?


Best regards,
Helge


!ENTRY org.eclipse.osgi 4 0 2012-11-29 11:03:16.366
!MESSAGE Bundle org.eclipse.equinox.weaving.hook not found.
[org.eclipse.equinox.weaving.aspectj] info Starting AspectJ weaving service ...
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.weaving.aspectj.AspectJWeavingActivator.start(Unknown Source)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
	at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
	at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1177)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Caused by: java.lang.NoClassDefFoundError: org/eclipse/equinox/service/weaving/IWeavingServiceFactory
	at org.eclipse.equinox.weaving.aspectj.AspectJWeavingStarter.start(Unknown Source)
	... 20 more
Caused by: java.lang.ClassNotFoundException: org.eclipse.equinox.service.weaving.IWeavingServiceFactory
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:455)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	... 21 more
[org.eclipse.equinox.weaving.caching] info starting standard caching service ...

!ENTRY org.eclipse.equinox.weaving.caching 4 0 2012-11-29 11:03:17.193
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Exception in org.eclipse.equinox.weaving.internal.caching.Activator.start() of bundle org.eclipse.equinox.weaving.caching.
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
	at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
	at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1177)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Caused by: java.lang.NoClassDefFoundError: org/eclipse/equinox/service/weaving/ICachingServiceFactory
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188)
	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClassHoldingLock(ClasspathManager.java:632)
	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:614)
	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:568)
	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:492)
	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:465)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
	at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:464)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	at org.eclipse.equinox.weaving.internal.caching.Activator.registerCachingServiceFactory(Unknown Source)
	at org.eclipse.equinox.weaving.internal.caching.Activator.start(Unknown Source)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
	... 12 more
Caused by: java.lang.ClassNotFoundException: org.eclipse.equinox.service.weaving.ICachingServiceFactory
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:455)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	... 33 more
Root exception:
java.lang.NoClassDefFoundError: org/eclipse/equinox/service/weaving/ICachingServiceFactory
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188)
	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClassHoldingLock(ClasspathManager.java:632)
	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:614)
	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:568)
	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:492)
	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:465)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
	at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:464)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	at org.eclipse.equinox.weaving.internal.caching.Activator.registerCachingServiceFactory(Unknown Source)
	at org.eclipse.equinox.weaving.internal.caching.Activator.start(Unknown Source)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
	at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
	at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1177)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Caused by: java.lang.ClassNotFoundException: org.eclipse.equinox.service.weaving.ICachingServiceFactory
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:455)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	... 33 more
[org.eclipse.equinox.weaving.caching.j9] warning cannot start J9 caching service
Re: LTW not working in Eclipse Juno [message #988384 is a reply to message #988307] Thu, 29 November 2012 17:04 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew Eisenberg
Messages: 368
Registered: July 2009
Senior Member
org.eclipse.equinox.weaving.hook is not a bundle or a plugin. Rather it is a bundle fragment. Fragments are loaded along with host bundles. In this case weaving hook is a fragment of the core osgi bundle (org.eclipse.osgi). Fragments have a different icon in Eclipse and they cannot be autostarted (since they always start with their host bundle).

There is a bug in equinox that system fragments must be loaded from the same filesystem directory as the host bundle. So, if weaving.hook is in your workspace, you must import org.eclipse.osgi into your workspace.

From the looks of your error message, I think this is your problem.
Re: LTW not working in Eclipse Juno [message #988515 is a reply to message #988307] Fri, 30 November 2012 10:32 Go to previous messageGo to next message
Helge Mising name is currently offline Helge Mising name
Messages: 17
Registered: October 2010
Junior Member
Hi Andrew,

Ah, thank you for this insight. The weaving hook is a fragment to the OSGi bundle. But unfortunately, this does not solve my problem.

Likely, as you suggest, the different locations in the file system are the problem. The osgi bundle resides in Eclipse's plugin folder "/Applications/eclipse/plugins", whereas the hook fragment is in a platform specific folder in the user directory "/Users/username/.eclipse/org.eclipse.platform_4.2.0_2111846031/plugins". (I am on Mac OS 10.8 if this plays a role) Until now, I did not have the hook fragment in the workspace.

To solve the problem I tried the following strategies separately:

1) I moved the hook fragment to Eclipse's plugin folder. This does not work. All projects in my workspace will not be built anymore and in the plugins view is the hook fragment marked as out of sync.
2) I moved the osgi bundle to the platform folder. This does not work. Eclipse will not start up since it cannot find the osgi bundle.
3) I imported both, the osgi bundle and the hook fragment as binary projects into my workspace. In my run configuration I selected those two to be loaded. This does not work. It produces the same class not found exceptions.


As mentioned, I installed AJDT through the marketplace. The installation routine automatically placed all AJDT bundles into the platform directory in the user folder. Can I alter this behavior? Can I specify that all AJDT bundles end up in Eclipse's plugin folder? Is there an alternative way of installing AJDT? Should I uninstall AJDT and just manually place all of its plugins into Eclipse's plugin folder as in the old days?


Best regards,
Helge
Re: LTW not working in Eclipse Juno [message #988551 is a reply to message #988515] Fri, 30 November 2012 12:53 Go to previous messageGo to next message
Helge Mising name is currently offline Helge Mising name
Messages: 17
Registered: October 2010
Junior Member
Hi all,

I figured out that when I import the osgi bundle and the weaving hook fragment not as binary projects but as binary projects with attached sources, then all classes of the hook fragment are found and my aspect code is woven into the code of the supplemented bundle.


So in case anyone has the problem of LTW with equinox weaving in Eclipse Juno:
--> import the bundle "org.eclipse.osgi" and the fragment "org.eclipse.equinox.weaving.hook" as "Binary Project with Linked Content" into your workspace in addition to the steps described here http://wiki.eclipse.org/Equinox_Weaving_QuickStart

Best,
Helge
Re: LTW not working in Eclipse Juno [message #988612 is a reply to message #988551] Fri, 30 November 2012 17:12 Go to previous message
Andrew Eisenberg is currently offline Andrew Eisenberg
Messages: 368
Registered: July 2009
Senior Member
Glad you were able to get this working. My dev environment is exactly as you describe: OSGi bundle and weaving hook bundle are imported with sources into my workspace.
Previous Topic:eclipse indigo is not starting up after installing gwt
Next Topic: [Urgent] - Bad version numner found in AspectJ 1.7.0 (m2eclipse issue?)
Goto Forum:
  


Current Time: Tue Oct 21 21:44:04 GMT 2014

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

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