This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Scala Eclipse Plugin Conflicts with AJDT

9 replies
Gordon Leland H...
Joined: 2009-02-01,
User offline. Last seen 42 years 45 weeks ago.
I am trying to incorporate scala and the eclipse plugin into an existing project, however the project already has a dependency on aspectj's AJDT plugin and the Scala plugin and AJDT appear not to play nicely together. After installing the scala plugin, there are no errors, however none of the aspects are recognized by AJDT. The problem persists even if the Scala builder is not selected and even after I remove the Scala plugin. The only solution is to create a new workspace after the scala plugin has been removed. I have attempted this multiple times and am almost positive this is caused by the Scala eclipse plugin.

Inside the workspace log file there is the following:
!ENTRY org.eclipse.osgi 2 0 2009-02-01 01:31:00.762!MESSAGE While loading class "lampion.presentation.Presentations$", thread "Thread[worker-oakland,6,main]" timed out waiting (5000ms) for thread "Thread[main,6,main]" to finish starting bundle "reference:file:plugins\ch.epfl.lamp.sdt.core_2.7.3.final.jar [515]". To avoid deadlock, thread "Thread[worker-oakland,6,main]" is proceeding but "lampion.presentation.Presentations$" may not be fully initialized. !STACK 0org.osgi.framework.BundleException: State change in progress for bundle "reference:file:plugins\ch.epfl.lamp.sdt.core_2.7.3.final.jar" by thread "main". at org.eclipse.osgi.framework.internal.core.AbstractBundle.beginStateChange(AbstractBundle.java:1144) at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:263) at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:400) at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:111) at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:427) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:193) at org.eclipse.osgi.framework.internal.core.BundleLoader.findLocalClass(BundleLoader.java:368) at org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal(BundleLoader.java:444) at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:397) at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:385) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:87) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at lampion.presentation.Presentations$ProjectImpl$Job.run(Presentations.scala:335)Caused by: org.eclipse.osgi.framework.internal.core.AbstractBundle$BundleStatusException ... 14 moreRoot exception:org.eclipse.osgi.framework.internal.core.AbstractBundle$BundleStatusException at org.eclipse.osgi.framework.internal.core.AbstractBundle.beginStateChange(AbstractBundle.java:1144) at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:263) at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:400) at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:111) at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:427) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:193) at org.eclipse.osgi.framework.internal.core.BundleLoader.findLocalClass(BundleLoader.java:368) at org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal(BundleLoader.java:444) at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:397) at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:385) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:87) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at lampion.presentation.Presentations$ProjectImpl$Job.run(Presentations.scala:335)
I am using the version from the update site, 2.7.3final. Anyone have any ideas or suggestions?
Thanks,Gordon
Jan Lohre
Joined: 2008-12-17,
User offline. Last seen 42 years 45 weeks ago.
Re: Scala Eclipse Plugin Conflicts with AJDT
Hi,

in eclipse/osgi a bundle is not allowed to do much work on startup. After 5 sec the framework aborts the loading of a bundle and ignores it after that.

I have seen the same case without AJDT, my way of getting the scala plugin back to work was closing all scala related projects and restart. Then opening a verys small scala project. If all of these steps are required? No idea but it worked.

After browsing trac sources I found a good candidate for causing the problem:

ScalaCompilationUnitManager.initCompilationUnits(ResourcesPlugin.getWorkspace)

in the start method in scala.tools.eclipse.ScalaUIPlugin, which appears to be the activator.

This is a severe problem effectivly limiting workspace sizes, but I wonder why the plugin developers never stumbled over this, as the plugin for sure has a larger codebase than I have.

I guess we should open a ticket.

Kind regards,
Jan

2009/2/1 Gordon Leland Hempton <ghempton [at] gmail [dot] com>
I am trying to incorporate scala and the eclipse plugin into an existing project, however the project already has a dependency on aspectj's AJDT plugin and the Scala plugin and AJDT appear not to play nicely together. After installing the scala plugin, there are no errors, however none of the aspects are recognized by AJDT. The problem persists even if the Scala builder is not selected and even after I remove the Scala plugin. The only solution is to create a new workspace after the scala plugin has been removed. I have attempted this multiple times and am almost positive this is caused by the Scala eclipse plugin.

Inside the workspace log file there is the following:
!ENTRY org.eclipse.osgi 2 0 2009-02-01 01:31:00.762!MESSAGE While loading class "lampion.presentation.Presentations$", thread "Thread[worker-oakland,6,main]" timed out waiting (5000ms) for thread "Thread[main,6,main]" to finish starting bundle "reference:file:plugins\ch.epfl.lamp.sdt.core_2.7.3.final.jar [515]". To avoid deadlock, thread "Thread[worker-oakland,6,main]" is proceeding but "lampion.presentation.Presentations$" may not be fully initialized. !STACK 0org.osgi.framework.BundleException: State change in progress for bundle "reference:file:plugins\ch.epfl.lamp.sdt.core_2.7.3.final.jar" by thread "main". at org.eclipse.osgi.framework.internal.core.AbstractBundle.beginStateChange(AbstractBundle.java:1144) at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:263) at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:400) at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:111) at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:427) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:193) at org.eclipse.osgi.framework.internal.core.BundleLoader.findLocalClass(BundleLoader.java:368) at org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal(BundleLoader.java:444) at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:397) at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:385) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:87) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at lampion.presentation.Presentations$ProjectImpl$Job.run(Presentations.scala:335)Caused by: org.eclipse.osgi.framework.internal.core.AbstractBundle$BundleStatusException ... 14 moreRoot exception:org.eclipse.osgi.framework.internal.core.AbstractBundle$BundleStatusException at org.eclipse.osgi.framework.internal.core.AbstractBundle.beginStateChange(AbstractBundle.java:1144) at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:263) at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:400) at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:111) at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:427) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:193) at org.eclipse.osgi.framework.internal.core.BundleLoader.findLocalClass(BundleLoader.java:368) at org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal(BundleLoader.java:444) at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:397) at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:385) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:87) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at lampion.presentation.Presentations$ProjectImpl$Job.run(Presentations.scala:335)
I am using the version from the update site, 2.7.3final. Anyone have any ideas or suggestions?
Thanks,Gordon

milessabin
Joined: 2008-08-11,
User offline. Last seen 33 weeks 3 days ago.
Re: Scala Eclipse Plugin Conflicts with AJDT

On Sun, Feb 1, 2009 at 10:32 AM, Gordon Leland Hempton
wrote:
> I am trying to incorporate scala and the eclipse plugin into an existing
> project, however the project already has a dependency on aspectj's AJDT
> plugin and the Scala plugin and AJDT appear not to play nicely together.
> After installing the scala plugin, there are no errors, however none of the
> aspects are recognized by AJDT. The problem persists even if the Scala
> builder is not selected and even after I remove the Scala plugin. The only
> solution is to create a new workspace after the scala plugin has been
> removed. I have attempted this multiple times and am almost positive this is
> caused by the Scala eclipse plugin.

The Scala Eclipse plugin should get on well with the AJDT (I know it
does for work on the plugin development because I'm using it myself
for work that's about to land on trunk :-)

However, it's not currently possible to have mixed Scala and AspectJ
projects. This is partly a Scala Eclipse plugin limitation, but there
are also issues currently with ajc's ability to hand classfiles
generated by scalac. Anything that you can do to help with either end
of the problem would be very much appreciated.

So for not I'd recommend splitting your project into two: one part
AspectJ+Java, the other Scala+Java. In this arrangement you won't be
able to write advice directly in Scala (but that would require an
"AspectS" which doesn't yet exist ;-) but you are able to call out to
Scala code from your AspectJ advice.

Cheers,

Miles

Gordon Leland H...
Joined: 2009-02-01,
User offline. Last seen 42 years 45 weeks ago.
Re: Scala Eclipse Plugin Conflicts with AJDT
Thanks Jan, that seemed like a plausible explanation, however I tried your solution exactly as described, but I still had the problem. The small scala project suffered from the same problem and had the same error in the workspace log. Perhaps the AJDT plugin somehow increases the load time for osgi bundles?

On Sun, Feb 1, 2009 at 3:36 AM, Miles Sabin <miles [at] milessabin [dot] com> wrote:
However, it's not currently possible to have mixed Scala and AspectJ
projects. This is partly a Scala Eclipse plugin limitation, but there
are also issues currently with ajc's ability to hand classfiles
generated by scalac. Anything that you can do to help with either end
of the problem would be very much appreciated.

I am not hoping to have aspectj apply advice to scalac class files, I only want ajdt to  continue to do what it did before with regular javac class files before I installed the scala plugin. I assume that the scala plugin doesnt much with the bytecode of the projects regular java class files?
Also, fyi, I am able to get the compilation and aspectj weaving to work fine using an ant build.


--
Gordon Hempton
http://hempton.com
Gordon Leland H...
Joined: 2009-02-01,
User offline. Last seen 42 years 45 weeks ago.
Re: Scala Eclipse Plugin Conflicts with AJDT
Also something that is really bizarre: after I uninstall the scala eclipse plugin, I get a different error in the log:
!ENTRY org.eclipse.ajdt.core 4 0 2009-02-01 13:01:12.819!MESSAGE java.util.EmptyStackException !STACK 0java.util.EmptyStackException at java.util.Stack.peek(Unknown Source) at java.util.Stack.pop(Unknown Source) at org.aspectj.bridge.context.CompilationAndWeavingContext.leavingPhase(CompilationAndWeavingContext.java:165) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1190) at org.aspectj.weaver.tools.WeavingAdaptor.getWovenBytes(WeavingAdaptor.java:423) at org.aspectj.weaver.tools.WeavingAdaptor.weaveClass(WeavingAdaptor.java:286) at org.eclipse.equinox.weaving.aspectj.loadtime.OSGiWeavingAdaptor.weaveClass(OSGiWeavingAdaptor.java:97) at org.eclipse.equinox.weaving.aspectj.WeavingService.preProcess(WeavingService.java:156) at org.eclipse.equinox.weaving.adaptors.AspectJAdaptor.weaveClass(AspectJAdaptor.java:235) at org.eclipse.equinox.weaving.hooks.AspectJHook.processClass(AspectJHook.java:126) at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:549) at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:524) at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:455) at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass_LockClassLoader(ClasspathManager.java:443) at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:423) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:193) at org.eclipse.osgi.framework.internal.core.BundleLoader.findLocalClass(BundleLoader.java:368) at org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal(BundleLoader.java:444) at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:397) at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:385) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:87)......
Which appears to be the fault of the ajdt plugin, however it does not appear before I installed the scala plugin and it also does not appear if I create a new workspace and import the same project. This leaves me to conclude that the scala plugin might not be doing a clean uninstall on the workspace level? The strange thing is that I see no scala related folders in the .plugins directory in the workspace folder.
I am really looking forward to start integrating scala into this project, however I do not want to deviate from the standard eclipse workflow/project structure that we already use. If anyone has any insight into this I would be greatly appreciative.
Thanks,Gordon
On Sun, Feb 1, 2009 at 12:55 PM, Gordon Leland Hempton <ghempton [at] gmail [dot] com> wrote:
Thanks Jan, that seemed like a plausible explanation, however I tried your solution exactly as described, but I still had the problem. The small scala project suffered from the same problem and had the same error in the workspace log. Perhaps the AJDT plugin somehow increases the load time for osgi bundles?

On Sun, Feb 1, 2009 at 3:36 AM, Miles Sabin <miles [at] milessabin [dot] com> wrote:
However, it's not currently possible to have mixed Scala and AspectJ
projects. This is partly a Scala Eclipse plugin limitation, but there
are also issues currently with ajc's ability to hand classfiles
generated by scalac. Anything that you can do to help with either end
of the problem would be very much appreciated.

I am not hoping to have aspectj apply advice to scalac class files, I only want ajdt to  continue to do what it did before with regular javac class files before I installed the scala plugin. I assume that the scala plugin doesnt much with the bytecode of the projects regular java class files?
Also, fyi, I am able to get the compilation and aspectj weaving to work fine using an ant build.

milessabin
Joined: 2008-08-11,
User offline. Last seen 33 weeks 3 days ago.
Re: Scala Eclipse Plugin Conflicts with AJDT

On Sun, Feb 1, 2009 at 8:55 PM, Gordon Leland Hempton
wrote:
> I am not hoping to have aspectj apply advice to scalac class files, I only
> want ajdt to continue to do what it did before with regular javac class
> files before I installed the scala plugin.

That should (and does for me) work just as you'd expect. If you can
put together a small reproducible test case for the problems you're
having that'd be very much appreciated.

Cheers,

Miles

Gordon Leland H...
Joined: 2009-02-01,
User offline. Last seen 42 years 45 weeks ago.
Re: Scala Eclipse Plugin Conflicts with AJDT
After lots of testing I have reduced it to a very simple case
1) Install a fresh copy of eclipse 3.4.12) Install latest AJDT 1.6.33) Install WTP and enable the Dynamic Web Module facet 4) Create a single java class5) Create an aspect with a pointcut on the class from step 3
At this point AJDT is working properly and the class is being correctly woven
6) Install Scala Plugin 2.6.3final
After step 6 is performed AJDT is no longer working and nothing is being woven. The error message from my previous emails usually shows up in the logs, but my gut intuition is that it is not the cause of the problem.
One thing that is interesting is that if I skip step 5, the class will be correctly woven. Has anyone else noticed a conflict between Scala and WTP?
Thanks,
On Sun, Feb 1, 2009 at 1:38 PM, Miles Sabin <miles [at] milessabin [dot] com> wrote:
On Sun, Feb 1, 2009 at 8:55 PM, Gordon Leland Hempton
<ghempton [at] gmail [dot] com> wrote:
> I am not hoping to have aspectj apply advice to scalac class files, I only
> want ajdt to  continue to do what it did before with regular javac class
> files before I installed the scala plugin.

That should (and does for me) work just as you'd expect. If you can
put together a small reproducible test case for the problems you're
having that'd be very much appreciated.

Cheers,


Miles

--
Miles Sabin
tel:    +44 (0)1273 720 779
mobile: +44 (0)7813 944 528
skype:  milessabin



--
Gordon Hempton
http://hempton.com
Gordon Leland H...
Joined: 2009-02-01,
User offline. Last seen 42 years 45 weeks ago.
Re: Scala Eclipse Plugin Conflicts with AJDT
I was able to make some progress.
If I change the project's Java facet from Java 6 to Java 5 the AJDT pointcuts are detected and woven as normal. However, this is still problematic since the project requires Java 6. Any ideas?

On Mon, Feb 2, 2009 at 9:09 PM, Gordon Leland Hempton <ghempton [at] gmail [dot] com> wrote:
After lots of testing I have reduced it to a very simple case
1) Install a fresh copy of eclipse 3.4.12) Install latest AJDT 1.6.33) Install WTP and enable the Dynamic Web Module facet 4) Create a single java class5) Create an aspect with a pointcut on the class from step 3
At this point AJDT is working properly and the class is being correctly woven
6) Install Scala Plugin 2.6.3final
After step 6 is performed AJDT is no longer working and nothing is being woven. The error message from my previous emails usually shows up in the logs, but my gut intuition is that it is not the cause of the problem.
One thing that is interesting is that if I skip step 5, the class will be correctly woven. Has anyone else noticed a conflict between Scala and WTP?
Thanks,
On Sun, Feb 1, 2009 at 1:38 PM, Miles Sabin <miles [at] milessabin [dot] com> wrote:
On Sun, Feb 1, 2009 at 8:55 PM, Gordon Leland Hempton
<ghempton [at] gmail [dot] com> wrote:
> I am not hoping to have aspectj apply advice to scalac class files, I only
> want ajdt to  continue to do what it did before with regular javac class
> files before I installed the scala plugin.

That should (and does for me) work just as you'd expect. If you can
put together a small reproducible test case for the problems you're
having that'd be very much appreciated.

Cheers,


Miles

--
Miles Sabin
tel:    +44 (0)1273 720 779
mobile: +44 (0)7813 944 528
skype:  milessabin



--
Gordon Hempton
http://hempton.com



--
Gordon Hempton
http://hempton.com
milessabin
Joined: 2008-08-11,
User offline. Last seen 33 weeks 3 days ago.
Re: Scala Eclipse Plugin Conflicts with AJDT

On Tue, Feb 3, 2009 at 5:09 AM, Gordon Leland Hempton
wrote:
> After lots of testing I have reduced it to a very simple case
> 1) Install a fresh copy of eclipse 3.4.1
> 2) Install latest AJDT 1.6.3
> 3) Install WTP and enable the Dynamic Web Module facet
> 4) Create a single java class
> 5) Create an aspect with a pointcut on the class from step 3
> At this point AJDT is working properly and the class is being correctly
> woven
> 6) Install Scala Plugin 2.6.3final
> After step 6 is performed AJDT is no longer working and nothing is being
> woven. The error message from my previous emails usually shows up in the
> logs, but my gut intuition is that it is not the cause of the problem.
> One thing that is interesting is that if I skip step 5, the class will be
> correctly woven. Has anyone else noticed a conflict between Scala and WTP?

Is it possible that aspectj is attempting to load-time weave Scala
bytecode (ie. of the plugin itself) and failing? As I said earlier,
aspectj chokes on at least some scalac generated bytecode.

Also it's not clear to me what kinds of projects you have in your
workspace at step (6) above ... do you have a Scala project? Are you
attempting to advise Java and/or Scala which is part of a Scala
project?

Cheers,

Miles

milessabin
Joined: 2008-08-11,
User offline. Last seen 33 weeks 3 days ago.
Re: Scala Eclipse Plugin Conflicts with AJDT

On Sun, Feb 1, 2009 at 11:01 AM, Jan Lohre wrote:
> This is a severe problem effectivly limiting workspace sizes, but I wonder
> why the plugin developers never stumbled over this, as the plugin for sure
> has a larger codebase than I have.
>
> I guess we should open a ticket.

Sorry, I missed this earlier.

Actually I see the timeout quite regularly. However, I've never seen
this cause a problem in practise ... yes, the timeout occurs and the
error is logged, but this doesn't seem to cause a problem with Eclipse
startup or with large Scala projects (eg. the compiler and plugin
themselves).

If you are having problems with large projects then I'd like to know more ...

Cheers,

Miles

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland