Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.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
Hibernate Grails应用缺少GORM方法?_Hibernate_Maven_Grails_Gorm - Fatal编程技术网

Hibernate Grails应用缺少GORM方法?

Hibernate Grails应用缺少GORM方法?,hibernate,maven,grails,gorm,Hibernate,Maven,Grails,Gorm,我的团队一直在尝试将我们现有的Grails应用程序从1.3.7升级到2.1.0。在经历了很多挫折之后,包括更新了我们的整个测试套件,在我们的本地机器上,一切都按预期运行。然而,一旦我们将应用程序放在WAS8WebSphere服务器上,我们在尝试访问任何主页时都会遇到一个奇怪的错误。下面是一个例子 No signature of method: com.app.Product.findAll() is applicable for argument types: () values: [] Pos

我的团队一直在尝试将我们现有的Grails应用程序从1.3.7升级到2.1.0。在经历了很多挫折之后,包括更新了我们的整个测试套件,在我们的本地机器上,一切都按预期运行。然而,一旦我们将应用程序放在WAS8WebSphere服务器上,我们在尝试访问任何主页时都会遇到一个奇怪的错误。下面是一个例子

No signature of method: com.app.Product.findAll() is applicable for argument types: () values: []
Possible solutions: findAll(), findAll(), findAll(groovy.lang.Closure), findAll(java.lang.Object), findAll(java.lang.String), findAll(groovy.lang.Closure). Stacktrace follows:
groovy.lang.MissingMethodException: No signature of method: com.app.Product.findAll() is applicable for argument types: () values: []
Possible solutions: findAll(), findAll(), findAll(groovy.lang.Closure), findAll(java.lang.Object), findAll(java.lang.String), findAll(groovy.lang.Closure)
....
堆栈跟踪的下一步是:

....
Caused by: org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Runtime error executing action
... 47 more
Caused by: java.lang.reflect.InvocationTargetException
... 47 more
Caused by: groovy.lang.MissingMethodException: No signature of method: com.app.Product.findAll() is applicable for argument types: () values: []
Possible solutions: findAll(), findAll(), findAll(groovy.lang.Closure), findAll(java.lang.Object), findAll(java.lang.String), findAll(groovy.lang.Closure)
at com.app.controllers.DomainTablesController$_closure2.doCall(DomainTablesController.groovy:26)
... 47 more
我添加了一些测试代码进行检查,
findAll()
getAll()
,和
list()
方法都会抛出相同的错误。我不是Grails大师,但似乎缺少标准的GORM方法。我们使用Maven将Grails WAR打包到安装在服务器上的EAR中。下面是pom.xml的依赖项部分。它与使用
grailscreatepom
命令创建的干净版本相比只做了轻微修改

<dependencies>
    <dependency>
    <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-all</artifactId>
        <version>1.8.6</version>
    </dependency>

    <dependency>
        <groupId>org.grails</groupId>
        <artifactId>grails-dependencies</artifactId>
        <version>${grails.version}</version>
        <exclusions>                
            <exclusion>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
            </exclusion>            
        </exclusions>
        <type>pom</type>
    </dependency>

    <dependency>
        <groupId>org.grails</groupId>
        <artifactId>grails-plugin-testing</artifactId>
        <version>${grails.version}</version>
        <scope>test</scope>
    </dependency>

<dependency>
    <groupId>org.grails.plugins</groupId>
    <artifactId>mail</artifactId>
    <version>1.0.1</version>
    <scope>runtime</scope>
    <type>zip</type>
</dependency>

<dependency>
    <groupId>org.grails.plugins</groupId>
    <artifactId>jquery</artifactId>
    <version>1.7.2</version>
    <scope>runtime</scope>
    <type>zip</type>
</dependency>                    

<dependency>
    <groupId>org.grails.plugins</groupId>
    <artifactId>resources</artifactId>
    <version>1.1.6</version>
    <scope>runtime</scope>
    <type>zip</type>
</dependency>                    

<dependency>
    <groupId>org.grails.plugins</groupId>
    <artifactId>webxml</artifactId>
    <version>1.4.1</version>
    <scope>runtime</scope>
    <type>zip</type>
</dependency>
</dependencies>

驱动程序已经在我们部署到的服务器上设置好了,1.3.7版本在查找db2驱动程序或连接到数据库方面没有问题。想法?

我认为hibernate从2.0.*起被移动到了一个单独的依赖项,因此您可能需要添加以下
依赖项

<dependency>
  <groupId>org.grails</groupId>
  <artifactId>grails-hibernate</artifactId>
  <version>${grails.version}</version>
</dependency>
<dependency>
  <groupId>org.grails.plugins</groupId>
  <artifactId>hibernate</artifactId>
  <version>${grails.version}</version>
  <scope>compile</scope>
  <type>zip</type>
</dependency>

org.grails
. ;)


我要尝试的第一件事是使用grails WAR而不是Maven打包一场战争,看看这是否有效。如果是,问题在于Maven build.添加了Hibernate依赖项,删除了Groovy依赖项。构建EAR并在服务器上安装后,也会发生相同的错误。但它并没有更破碎,所以;这比我试过的其他东西都好。我们的计划是快速升级到2.1.0,然后在工作完成后再升级到最新版本。我一直想研究Gradle,因为我一直听说它对于依赖关系管理更好。不幸的是,我在一家大公司工作,所以任何这样的变更都需要一段时间才能获得批准。您还需要
hibernate
grails插件。补充回答。确保使用
mvn清洁安装-DappDeploy
(清洁安装部署)来获取新的依赖项。就升级而言,我宁愿尝试在2.3.7中创建一个全新的应用程序,并尝试将旧项目中的所有类/配置移植到新应用程序,确保所有测试都通过,并且应用程序按预期工作。添加grails hibernate插件导致新错误,这一次,在进入登录页面之前,抱怨缺少db2驱动程序。用stacktrace编辑的问题和更多信息。Mulligan!我没有添加-DappDeploy标志。用它重建的,它看起来像是在工作。非常感谢!
<dependency>
  <groupId>org.grails</groupId>
  <artifactId>grails-hibernate</artifactId>
  <version>${grails.version}</version>
</dependency>
<dependency>
  <groupId>org.grails.plugins</groupId>
  <artifactId>hibernate</artifactId>
  <version>${grails.version}</version>
  <scope>compile</scope>
  <type>zip</type>
</dependency>
<dependency>
    <groupId>org.codehaus.groovy</groupId>
    <artifactId>groovy-all</artifactId>
    <version>1.8.6</version>
</dependency>