如何调试grails运行时异常?
我有一个 grails 项目和一个 java 项目。 java 项目是一组独立的 POJO 类,我只是将它们转储到我的 grails 项目下的 src/java 中。
在控制器中,我为此包添加了一条导入语句。
现在,当我执行 grails run-app 并尝试运行该程序时,我收到 grails 运行时异常。它说 NoClassDefFound 是我的一个 POJO 导入的包中的类。
错误消息显示在我的控制器的一行上,但缺少的类来自我的 POJO 所需的外部 jar。我将它所抱怨的 .jar 移至 grails 项目的 lib 文件夹中。我还需要做什么?
我如何找出导致此问题的真正原因?
谢谢!
I have a grails project and a java project. The java project was a standalone set of POJO classes, and I just dumped them into src/java under my grails project.
In the controller, I added an import statement for this package.
Now when I do a grails run-app and try to run the program, I get a grails runtime exception. It is saying NoClassDefFound for a class that is in a package that one of my POJOs imports.
The error message is showing on a line of my Controller, but the class that is missing is from an external jar that my POJO needed. I moved the .jar that it is complaining about to the grails project's lib folder. What else do I need to do?
How do I track down what is really causing this problem?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
低级方法:运行 ProcessMonitor (现在集成了以前的单独的文件监视器)。通过它你可以看到 JVM 正在搜索什么类文件。
另外,您可以将 -verbose:class 添加到 grails bin 目录下的 startGrails/startGrails.bat 中定义的 JAVA_OPTS 中。这将显示类加载器的输出(详细!)。
可能还需要其他 JAR。
a low-level approach: run ProcessMonitor (which now integrates the formerly separate File Monitor). With it you can see what class file the JVM is searching for.
Also, you can add -verbose:class to the JAVA_OPTS defined in startGrails/startGrails.bat in the bin directory of grails. This will show the output (verbose!) from the class loader.
Possibly there are other JARs that are needed.
您是否尝试过将此 jar 文件添加为 BuildConfig.groovy 的依赖项?
让 Grails 处理所有依赖项。
Have you tried adding this jar file as a dependency to BuildConfig.groovy?
Let Grails handle all dependencies.