Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » InvocationTargetException
InvocationTargetException [message #460716] Mon, 05 September 2005 08:00 Go to next message
Eclipse UserFriend
Originally posted by: qminor.austin.rr.com

I am getting an error that I don't understand and I can't get around it. I
am trying to build an email application using JavaMail and I am receiving
the InvocationTargetException. What does this exception catch? Can anyone
help?

This is the error:

java.lang.reflect.InvocationTargetException
at org.eclipse.jface.operation.ModalContext.run(ModalContext.ja va:327)
at com.crypto.ui.menu_actions.SendAction.run(SendAction.java:41 )
at org.eclipse.jface.action.Action.runWithEvent(Action.java:996 )
at
org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:538)
at
org.eclipse.jface.action.ActionContributionItem.access$2(Act ionContributionItem.java:488)
at
org.eclipse.jface.action.ActionContributionItem$6.handleEven t(ActionContributionItem.java:441)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3080)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2713)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:809 )
at org.eclipse.jface.window.Window.open(Window.java:787)
at com.crypto.ui.Crypto.run(Crypto.java:72)
at com.crypto.ui.Crypto.main(Crypto.java:216)
Caused by: org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:2942)
at org.eclipse.swt.SWT.error(SWT.java:2865)
at org.eclipse.swt.SWT.error(SWT.java:2836)
at org.eclipse.swt.widgets.Widget.error(Widget.java:395)
at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:298)
at org.eclipse.swt.widgets.Text.getText(Text.java:851)
at com.crypto.ui.Crypto.getTxtTo(Crypto.java:205)
at com.crypto.ui.menu_actions.SendAction$1.run(SendAction.java: 55)
at
org.eclipse.jface.operation.ModalContext$ModalContextThread. run(ModalContext.java:113)


Here is the code:

public class SendAction extends Action {

private Properties props;

private String host = "smtp-server.austin.rr.com";

private Session session;

private String from = "qminor@austin.rr.com";

public SendAction() {
super("Send");
setImageDescriptor(ImageDescriptor.createFromFile(SendAction .class,
"/com/crypto/images/sendmsg.gif"));
setToolTipText("Send");
// TODO Auto-generated constructor stub
}

public void run() {
try {
ModalContext.run(new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {

try {
progressMonitor.beginTask("Sending",
IProgressMonitor.UNKNOWN);
props = System.getProperties();
props.put("mail.smtp.host", host);

session = Session.getDefaultInstance(props, null);

MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(Crypto.getApp().getTxtTo()));
message.setSubject(Crypto.getApp().getTxtSubject());
message.setText("This is a test");
Transport.send(message);
progressMonitor.done();
Crypto.getApp().refreshView();

} catch (AddressException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}, true, Crypto.getApp().slm.getProgressMonitor(),
Crypto.getApp().getShell()
.getDisplay());
} catch (InterruptedException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} finally {
Crypto.getApp().refreshView();
}
}

}
Re: InvocationTargetException [message #460718 is a reply to message #460716] Mon, 05 September 2005 12:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

"Quincy Minor" <qminor@austin.rr.com> wrote in message
news:92e9a538482e5348b6bb4a77962ca195$1@www.eclipse.org...
>I am getting an error that I don't understand and I can't get around it. I
>am trying to build an email application using JavaMail and I am receiving
>the InvocationTargetException. What does this exception catch? Can anyone
>help?
>
You cannot make a UI call in a non-UI thread.
Look at the stack trace.
---
Sunil
Re: InvocationTargetException [message #460725 is a reply to message #460718] Mon, 05 September 2005 16:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: qminor.austin.rr.com

So how can I fix this?
Re: InvocationTargetException [message #460727 is a reply to message #460725] Mon, 05 September 2005 19:02 Go to previous message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

"Quincy Minor" <qminor@austin.rr.com> wrote in message
news:d1aa77d3b930b30dd2e6212e786a2ef9$1@www.eclipse.org...
> So how can I fix this?
>
Don't do UI operations in a non-UI thread.
See Display.syncExec() and Display.asyncExec().
---
Sunil
Previous Topic:Customizing TreeItem ?
Next Topic:"Hello World" Post !
Goto Forum:
  


Current Time: Wed Apr 24 22:00:48 GMT 2024

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

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

Back to the top