找不到 XMPP Spring 集成属性或字段“json”

Posted

技术标签:

【中文标题】找不到 XMPP Spring 集成属性或字段“json”【英文标题】:XMPP Spring Integration Property or field 'json' cannot be found 【发布时间】:2019-01-12 13:49:57 【问题描述】:

我尝试使用以下教程使用 Spring Integration 实现 XMPP: https://grokonez.com/spring-framework/spring-integration/firebase-cloud-messaging-xmpp-server-example-receive-upstream-messages-spring-integration

但是我收到以下错误:

org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'json' cannot be found on object of type 'org.jivesoftware.smack.packet.StandardExtensionElement' - maybe not public or not valid?
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:217) ~[spring-expression-5.1.3.RELEASE.jar:5.1.3.RELEASE]
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:104) ~[spring-expression-5.1.3.RELEASE.jar:5.1.3.RELEASE]
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.access$000(PropertyOrFieldReference.java:51) ~[spring-expression-5.1.3.RELEASE.jar:5.1.3.RELEASE]
    at org.springframework.expression.spel.ast.PropertyOrFieldReference$AccessorLValue.getValue(PropertyOrFieldReference.java:406) ~[spring-expression-5.1.3.RELEASE.jar:5.1.3.RELEASE]
    at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:90) ~[spring-expression-5.1.3.RELEASE.jar:5.1.3.RELEASE]
    at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:111) ~[spring-expression-5.1.3.RELEASE.jar:5.1.3.RELEASE]
    at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:328) ~[spring-expression-5.1.3.RELEASE.jar:5.1.3.RELEASE]
    at org.springframework.integration.xmpp.inbound.ChatMessageListeningEndpoint$ChatMessagePublishingStanzaListener.processStanza(ChatMessageListeningEndpoint.java:143) ~[spring-integration-xmpp-5.1.1.RELEASE.jar:5.1.1.RELEASE]

那么如何在 Spring 集成中接收上游消息呢?

【问题讨论】:

【参考方案1】:

你的问题是你没有显示你的代码是什么。看起来您确实错过了上述示例基于 GCM 的事实,其中来自 org.jivesoftware.smack.packet.MessagegetExtension('google:mobile:data') 确实为我们返回了带有 getJson() 方法的 org.jivesoftware.smackx.gcm.packet.GcmPacketExtension

在您的情况下,您似乎获得了org.jivesoftware.smack.packet.StandardExtensionElement。所以,那真的是预计那里没有json

【讨论】:

嗨@Artem Bilan,感谢您的回复。事实上,我通过 android 应用程序的 Firebase 云消息传递发送上游消息。但是在 org.jivesoftware.smack.packet.StandardExtensionElement 我发现不是 getJson() 我看到有一个名为 text 的字段。所以我认为文本是 Strin Json。那么你知道如何从中获取数据吗? 正如我在回答中所说:我们不知道您的代码,您也没有显示您的失败之处,但无论如何,如果您遵循该示例,那么您的 payload-expression 必须是这样的:payload-expression="getExtension('google:mobile:data').text" 没错,这解决了我的问题:payload-expression="getExtension('google:mobile:data').text" ..感谢您的帮助

以上是关于找不到 XMPP Spring 集成属性或字段“json”的主要内容,如果未能解决你的问题,请参考以下文章

iOS - 带有 WebRTC 的 XMPP 用于实时视频通话或聊天

将 IM 聊天服务器集成到现有 Spring 服务器

Thymeleaf:对象中的对象,无法像jsp那样访问值?属性或字段 - 在 null 上找不到

org.springframework.expression.spel.SpelEvaluationException:EL1007E:在 null 上找不到属性或字段“chargesName”

EL1008E: 在“java.util.ArrayList”类型的对象上找不到属性或字段“内容” - 可能不是公共的或无效的?

XMPP Spring 集成 - 聊天