问题描述
我正在尝试在我的 Eclipse RCP/RAP 应用程序中添加 AspectJ.
I am trying to add AspectJ in my Eclipse RCP/RAP application.
我按照这些人所说的一步一步做:链接在这里(除了创建新平台,我自己在我的平台中添加了库).
I did step by step as these guys say: link here (except creating a new platform, I added the libraries by my self in my platform).
但问题是它仍然无法正常工作...我收到此错误:
But the problem is that it is still not working... I get this error:
osgi> !SESSION 2012-03-18 02:16:54.354 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.7.0_02
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Command-line arguments: -dev file:/home/alexandru/workspaces/Java-RCP-RAP/project/.metadata/.plugins/org.eclipse.pde.core/RAP Application/dev.properties -os linux -ws gtk -arch x86_64 -consoleLog -console -data /home/alexandru/workspaces/Java-RCP-RAP/project/.metadata/.plugins/org.eclipse.rap.ui.launch/RAPApplication
!ENTRY org.eclipse.osgi 4 0 2012-03-18 02:16:54.960
!MESSAGE Bundle org.eclipse.equinox.weaving.hook not found.
java.lang.ClassNotFoundException: org.aspectj.weaver.loadtime.definition.Definition
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
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:389)
at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1130)
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)
不知道为什么会出现这个错误……真的很奇怪……
I don't know why I have this error... it's really strange...
推荐答案
嗯...这个错误是因为我没有重新导出 org.aspectj.runtime
依赖...
well... this error happened because I haven't reexported the org.aspectj.runtime
dependency...
但现在我有另一个错误:
but now I have another error:
!ENTRY org.eclipse.osgi 4 0 2012-03-18 21:33:55.112
!MESSAGE Bundle org.eclipse.equinox.weaving.hook not found.
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
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:389)
at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1130)
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:467)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 21 more
我认为这是因为未找到 org.eclipse.equinox.weaving.hook
...但我添加了此 -Dosgi.framework.extensions=org.eclipse.equinox.weaving.hook
在运行配置
.
I think this is because org.eclipse.equinox.weaving.hook
is not found... but I added this -Dosgi.framework.extensions=org.eclipse.equinox.weaving.hook
at run configurations
.
已编辑解决方案:
找到了..
我必须将 aspectj 库添加到我的 osgi 框架所在的同一文件夹中(其中定义了平台)
I had to add the aspectj libraries in the same folder where my osgi framework is (where platform is defined)
这篇关于Eclipse RCP AspectJ 配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!