我在运行Grails应用时遇到错误。
我在Grails 2.1.4中的应用程序。
我正在使用
Groovy 2.1.*
Java 1.7
Tomcat 7.0.37
我将我的应用程序从Grails 2.1.4升级到2.3.0.M1。在我收到这样的错误之后:
| Loading Grails 2.3.0.M1
| Configuring classpath
| Error SLF4J: Class path contains multiple SLF4J bindings.
| Error SLF4J: Found binding in [jar:file:/home/testuser/.m2/repository/org/grails/grails-plugin-log4j/2.3.0.M1/grails-plugin-log4j-2.3.0.M1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
| Error SLF4J: Found binding in [jar:file:/home/testuser/.m2/repository/org/slf4j/slf4j-log4j12/1.6.6/slf4j-log4j12-1.6.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
| Error SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
| Error SLF4J: Actual binding is of type [org.slf4j.impl.GrailsSlf4jLoggerFactory]
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application.....
| Compiling 143 source files.
Copying properties file...
| Compiling 143 source files.....
Updated web.xml for session information
| Running Grails application
/mycompany/dev/testuser/ws2/myapp\..\sub-app\deploy\dev\log4j.xml
| Running Grails application.
| Error SLF4J: Class path contains multiple SLF4J bindings.
| Error SLF4J: Found binding in [jar:file:/home/testuser/.m2/repository/org/grails/grails-plugin-log4j/2.3.0.M1/grails-plugin-log4j-2.3.0.M1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
| Error SLF4J: Found binding in [jar:file:/home/testuser/.m2/repository/org/slf4j/slf4j-log4j12/1.6.6/slf4j-log4j12-1.6.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
| Error SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
| Error SLF4J: Actual binding is of type [org.slf4j.impl.GrailsSlf4jLoggerFactory]
| Server running. Browse to http://localhost:8080/myapp
Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsApplication' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.GrailsConfigurationException: Class not found loading Grails application: myapp.RefreshCustomerMatrixJob
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.codehaus.groovy.grails.exceptions.GrailsConfigurationException: Class not found loading Grails application: myapp.RefreshCustomerMatrixJob
... 5 more
Caused by: java.lang.ClassNotFoundException: myapp.RefreshCustomerMatrixJob
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
... 5 more
Error initializing the application: Error creating bean with name 'grailsApplication' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.GrailsConfigurationException: Class not found loading Grails application: myapp.RefreshCustomerMatrixJob
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsApplication' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.GrailsConfigurationException: Class not found loading Grails application: myapp.RefreshCustomerMatrixJob
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.codehaus.groovy.grails.exceptions.GrailsConfigurationException: Class not found loading Grails application: myapp.RefreshCustomerMatrixJob
... 5 more
Caused by: java.lang.ClassNotFoundException: myapp.RefreshCustomerMatrixJob
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
... 5 more
| Error Exception in thread "Thread-7"
| Error java.lang.RuntimeException: Forked Grails VM exited with error
| Error at org.codehaus.groovy.grails.cli.fork.ForkedGrailsProcess$_attachOutputListener_closure5.doCall(ForkedGrailsProcess.groovy:220)
| Error at org.codehaus.groovy.grails.cli.fork.ForkedGrailsProcess$_attachOutputListener_closure5.doCall(ForkedGrailsProcess.groovy)
| Error at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| Error at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
| Error at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
| Error at java.lang.reflect.Method.invoke(Method.java:601)
| Error at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
| Error at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
| Error at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
| Error at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1085)
| Error at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
| Error at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
| Error at groovy.lang.Closure.call(Closure.java:411)
| Error at groovy.lang.Closure.call(Closure.java:405)
| Error at org.codehaus.groovy.grails.cli.fork.ForkedGrailsProcess.attachOutputListener(ForkedGrailsProcess.groovy:228)
| Error at org.grails.plugins.tomcat.fork.ForkedTomcatServer.attachOutputListener(ForkedTomcatServer.groovy)
| Error at org.codehaus.groovy.grails.cli.fork.ForkedGrailsProcess.attachOutputListener(ForkedGrailsProcess.groovy)
| Error at org.grails.plugins.tomcat.fork.ForkedTomcatServer.attachOutputListener(ForkedTomcatServer.groovy)
| Error at org.codehaus.groovy.grails.cli.fork.ForkedGrailsProcess.fork(ForkedGrailsProcess.groovy:172)
| Error at org.grails.plugins.tomcat.fork.ForkedTomcatServer.fork(ForkedTomcatServer.groovy)
| Error at org.codehaus.groovy.grails.cli.fork.ForkedGrailsProcess.fork(ForkedGrailsProcess.groovy:141)
| Error at org.grails.plugins.tomcat.fork.ForkedTomcatServer.fork(ForkedTomcatServer.groovy)
| Error at org.grails.plugins.tomcat.fork.ForkedTomcatServer$_startSecure_closure1.doCall(ForkedTomcatServer.groovy:122)
| Error at org.grails.plugins.tomcat.fork.ForkedTomcatServer$_startSecure_closure1.doCall(ForkedTomcatServer.groovy)
| Error at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| Error at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
| Error at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
| Error at java.lang.reflect.Method.invoke(Method.java:601)
| Error at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
| Error at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
| Error at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
| Error at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1085)
| Error at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
| Error at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
| Error at groovy.lang.Closure.call(Closure.java:411)
| Error at org.grails.plugins.tomcat.fork.ForkedTomcatServer$_startSecure_closure1.call(ForkedTomcatServer.groovy)
| Error at groovy.lang.Closure.call(Closure.java:405)
| Error at org.grails.plugins.tomcat.fork.ForkedTomcatServer$_startSecure_closure1.call(ForkedTomcatServer.groovy)
| Error at groovy.lang.Closure.run(Closure.java:492)
| Error at org.grails.plugins.tomcat.fork.ForkedTomcatServer$_startSecure_closure1.run(ForkedTomcatServer.groovy)
| Error at java.lang.Thread.run(Thread.java:722)
答案 0 :(得分:4)
我在How to migrate Grails 2.1 to Grails 2.3 application回答了类似的问题。总结一下,比较Config.groovy
& BuildConfig.groovy
到新Grails 2.3应用的默认版本。确保您的依赖项位于BuildConfig.groovy
而不是application.properties
,并且 Tomcat , Hibernate 和脚手架插件是正确的版本并且具有正确的范围(为 Tomcat插件构建, Hibernate的运行时)。
答案 1 :(得分:1)
我在错误日志中看到了这一行:
Error Exception in thread "Thread-7"
| Error java.lang.RuntimeException: Forked Grails VM exited with error
尝试评论 BuildConfig.groovy 的 grails.project.fork 部分
答案 2 :(得分:1)
我遇到了同样的错误,问题是代码中文件名和类名之间的字母大小写差异。确保您的班级名称和文件名完全匹配。
例如,我的文件名为OAuthCallBackController.groovy,类名为OauthCallBackController(注意小写'a')