Grails 2.3.4 War在Tomcat 7.0.47中无法正常工作
使用Grails 2.3.4 War在Tomcat 7.0.47中无法正常工作,grails,tomcat7,Grails,Tomcat7,使用grailsrun-app运行应用程序工作正常,但在Tomcat7中部署后,我会遇到以下错误 groovy.lang.MissingMethodException: No signature of method: static com.digithurst.hdspro.web.Responder.respond() is applicable for argument types: (ResourceListCmd, QueryCmd, groovy.util.ConfigObject
grailsrun-app
运行应用程序工作正常,但在Tomcat7中部署后,我会遇到以下错误
groovy.lang.MissingMethodException:
No signature of method: static com.digithurst.hdspro.web.Responder.respond()
is applicable for argument types: (ResourceListCmd, QueryCmd, groovy.util.ConfigObject)
values: [ResourceListCmd@5c380e, ...]
Possible solutions: respond(HttpResource, java.lang.Object, java.lang.String)
如前所述,它在Tomcat之外工作。方法的调用方式与实现方式完全相同。ResourceListCmd
实现了接口HttpResource
,这使它非常适合。如果第一个参数为null
,也会发生此错误
groovy.lang.MissingMethodException:
No signature of method: static com.digithurst.hdspro.web.Responder.respond()
is applicable for argument types: (null, QueryCmd, groovy.util.ConfigObject)
values: [null, ...]
Possible solutions: respond(HttpResource, java.lang.Object, java.lang.String)
更多关于环境的信息:
- Windows 7 64位
- Java 7 U45 x86
- Grails2.3.4
- Tomcat 7.0.47
.grails
和.m2
文件夹,并在创建war文件之前执行了grails clean
操作
[回答H3rnst后编辑]
控制器:
def index() {
try {
ResourceListCmd configs = configService.search()
respond Responder.respond(configs, new QueryCmd(level: 'list'),
grailsApplication.config.grails.serverURL)
}
catch (Exception e) {
render status: INTERNAL_SERVER_ERROR
}
}
interface HttpResource {
...
}
abstract class AbstractHttpResource implements HttpResource {
...
}
class ResourceListCmd extends AbstractHttpResource {
...
}
ResourceListCmd:
def index() {
try {
ResourceListCmd configs = configService.search()
respond Responder.respond(configs, new QueryCmd(level: 'list'),
grailsApplication.config.grails.serverURL)
}
catch (Exception e) {
render status: INTERNAL_SERVER_ERROR
}
}
interface HttpResource {
...
}
abstract class AbstractHttpResource implements HttpResource {
...
}
class ResourceListCmd extends AbstractHttpResource {
...
}
响应者:
class Responder {
static def respond(HttpResource resource, def query, String serverURL) {
...
}
}
war(或tomcat服务器类路径)包含重复或错误版本的jar,该jar包含com.digithurst.hdspro.web.Responder类。(您正在使用开发run应用程序启动的类的版本与运行war的tomcat加载不同)
您可以尝试解包war端,验证有问题jar的版本和/或使用类似于扫描重复类的工具
您甚至可以尝试使用该命令并搜索相同库的重复注入。可能是您正在使用的两个不同插件合并到了同一个库的不同版本中导致了问题。建议执行运行war
实际上给出了解决问题的最终线索。这不是Tomcat的问题,而是应用程序运行的环境问题runapp
和runwar
默认情况下都使用“开发”环境,因此可以正常工作。只有在“生产”中没有,这是部署到Tomcat时使用的
真正的罪魁祸首是配置的一部分,错误消息是正确的,尽管出乎意料。我正在使用grailsApplication.config.grails.serverURL
调用Responder.respond()
方法。serverURL
仅在“开发”模式下设置,而未在“生产”模式下设置。这就是Groovy/Java抱怨方法签名的原因:
(ResourceListCmd, QueryCmd, groovy.util.ConfigObject) vs (HttpResource, java.lang.Object, java.lang.String)
线索是最后一个参数,前两个是正确的。但是,我本来希望
null
作为值,而不是一个完全不同的类型。是运行war还是运行应用程序工作?我没有尝试run war
(不知道该命令),但正如开头一句所写,run app
确实工作。我有一个类似的问题,run app工作正常,但run war不工作,你能试一试吗?我当然能,但那有什么帮助呢?但这必须等到周一,因为这个类是我写的,所以不是任何第三方库的一部分。不过,我会看看战争的内部情况。Jarscan只显示了一个出现在Responder
中的类,就是我编写的那个类。我也曾经看过.class
,这是意料之中的。