为什么 Grails 4.0.10 运行应用程序的行为一夜之间发生了变化?

发布于 2025-01-11 08:06:13 字数 2339 浏览 6 评论 0原文

我突然发现 Grails 插件中的类与 Grails 插件中的同一个类之间发生冲突。

Grails 通知插件有一个定义的骨架 User 类,以便提供 用于独立插件测试。 User 类是使用与以下相同的包定义的 主应用程序中真正的 User 类。插件 User 类未发布 插件 - 它被排除在 jar 之外。无论如何,应用程序类应该占主导地位, 并且没有关于重复类的运行时警告。插件 User 类位于 然而,插件源jar。这一直运作良好 - 直到现在。

所以,我不仅感到困惑,而且很担心,因为我们还包括了一些重复的内容 定义的实用程序类也被排除在插件 jar 之外 - 这些也会成为问题吗?

重要提示:这个问题昨天不存在!连夜公司保安应用了一些 更新并强制重新启动我们的计算机,因此 Intellij 尤其必须重新打开。 同事可以在他的计算机上复制相同的新行为,因此它不是本地缓存 我的计算机上出现问题 - 指向常见代码或构建问题? 我们通过 Intellij IDE 运行 run-app,但从 cmdline 调用 run-app 会出现同样的问题。

    // This Grails debug console code
    import com.penbaymedia.jdeis5.notification.service.EmailService // just to check existence
    
    def svc = ctx.getBean('emailService')   // in Grails Notification plugin
    
    def user = User.findByUsername('jphiloon')  // User defined in main app and in plugin
    
    svc.getEmail(user)
    
    /* Responds with this result:
    groovy.lang.MissingMethodException: No signature of method: com.penbaymedia.jdeis5.notification.service.EmailService.getEmail() is applicable for argument types: (com.penbaymedia.jdeis5.domainobject.User) values: [com.penbaymedia.jdeis5.domainobject.User : 5265]
    Possible solutions: getEmail(com.penbaymedia.jdeis5.domainobject.User), getClass(), sendMail(groovy.lang.Closure)
    The following classes appear as argument class and as parameter class, but are defined by different class loader:
    com.penbaymedia.jdeis5.domainobject.User (defined by 'org.springframework.boot.devtools.restart.classloader.RestartClassLoader@1378323c' and 'sun.misc.Launcher$AppClassLoader@18b4aac2')
    If one of the method suggestions matches the method you wanted to call, 
    then check your class loader setup.
    */

/* The error shown in the application run-app console is a bit different, but unproxying the User object does not help:
2022-03-02 11:20:00,270 ERROR com.penbaymedia.jdeis5.job.AssignmentNotificationIntervalJob - No signature of method: com.penbaymedia.jdeis5.notification.service.EmailService.getEmail() is applicable for argument types: (com.penbaymedia.jdeis5.domainobject.User$HibernateProxy$hgS4G0mO) values: [<com.penbaymedia.jdeis5.domainobject.User$HibernateProxy$hgS4G0mO@9c96547>]
Possible solutions: getEmail(com.penbaymedia.jdeis5.domainobject.User), getClass(), sendMail(groovy.lang.Closure)
*/

I am suddenly getting a conflict between a class in a Grails plugin and the same class in a Grails plugin.

Grails Notification plugin has a skeleton User class defined in order to provide
for stand-alone plugin testing. The User class is defined with the same package as
the real User class in the main app. The plugin User class is NOT published with
the plugin - it is excluded from the jar. In any case, the app class should predominate,
and there is no runtime warning about duplicate classes. The plugin User class is there in
the plugin sources jar, however. This has always worked fine - until now.

So, not only am I mystified, I'm also worried because we also include a number of duplicatively
defined utility classes that are also excluded from the plugin jars - will those also be a problem?

Important: this problem was not there yesterday! Overnight corporate security applied some
updates and forced a restart on our computers, so Intellij in particular had to be reopened.
A colleague can duplicate this same new behavior on his machine, so it's not a local cache
problem on my computer - pointing to a common code or build problem?
We are running run-app via the Intellij IDE, but invoking run-app from a cmdline exhibits the same problem.

    // This Grails debug console code
    import com.penbaymedia.jdeis5.notification.service.EmailService // just to check existence
    
    def svc = ctx.getBean('emailService')   // in Grails Notification plugin
    
    def user = User.findByUsername('jphiloon')  // User defined in main app and in plugin
    
    svc.getEmail(user)
    
    /* Responds with this result:
    groovy.lang.MissingMethodException: No signature of method: com.penbaymedia.jdeis5.notification.service.EmailService.getEmail() is applicable for argument types: (com.penbaymedia.jdeis5.domainobject.User) values: [com.penbaymedia.jdeis5.domainobject.User : 5265]
    Possible solutions: getEmail(com.penbaymedia.jdeis5.domainobject.User), getClass(), sendMail(groovy.lang.Closure)
    The following classes appear as argument class and as parameter class, but are defined by different class loader:
    com.penbaymedia.jdeis5.domainobject.User (defined by 'org.springframework.boot.devtools.restart.classloader.RestartClassLoader@1378323c' and 'sun.misc.Launcher$AppClassLoader@18b4aac2')
    If one of the method suggestions matches the method you wanted to call, 
    then check your class loader setup.
    */

/* The error shown in the application run-app console is a bit different, but unproxying the User object does not help:
2022-03-02 11:20:00,270 ERROR com.penbaymedia.jdeis5.job.AssignmentNotificationIntervalJob - No signature of method: com.penbaymedia.jdeis5.notification.service.EmailService.getEmail() is applicable for argument types: (com.penbaymedia.jdeis5.domainobject.User$HibernateProxy$hgS4G0mO) values: [<com.penbaymedia.jdeis5.domainobject.User$HibernateProxy$hgS4G0mO@9c96547>]
Possible solutions: getEmail(com.penbaymedia.jdeis5.domainobject.User), getClass(), sendMail(groovy.lang.Closure)
*/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文