XMPP Spring Integration Property or field 'jso

2019-08-17 18:11发布

问题:

I tried to implement XMPP with Spring Integration using the following tutorial: https://grokonez.com/spring-framework/spring-integration/firebase-cloud-messaging-xmpp-server-example-receive-upstream-messages-spring-integration

However I am getting the following error:

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]

So how to receive an upstream message within Spring integration?

回答1:

Your problem that you don't show what is your code on the matter. And looks like you really are missing the fact that the mentioned sample is based on the GCM, where getExtension('google:mobile:data') from the org.jivesoftware.smack.packet.Message really returns for us a org.jivesoftware.smackx.gcm.packet.GcmPacketExtension with the getJson() method.

In your case it looks like your get a org.jivesoftware.smack.packet.StandardExtensionElement. So, that really is expected do not have a json over there.