Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AspectJ » Getting examples to run (run examples in Eclipse)
icon4.gif  Getting examples to run [message #555202] Wed, 25 August 2010 19:30 Go to next message
tom murphy is currently offline tom murphyFriend
Messages: 5
Registered: July 2009
Junior Member
fixes 'Selection does not contain a main type' error.

Install the AspectJ Development Tools, select new.../other... then open the AspectJ folder, open the AspectJ examples folder, install an example (I used the Tracing example).

Next, use the new... wizard to create an aspect (.aj) file in the top level source folder (tracing in my case). Then copy the aspectJ code from one of the sub folders (in my case, I copied the code in tracing/version1/TraceMyClasses.aj) into your new aspect file. Then, expand the .aj file in the explorer, right click on the *main* method, select run as *java* application. Obvious isn't it?
Re: Getting examples to run [message #555217 is a reply to message #555202] Wed, 25 August 2010 21:45 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
If I follow your steps exactly, then the result is a compile error.

Ie- you don't mention changing package names, and you don't mention copying over Trace.java.

After I do that and make the project compile cleanly, I can right-click and run the main method from within the aspect as expected.

Make sure that the project compiles cleanly and then try again. Also, make sure that you have JDT Weaving enabled.

If you do both of those and still have a problem, please raise bug on bugzilla and attach the project (or if you can, attach the project to this mailing list thread).
Re: Getting examples to run [message #555228 is a reply to message #555217] Wed, 25 August 2010 23:15 Go to previous messageGo to next message
tom murphy is currently offline tom murphyFriend
Messages: 5
Registered: July 2009
Junior Member
Thanks for the additional info (after all the trouble I had getting this to work, I just assumed anyone able to get that far would know to fixup the package names and copy the helper classes). But you also mention having JDT weaving enabled. How do I do that????
Re: Getting examples to run [message #555231 is a reply to message #555228] Wed, 25 August 2010 23:58 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
When you create an aspectj project for the first time, you should have been prompted to enable JDT Weaving and then prompted to restart.

If not, you can go to your Preferences -> JDT Weaving and enable it there (restart is necessary). You can also see if it is already enabled.

Turning on JDT weaving will enable certain AJDT behavior such AspectJ-aware searching and content assist. This includes searching for main methods.
Re: Getting examples to run [message #601230 is a reply to message #555202] Wed, 25 August 2010 21:45 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
If I follow your steps exactly, then the result is a compile error.

Ie- you don't mention changing package names, and you don't mention copying over Trace.java.

After I do that and make the project compile cleanly, I can right-click and run the main method from within the aspect as expected.

Make sure that the project compiles cleanly and then try again. Also, make sure that you have JDT Weaving enabled.

If you do both of those and still have a problem, please raise bug on bugzilla and attach the project (or if you can, attach the project to this mailing list thread).
Re: Getting examples to run [message #601237 is a reply to message #601230] Wed, 25 August 2010 23:15 Go to previous messageGo to next message
tom murphy is currently offline tom murphyFriend
Messages: 5
Registered: July 2009
Junior Member
Thanks for the additional info (after all the trouble I had getting this to work, I just assumed anyone able to get that far would know to fixup the package names and copy the helper classes). But you also mention having JDT weaving enabled. How do I do that????
Re: Getting examples to run [message #601241 is a reply to message #601237] Wed, 25 August 2010 23:58 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
When you create an aspectj project for the first time, you should have been prompted to enable JDT Weaving and then prompted to restart.

If not, you can go to your Preferences -> JDT Weaving and enable it there (restart is necessary). You can also see if it is already enabled.

Turning on JDT weaving will enable certain AJDT behavior such AspectJ-aware searching and content assist. This includes searching for main methods.
Re: Getting examples to run [message #769366 is a reply to message #555231] Wed, 21 December 2011 22:39 Go to previous messageGo to next message
Steve Cohen is currently offline Steve CohenFriend
Messages: 46
Registered: July 2009
Member
I have a similar problem. Six months ago, using Eclipse Helios, I created an Aspect J project and used it to weave around a Java project. Haven't used the AspectJ at all since then. I had need of it, so I resurrected it again. In the meantime I had upgraded to Eclipse Indigo and had not added the AspectJ Plugin. After adding it and trying to launch the Aspect J program wrapping my Java program, I get the 'Selection does not contain a main type' error, even though I can clearly see the main method and even though JDT weaving is already enabled. Any ideas? This all worked before the Eclipse upgrade.
Re: Getting examples to run [message #769376 is a reply to message #769366] Wed, 21 December 2011 23:11 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
Is the main method in an aspect or a class? In a java file or an aj file? Any exceptions in your error log?

Re: Getting examples to run [message #874400 is a reply to message #769376] Sun, 20 May 2012 19:44 Go to previous messageGo to next message
Arjie Cristobal is currently offline Arjie CristobalFriend
Messages: 1
Registered: May 2012
Junior Member
Hi Andrew,

I'm getting the same issue. I tried your suggestion above but I'm still getting the error.

Here is what is displayed in Error Log of eclipse:

Quote:
Unable to create editor ID org.eclipse.jdt.ui.CompilationUnitEditor: The file does not exist.
src/tracing/lib[Tracing Example] does not exist



Thanks,
Arjie
Re: Getting examples to run [message #874408 is a reply to message #874400] Sun, 20 May 2012 20:19 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
@ Arjie can you attach a full stack trace of the problem? Go to Window -> Show view -> Other -> Error log.

Find the relevant entry and copy/paste.
Re: Getting examples to run [message #881064 is a reply to message #874408] Sun, 03 June 2012 20:17 Go to previous messageGo to next message
Richard Stranberg is currently offline Richard StranbergFriend
Messages: 2
Registered: June 2012
Junior Member
Hi Andrew,

I am having the same problem after upgrading a bunch of stuff. I found this thread through a google search of the error.

Here is the stack trace:
org.eclipse.core.runtime.CoreException: The file does not exist.
at org.eclipse.core.internal.filebuffers.ResourceFileBuffer.create(ResourceFileBuffer.java:237)
at org.eclipse.core.internal.filebuffers.TextFileBufferManager.connect(TextFileBufferManager.java:112)
at org.eclipse.ui.editors.text.TextFileDocumentProvider.createFileInfo(TextFileDocumentProvider.java:559)
at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.createFileInfo(CompilationUnitDocumentProvider.java:969)
at org.eclipse.ui.editors.text.TextFileDocumentProvider.connect(TextFileDocumentProvider.java:478)
at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.connect(CompilationUnitDocumentProvider.java:1229)
at org.eclipse.ui.texteditor.AbstractTextEditor.doSetInput(AbstractTextEditor.java:4056)
at org.eclipse.ui.texteditor.StatusTextEditor.doSetInput(StatusTextEditor.java:217)
at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.doSetInput(AbstractDecoratedTextEditor.java:1444)
at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.internalDoSetInput(JavaEditor.java:2578)
at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.doSetInput(JavaEditor.java:2551)
at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.doSetInput(CompilationUnitEditor.java:1371)
at org.eclipse.ui.texteditor.AbstractTextEditor$19.run(AbstractTextEditor.java:3043)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:759)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:756)
at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2606)
at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3061)
at org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTextEditor.java:3088)
at org.eclipse.ui.internal.EditorManager.createSite(EditorManager.java:798)
at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:647)
at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:465)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313)
at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1254)
at org.eclipse.ui.internal.PartStack.handleDeferredEvents(PartStack.java:1222)
at org.eclipse.ui.internal.LayoutPart.deferUpdates(LayoutPart.java:400)
at org.eclipse.ui.internal.PartSashContainer.handleDeferredEvents(PartSashContainer.java:1409)
at org.eclipse.ui.internal.LayoutPart.deferUpdates(LayoutPart.java:400)
at org.eclipse.ui.internal.WorkbenchPage.handleDeferredEvents(WorkbenchPage.java:1420)
at org.eclipse.ui.internal.WorkbenchPage.deferUpdates(WorkbenchPage.java:1410)
at org.eclipse.ui.internal.WorkbenchPage.closeEditors(WorkbenchPage.java:1384)
at org.eclipse.ui.internal.WorkbenchPage.closeEditor(WorkbenchPage.java:1439)
at org.eclipse.ui.internal.EditorPane.doHide(EditorPane.java:61)
at org.eclipse.ui.internal.PartStack.close(PartStack.java:541)
at org.eclipse.ui.internal.EditorStack.close(EditorStack.java:206)
at org.eclipse.ui.internal.PartStack$1.close(PartStack.java:120)
at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation$1.handleEvent(TabbedStackPresentation.java:83)
at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:269)
at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:278)
at org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder.access$1(DefaultTabFolder.java:1)
at org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder$1.closeButtonPressed(DefaultTabFolder.java:71)
at org.eclipse.ui.internal.presentations.PaneFolder.notifyCloseListeners(PaneFolder.java:631)
at org.eclipse.ui.internal.presentations.PaneFolder$3.close(PaneFolder.java:206)
at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1595)
at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:261)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
at org.eclipse.equinox.launcher.Main.run(Main.java:1408)


I have Eclipse IDE for Java Developers
Version: Helios Service Release 2
Build id: 20110301-1815

I've done everything I can think of, deleting the project, going to an older version of my project, etc. nothing seems to work. Cleaning, etc. etc.

When I look at main.xml, displaying the graphical plainly doesn't work. And in my main acitvity for the code:

setContentView(R.layout.main);

I get the error: main cannot be resolved or is not a field

Thanks a lot,

Rick
Re: Getting examples to run [message #881151 is a reply to message #881064] Mon, 04 June 2012 02:09 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
Rick, I'm not sure that you have the right thread. Are you trying to launch an AspectJ project? main.xml is not typically part of an AspectJ program

What were you trying to do when you got that exception?.
Re: Getting examples to run [message #881644 is a reply to message #881151] Tue, 05 June 2012 01:23 Go to previous messageGo to next message
Richard Stranberg is currently offline Richard StranbergFriend
Messages: 2
Registered: June 2012
Junior Member
Hi Andrew,

I don't think I do actually. I was simply trying to do a build of the project. It was conking out immediately trying to resolve some of the R ids. It had taken place after I did a bunch of updates on everything.
I did find the solution to my problem however. Actually changing an import from
import android.R;

to
import you.package.R;

did the trick.

Maybe you could tell me what changed out of curiosity.

Anyway, thank you for your attention.

Rick
Re: Getting examples to run [message #881669 is a reply to message #881644] Tue, 05 June 2012 03:14 Go to previous message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
You are looking for the ADT (Android Development Tools). This is AJDT, AspectJ Development Tools.
Previous Topic:Bundle 'org.aspectj.runtime' cannot be resolved
Next Topic:org.eclipse.ajdt.javamodel.CompilationUnitFilter error on Eclipse startup
Goto Forum:
  


Current Time: Tue Mar 19 08:34:06 GMT 2024

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

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

Back to the top