Kazuya Tomita Kazuya Tomita - 1 month ago 8
Java Question

"reference to Validator is ambiguous" in PlayFramework

I'm using PlayFramework 2.2.1 and the below code is my Entity class which belongs to Model:

package models;

import java.util.Date;
import java.util.List;

import javax.persistence.*;
import javax.validation.*;

import com.avaje.ebean.annotation.*;
import controllers.Application.FindForm; //this is a inner class for temporarily retaining a value from a form

import play.db.ebean.*;
import play.data.validation.*;
import play.data.validation.Constraints.*;

import controllers.Application.FindForm;
import play.data.Form;
import play.libs.F;
import play.mvc.Result;
import views.html.find;

@Entity
public class Message extends Model{

@Id
public Long id;

@Required(message = "This item is required.")
public String name;

@Email(message = "Enter your email address")
public String mail;

@Required
@MinLength(10)
@MaxLength(200)
@ValidateWith(value = IsUrl.class, message = "Fill in the message which starts URL")
public String message;

@CreatedTimestamp
public Date postdata;

public static Finder<Long, Message> find =
new Finder<Long, Message>(Long.class, Message.class);


@Override
public String toString() {
return ("[id:" + id + ", name:" + name + ", mail:" + mail +
", message:" + message + ", data:" + postdata + "]");
}

public static class IsUrl extends Validator<String> {

//this method is not strict, originally have to use regular expression.
public boolean isValid(Stirng s) {
return s.toLowerCase().startsWith("http://");
}

@Override
public F.Tuple<String, Object[]> getErrorMessage() {
return new F.Tuple<String, Object[]>("error.invalid", new String[]{});
}
}



}


There seem to be many questions related to this title in stackoverflow. And of all these questions, I think this might sound really relevant to my question.

How do I disambiguate in Scala between methods with vararg and without
But if you see this question, you will easily understand they are discussing about method, not class. And now I am facing compilation error which says:

reference to Validator is ambiguous


In my expectation, this is derived from Scala code which exists deep inside of Framework. So, I have no idea what to do and I exhaustively googled about this error message, but the problem still remains.

What should I do?

Answer

By Scary Wombat's useful comment, I could solve my problem. I no longer need any answer. Thank you so much, Scary.

Comments