Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Tomcat8上的Grails3:域类不能自己强制转换_Java_Tomcat_Grails_Casting_Tomcat8 - Fatal编程技术网

Java Tomcat8上的Grails3:域类不能自己强制转换

Java Tomcat8上的Grails3:域类不能自己强制转换,java,tomcat,grails,casting,tomcat8,Java,Tomcat,Grails,Casting,Tomcat8,我有一个在本地平台上运行的Grails3应用程序。但是,当我创建一个war文件(使用grailswar或grailspackage)并部署到tomcat8(8.5.5)上时。我有个错误 Class org.springframework.core.convert.ConverterNotFoundException Message : converter found capable of converting from type [Player] to type [Player] 这个错误对我

我有一个在本地平台上运行的Grails3应用程序。但是,当我创建一个war文件(使用
grailswar
grailspackage
)并部署到tomcat8(8.5.5)上时。我有个错误

Class org.springframework.core.convert.ConverterNotFoundException
Message : converter found capable of converting from type [Player] to type [Player]
这个错误对我来说毫无意义。但在执行此类代码时会引发此异常:

    def players = Player.all
    players.sort(new Comparator() {
        @Override
        int compare(o1, o2) {
            int p1followers = User.findAllByPlayer(o1).size()
            int p2followers = User.findAllByPlayer(o2).size()
            return p1followers > p2followers ? 1 : p1followers == p2followers ? 0 : -1
        }
    })
每次我试着“投”一个球员到另一个球员。。。与用户相同

如果我这样做:

List users = User.all
for(User u : users){}
我会有一个例外:“用户不能被强制转换为用户”

这里是User和Player域类(我删除了一些部分)

当我在intelijIDEA中运行grails应用程序时,这段代码有效,但当我在Tomcat8上部署war文件时,这段代码无效

在我的build.graddle中,我穿上了这个,前提是:

//compile "org.springframework.boot:spring-boot-starter-tomcat"
provided "org.springframework.boot:spring-boot-starter-tomcat"
如果您需要更多的代码,请告诉我并编辑


谢谢。

您使用的是哪一版本的grails 3?您是否尝试在本地主机上下载tomcat并在其上运行war以排除生产tomcat的错误配置?我使用的是grails 3.1.3。我将尝试在localhost上运行tomcat.Off-topic注释:该比较器代码似乎效率极低。您应该在本地(创建war文件时)、服务器甚至jdk上使用相同的tomcat和grails版本。我在本地尝试了tomcat,我也遇到了同样的问题。该项目仅与命令“grailsrunapp”一起工作。
//compile "org.springframework.boot:spring-boot-starter-tomcat"
provided "org.springframework.boot:spring-boot-starter-tomcat"