在 CloudFoundry 中运行 RabbitMQ 时出现 NoSuchMethodError

发布于 2024-12-18 03:00:08 字数 4056 浏览 1 评论 0 原文

我最近设置了一个 SpringSource CloudFoundry 微云实例,并尝试使用此处找到的 RabbitMQ(带代码)运行相当简短的消息传递示例:

http://support.cloudfoundry.com/entries/20322602-getting-started-with-the-rabbitmq-service-from-a-spring-application

应用程序的公共工作实例此处提供:

http://rabbit-simple.cloudfoundry.com

当我尝试执行此操作时,环境会设置如果正确启动,代码可以毫无问题地构建、部署(使用 vmc 命令行工具)并绑定到rabbitmq 服务。以下是运行“vmc 应用程序”的控制台输出:

Macintosh-2:target wlaprise$ vmc push rabbit-simple
Would you like to deploy from the current directory? [Yn]: y
Application Deployed URL ["rabbit-simple.c3works.cloudfoundry.me"]: 
Detected a Java SpringSource Spring Application, is this correct? [Yn]: y
Memory Reservation ("64M", "128M", "256M", "512M", "1G") ["512M"]: 
Creating Application: OK
Would you like to bind any services to 'rabbit-simple'? [yN]: y
The following system services are available
1: mongodb
2: mysql
3: postgresql
4: rabbitmq
5: redis
Please select one you wish to provision: 4
Specify the name of the service ["rabbitmq-fad62"]: 
Creating Service: OK
Binding Service [rabbitmq-fad62]: OK
Uploading Application:
  Checking for available resources: OK
  Processing resources: OK
  Packing application: OK
  Uploading (2K): OK   
Push Status: OK
Staging Application: OK                                                         
Starting Application: OK                                                        

Macintosh-2:target wlaprise$ vmc apps

+---------------+----+---------+---------------------------------------+----------------+
| Application   | #  | Health  | URLS                                  | Services       |
+---------------+----+---------+---------------------------------------+----------------+
| rabbit-simple | 1  | RUNNING | rabbit-simple.c3works.cloudfoundry.me | rabbitmq-fad62 |
+---------------+----+---------+---------------------------------------+----------------+

当我尝试从浏览器运行该应用程序时,它最初会正确显示输入表单,但是当我输入消息并点击“发布”时,我会返回 500 错误

Exception--------
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.springframework.amqp.core.MessageProperties.getReplyTo()Lorg/springframework/amqp/core/Address;
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:839)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause
java.lang.NoSuchMethodError: org.springframework.amqp.core.MessageProperties.getReplyTo()Lorg/springframework/amqp/core/Address;
    org.springframework.amqp.rabbit.support.DefaultMessagePropertiesConverter.fromMessageProperties(DefaultMessagePropertiesConverter.java:120)
    org.springframework.amqp.rabbit.core.RabbitTemplate.doSend(RabbitTemplate.java:365)
    org.springframework.amqp.rabbit.core.RabbitTemplate$1.doInRabbit(RabbitTemplate.java:164)
    org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:330)
    org.springframework.amqp.rabbit.core.RabbitTemplate.send(RabbitTemplate.java:162)
    org.springframework.amqp.rabbit.core.RabbitTemplate.convertAndSend(RabbitTemplate.java:179)
    org.springframework.amqp.rabbit.core.RabbitTemplate.convertAndSend(RabbitTemplate.java:175)
    com.c3works.msg.HomeController.publish(HomeController.java:25)

:有人成功完成此操作并知道我可能做错了什么(RabbitMQ 问题、CloudFoundry 问题、我自己的问题:0 )?

我所做的唯一与 SpringSource 教程代码不同的事情是将 HomeController 中的返回字符串更改为: 返回“WEB-INF/views/home.jsp”; 到 “home”与 spring-context.xml 文件中设置 viewResolver 的方式保持一致(这对于正确显示输入表单是必要的)。

谢谢。

I recently set a SpringSource CloudFoundry micro cloud instance and am trying to run through their fairly brief messaging example using RabbitMQ found here (with code):

http://support.cloudfoundry.com/entries/20322602-getting-started-with-the-rabbitmq-service-from-a-spring-application

A public working instance of the app is provided here:

http://rabbit-simple.cloudfoundry.com

When I attempt this, the environment sets up properly, the code builds, deploys (using the vmc command line tools) and binds to a rabbitmq service without issue. Here is the console output from running ‘vmc apps’:

Macintosh-2:target wlaprise$ vmc push rabbit-simple
Would you like to deploy from the current directory? [Yn]: y
Application Deployed URL ["rabbit-simple.c3works.cloudfoundry.me"]: 
Detected a Java SpringSource Spring Application, is this correct? [Yn]: y
Memory Reservation ("64M", "128M", "256M", "512M", "1G") ["512M"]: 
Creating Application: OK
Would you like to bind any services to 'rabbit-simple'? [yN]: y
The following system services are available
1: mongodb
2: mysql
3: postgresql
4: rabbitmq
5: redis
Please select one you wish to provision: 4
Specify the name of the service ["rabbitmq-fad62"]: 
Creating Service: OK
Binding Service [rabbitmq-fad62]: OK
Uploading Application:
  Checking for available resources: OK
  Processing resources: OK
  Packing application: OK
  Uploading (2K): OK   
Push Status: OK
Staging Application: OK                                                         
Starting Application: OK                                                        

Macintosh-2:target wlaprise$ vmc apps

+---------------+----+---------+---------------------------------------+----------------+
| Application   | #  | Health  | URLS                                  | Services       |
+---------------+----+---------+---------------------------------------+----------------+
| rabbit-simple | 1  | RUNNING | rabbit-simple.c3works.cloudfoundry.me | rabbitmq-fad62 |
+---------------+----+---------+---------------------------------------+----------------+

When I try to run the app from a browser, it initially displays the input form properly, but when I enter a message and hit ‘Publish’ I get this 500 error returned:

Exception--------
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.springframework.amqp.core.MessageProperties.getReplyTo()Lorg/springframework/amqp/core/Address;
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:839)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause
java.lang.NoSuchMethodError: org.springframework.amqp.core.MessageProperties.getReplyTo()Lorg/springframework/amqp/core/Address;
    org.springframework.amqp.rabbit.support.DefaultMessagePropertiesConverter.fromMessageProperties(DefaultMessagePropertiesConverter.java:120)
    org.springframework.amqp.rabbit.core.RabbitTemplate.doSend(RabbitTemplate.java:365)
    org.springframework.amqp.rabbit.core.RabbitTemplate$1.doInRabbit(RabbitTemplate.java:164)
    org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:330)
    org.springframework.amqp.rabbit.core.RabbitTemplate.send(RabbitTemplate.java:162)
    org.springframework.amqp.rabbit.core.RabbitTemplate.convertAndSend(RabbitTemplate.java:179)
    org.springframework.amqp.rabbit.core.RabbitTemplate.convertAndSend(RabbitTemplate.java:175)
    com.c3works.msg.HomeController.publish(HomeController.java:25)

Has anyone worked this successfully and know what I might be doing wrong (RabbitMQ issue, CloudFoundry issue, my own issue :0 )?

The only thing I did that wasn’t identical to SpringSource's tutorial code was to change the return string in the HomeController from :
return "WEB-INF/views/home.jsp";
to
“home” to be consistent with the way the viewResolver was set up in the spring-context.xml file (this was necessary to even get the input form to display properly).

Thanks.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

山田美奈子 2024-12-25 03:00:08

我在没有使用 STS 编辑器的情况下再次从头开始构建它,并且它可以正常运行。我无法真正解释为什么从 STS IDE 内的 Maven 项目构建它会导致我遇到的问题,但仅使用文本编辑器和 vmc 命令行指令来干净地构建所有内容是可行的。

I built this again from scratch without using STS editor and it functions properly. I can't really explain why building it from a Maven project inside the STS IDE led to the problem I experienced, but a clean build of everything using just a text editor and vmc command line instructions worked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文