4

I have a problem, that I can't properly run/debug my AspectJ project in Eclipse. My Launching settings are set to "Execute resource, or if not possible execute project". This is what I want and need, don't advice me to change it please.

My Problem now is that I have a project with 2 files:

  • Mainclass.java
  • MainclassHook.aj

If I select Mainclass.java in the project explorer he will ask me how to execute it (same happens if I select the project itself (but in the project he will search for main-Classes)):

Launch project/Mainclass.java

This will result in a new Run/Debug Configuration everytime I launch the project:

enter image description here

If I try to launch from MainclassHook.aj opened I get just a plain error (instead of Eclipse trying to launch the project, just as he does if I select the project and launch it)

enter image description here

Now I think the solution to this would be to add the AspectJ/Java Application into the projects Run/Debug Settings list, but for some reason I can't choose the AspectJ launch there:

Only shows java configurations

How can I achieve that my Eclipse will properly run either my currently selected file, or if it is not launchable, the associated project with a single Run/Debug Configuration which is an AspectJ/Java Application?

Cœur
  • 37,241
  • 25
  • 195
  • 267
th3falc0n
  • 1,389
  • 1
  • 12
  • 33
  • Sorry, a bounty is pretty much useless if you want a new feature or bugfix. I already told you in my answer where to create a ticket. You have not answered my question whether you have done that or maybe even found an existing ticket for this. You also have not told me if you have tried just running your AspectJ project with a simple Java run configuration. If you do not need anything special on *inpath* or *aspectpath*, this works. – kriegaex Jan 11 '15 at 13:56
  • I have not found an existing ticket, and I have not created a new one. I can't confirm that it is a bug, because it has already worked in the same configuration, with the same verions of AJDT and Eclipse, Of course I have not ran my project with a simple Java run configuration, cause that won't compile AspectJ code, which renders my project useless. In addition, Eclipse won't automatically start the project itself when trying to run a aspectJ assigned file, so it won't help to configure the project run. – th3falc0n Jan 11 '15 at 14:15

1 Answers1

2

I think your wish is a bit sophisticated. If the file is not launchable, why do you want to launch it? Anyway, I know what you mean. It works for Java projects but not 100% for AspectJ projects. If it does not work for your AspectJ files, just select an ancestor folder (e.g. src or project folder) containing a main class instead and the project launch config will be started.

If you want to raise a bug ticket for this little shortcoming in AJDT (AspectJ Development Tools), you can create it here. Probably it would be best to carefully describe the bug or just link to this question on StackOverflow.

kriegaex
  • 63,017
  • 15
  • 111
  • 202
  • The big problem that I am not able to add the AspectJ Launch to the projects default, so it won't really work out :| – th3falc0n Dec 20 '14 at 15:38
  • I always start my AspectJ projects as Java, not as AspectJ/Java. This works nicely. I do not work with project defaults, though. Give it a try. – kriegaex Dec 20 '14 at 16:52
  • I have a silly question but I need to ask it anyway, does MainclassHook.aj have a main method? @th3falc0n. if so, could you do the action depicted in the [image](https://dl.dropboxusercontent.com/u/15056258/try.png) – Hakan Özler Dec 22 '14 at 12:33
  • @Hakan: Why should an aspect have a main method? It contradicts the idea of a cross-cutting concern. It is technically possible, but does not make much sense. – kriegaex Dec 22 '14 at 14:36
  • I did create main methods in some aspects to practice AspectJ thats it. You are right @kriegaex . I just remember this case which may help his approach. – Hakan Özler Dec 22 '14 at 14:44
  • @Hakan No, MainclassHook.aj doesn't have a main method. – th3falc0n Dec 23 '14 at 21:16
  • Have you created a bug ticket? If so, please add a link to a self-written answer. – kriegaex Dec 23 '14 at 22:00