[英]Grails domain class has no setter method after implement interface
I have two java interface: 我有两个Java接口:
public interface ProductRevision {
String getName();
public ComponentRevision getTiedComponent();
}
public interface ComponentRevision {
String getName();
}
And then I define two Grails domain class: 然后定义两个Grails域类:
class GormProductRevision implements ProductRevision {
String name
GormComponentRevision tiedComponent
}
class GormComponentRevision implements ComponentRevision {
String name
}
There is no compile error, However when I call below controller: 没有编译错误,但是当我在控制器下面调用时:
class GormProductRevisionController {
def save() {
GormComponentRevision gormComponentRevision = new GormComponentRevision()
gormComponentRevision.name = 'Component'
gormComponentRevision.save()
GormProductRevision gormProductRevision = new GormProductRevision()
gormProductRevision.name = 'Product'
gormProductRevision.tiedComponent = gormComponentRevision
gormProductRevision.save()
}
}
it throws exception 它引发异常
Property 'tiedComponent' has no setter method in class 'class GormProductRevision'. Stacktrace follows:
Message: Property 'tiedComponent' has no setter method in class 'class GormProductRevision'
Line | Method
->> 2138 | setSimpleProperty in org.apache.commons.beanutils.PropertyUtilsBean
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1957 | setNestedProperty in ''
| 2064 | setProperty . . . in ''
| 858 | setProperty in org.apache.commons.beanutils.PropertyUtils
| 31 | save . . . . . . in GormProductRevisionController
| 195 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter . . . . in grails.plugin.cache.web.filter.AbstractFilter
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run . . . . . . . in ''
^ 619 | run in java.lang.Thread
Could anybody help me? 有人可以帮我吗?
(Sorry, I don't have the reputation to 'comment' yet.) (对不起,我还没有“评论”的声誉。)
I am seeing a strange version of this bug as well. 我也看到了这个错误的奇怪版本。 And I wish what I could add was concrete.
我希望我能补充的是具体的。 But for me, I only see this issue sometimes.
但是对我来说,有时我只会看到这个问题。 I have a domain class that implements two interfaces and all is well in testing including deploying a war on my local (Mac) machine to tomcat.
我有一个实现两个接口的域类,并且都很好地进行了测试,包括在本地(Mac)计算机上向tomcat部署war。
When I deploy it in ec2 (ubuntu) on tomcat, sometimes this bug occurs, sometimes not. 当我将它部署在tomcat的ec2(ubuntu)中时,有时会出现此错误,有时不会。 I thought it was that I had modified the domain object but with the datasource in 'update' (not 'create-drop') that there was some mismatch.
我以为是我修改了域对象,但是在“更新”(不是“创建-放置”)中的数据源存在一些不匹配。 One time I dropped the database and let it recreate and the problem went away.
有一次,我删除了数据库并让它重新创建,问题就消失了。 But I'm seeing the problem again and I haven't touch that domain class in a while.
但是我又遇到了问题,而且我已经有一段时间没有接触过该域类了。
I have found a workaround: take the datasource from create-drop to update, but then drop the database (using mysql or whatever your db client is), then let grails recreate the system. 我找到了一种解决方法:将数据源从create-drop进行更新,然后删除数据库(使用mysql或任何您的数据库客户端),然后让grails重新创建系统。 Could there be a problem in create-drop?
create-drop可能有问题吗? Maybe.
也许。 Could it be my brain?
难道是我的大脑? Absolutely!
绝对!
So I'm not sure this is the same problem, or it mine is just something different and stupid but I wanted to add that I think I'm seeing something like this as well. 所以我不确定这是同一个问题,还是我的只是一个不同而又愚蠢的问题,但是我想补充一点,我想我也看到了类似的事情。
BTW, this class, just to give you all the details, has a transient byte[] field for a file upload. 顺便说一句,该类仅是为了向您提供所有详细信息,它具有用于文件上传的瞬态byte []字段。 And that was NOT set to bindable until just now.
直到现在,这还没有设置为可绑定 。 And, not to hijack the thread, but that 'transients are no longer bound by default' acts weirdly and could maybe be related to my problems.
而且,不是要劫持线程,而是“瞬态不再默认绑定”的行为很怪异,可能与我的问题有关。 No non-bound transients for OP's original question, right?
OP的原始问题没有非绑定瞬态,对吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.