Skip to content
This repository has been archived by the owner on Feb 9, 2019. It is now read-only.

The method to set the recipient is not recognised. #92

Open
Archangelix opened this issue Oct 23, 2013 · 2 comments
Open

The method to set the recipient is not recognised. #92

Archangelix opened this issue Oct 23, 2013 · 2 comments

Comments

@Archangelix
Copy link

Hi,
I'm still relatively new to Scala and Play. Please bear with me if I'm missing anything here. I'm getting an error while trying to set the recipient.

[RuntimeException: java.lang.NoSuchMethodError: com.typesafe.plugin.MailerAPI.setRecipient([Ljava/lang/String;)Lcom/typesafe/plugin/MailerAPI;]

This is the method calling the mailer API:

  def send = Action { implicit req =>
    val mail = use[MailerPlugin].email
    mail.setSubject("mailer")
    mail.setRecipient("Iwan Satria <[email protected]>")
    mail.setFrom("Peter Hausel <[email protected]>")
    //sends html
    mail.sendHtml("<html>html</html>")
    Ok(views.html.homepage(loginForm)(session))
  }

I have checked the codes in MailerPlugin.scala and the method does exist in the MailerBuilder trait but not in MailerAPI.

I'm not sure where the problem is. Is there anything else that I need to check?

@jroper
Copy link
Member

jroper commented Oct 23, 2013

MailerAPI extends MailerApiJavaInterop, which is where the method is defined. I didn't write the code, but I would guess the reason for this interface is that varargs in Java and Scala work differently, so the interface needs to be declared in Java.

https://github.com/typesafehub/play-plugins/blob/master/mailer/src/main/scala/com/typesafe/plugin/MailerApiJavaInterop.java

As for why this isn't working, could be you have different versions of the mailer plugin on the classpath, or maybe there's a scala compiler bug.

@Archangelix
Copy link
Author

Thank you for the kind reply.

These are the versions I'm using in my application. Is there any incompatibility between them?

  • play! 2.1.1
  • Java 1.7.0_40 and
  • Scala 2.10.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants