No converter found to convert to interface javax.jms.TextMessage - spring-boot

I am running a spring boot application that connects to activeMQ as a consumer from my Spring STS environment. I then run my camel blueprint from my JBoss Developer Studio app.
Here's the code from my listener:
#JmsListener(destination = '${tripRequest.updateStatus.destination}')
void handle(TextMessage message) {
When the message hits the consumer, I get the following exception:
org.springframework.jms.listener.adapter.ListenerExecutionFailedException: Listener method could not be invoked with incoming message
Endpoint handler details:
Method [public void com.xxx.trip.request.messaging.status.TripRequestUpdateStatusListener.handle(javax.jms.TextMessage)]
Bean [com.xxx.trip.request.messaging.status.TripRequestUpdateStatusListener#1a99744a]
; nested exception is org.springframework.messaging.converter.MessageConversionException: No converter found to convert to interface javax.jms.TextMessage, message=GenericMessage [payload=byte[197], headers={CamelFileLastModified=1466448102155, CamelFileParent=C:\Users\Thom\git\brms-poc-esb\rule-cancel\data, CamelFilePath=C:\Users\Thom\git\brms-poc-esb\rule-cancel\data\one.json, CamelFileLength=22, jms_destination=queue://tripRequest.updateStatus.v1.0, jms_priority=4, CamelFileAbsolute=true, jms_timestamp=1466631945834, CamelFileName=one.json, jms_redelivered=false, jms_deliveryMode=2, CamelFileNameConsumed=one.json, breadcrumbId=ID-ThomasLaptop-55017-1466631942306-0-1, jms_replyTo=temp-queue://ID:ThomasLaptop-55022-1466631945608-1:1:1, CamelFileRelativePath=one.json, jms_correlationId=Camel-ID-ThomasLaptop-55017-1466631942306-0-3, id=3c38a185-44c7-4df2-fefb-1f3320e0262f, CamelFileAbsolutePath=C:\Users\Thom\git\brms-poc-esb\rule-cancel\data\one.json, jms_expiration=1466631965834, jms_messageId=ID:ThomasLaptop-55022-1466631945608-1:1:2:1:1, CamelFileNameOnly=one.json, timestamp=1466631945924}]
at org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter.invokeHandler(MessagingMessageListenerAdapter.java:94) ~[spring-jms-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter.onMessage(MessagingMessageListenerAdapter.java:66) ~[spring-jms-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:721) ~[spring-jms-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:681) ~[spring-jms-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:651) ~[spring-jms-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:315) [spring-jms-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:253) [spring-jms-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1158) [spring-jms-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1150) [spring-jms-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1047) [spring-jms-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at java.lang.Thread.run(Unknown Source) [na:1.8.0_91]
Caused by: org.springframework.messaging.converter.MessageConversionException: No converter found to convert to interface javax.jms.TextMessage, message=GenericMessage [payload=byte[197], headers={CamelFileLastModified=1466448102155, CamelFileParent=C:\Users\Thom\git\brms-poc-esb\rule-cancel\data, CamelFilePath=C:\Users\Thom\git\brms-poc-esb\rule-cancel\data\one.json, CamelFileLength=22, jms_destination=queue://tripRequest.updateStatus.v1.0, jms_priority=4, CamelFileAbsolute=true, jms_timestamp=1466631945834, CamelFileName=one.json, jms_redelivered=false, jms_deliveryMode=2, CamelFileNameConsumed=one.json, breadcrumbId=ID-ThomasLaptop-55017-1466631942306-0-1, jms_replyTo=temp-queue://ID:ThomasLaptop-55022-1466631945608-1:1:1, CamelFileRelativePath=one.json, jms_correlationId=Camel-ID-ThomasLaptop-55017-1466631942306-0-3, id=3c38a185-44c7-4df2-fefb-1f3320e0262f, CamelFileAbsolutePath=C:\Users\Thom\git\brms-poc-esb\rule-cancel\data\one.json, jms_expiration=1466631965834, jms_messageId=ID:ThomasLaptop-55022-1466631945608-1:1:2:1:1, CamelFileNameOnly=one.json, timestamp=1466631945924}]
at org.springframework.messaging.handler.annotation.support.PayloadArgumentResolver.resolveArgument(PayloadArgumentResolver.java:118) ~[spring-messaging-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:98) ~[spring-messaging-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:138) ~[spring-messaging-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:107) ~[spring-messaging-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter.invokeHandler(MessagingMessageListenerAdapter.java:90) ~[spring-jms-4.2.5.RELEASE.jar:4.2.5.RELEASE]
... 10 common frames omitted
I know for a fact that we have tested this with text messages sent from another application and this message works fine. I don't understand why it fails from my camel route. When I look at the message, it appears to be well-formed XML. Here it is:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<tripRequestUpdateStatus>
<id>1</id>
<status>Approved</status>
<updatedBy source="lgtc">1</updatedBy>
</tripRequestUpdateStatus>
Why does it need converted in the first place when I'm sending text? Why is conversion failing?

I guess you created a new question after you found out something, but forgot to mention this in this question: How to send text message instead of byte message
You send the messages as byte payload so the JMS consumer receives the message payload as a javax.jms.BytesMessage which Spring Integration is not able to convert to a javax.jms.TextMessage. So you can change your code to use a javax.jms.BytesMessage instead. Or have the sender send the JMS messages as Text based instead of Bytes.

Related

Pass through SOAP proxy spring Unsupported media type multipart/related; type="application/xop+xml"; boundary

Hi I am trying to implement a pass through SOAP proxy via #RestController in spring. For this purpose I have mapped a rest controller in following way:
#RestController
class MyProxy {
#PostMapping(value = "/**")
public ResponseEntity<String> proxyPost(#RequestBody(required = false) String body, HttpServletRequest request) {}
}
The regular SOAP requests are going OK. The problem comes when a MTOM type of SOAP request is send via the proxy. Then spring failes with unrecognized content type. Here is the exception:
Caused by: org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is javax.servlet.ServletException: Unsupported Content-Type [multipart/related; type="application/xop+xml"; boundary="uuid:dacf4733-80b4-41bc-b2e1-db69b6beadf6"; start="<root.message#cxf.apache.org>"; start-info="text/xml"], expected [multipart/form-data]
at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.handleParseFailure(StandardMultipartHttpServletRequest.java:124)
at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:115)
at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.<init>(StandardMultipartHttpServletRequest.java:88)
at org.springframework.web.multipart.support.StandardServletMultipartResolver.resolveMultipart(StandardServletMultipartResolver.java:122)
at org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1205)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
... 60 common frames omitted
Caused by: javax.servlet.ServletException: Unsupported Content-Type [multipart/related; type="application/xop+xml"; boundary="uuid:dacf4733-80b4-41bc-b2e1-db69b6beadf6"; start="<root.message#cxf.apache.org>"; start-info="text/xml"], expected [multipart/form-data]
at org.eclipse.jetty.server.Request.getParts(Request.java:2407)
at javax.servlet.http.HttpServletRequestWrapper.getParts(HttpServletRequestWrapper.java:317)
at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:95)
... 66 common frames omitted
When receiving a multipart/* request Spring delegates this to the configured Multipart handler. This is enabled by default and for this case should be disabled.
spring.servlet.multipart.enabled=false
Adding the above to your properties should disable it and prevent the parsing, so you can handle it in your controller.

SpEL evaluation of path variable in WebsocketSecurityConfiguration

I am running a JHipster 6.1.2 Gateway with Websockets and am trying to restrict access to a messaging topic, so that users can only subscribe to topics of the institution they belong to. So basically I want to perform a check on the id from the subscription path.
My current solution is based on https://stackoverflow.com/a/44895369/4246074 and looks as follows:
WebsocketSecurityConfiguration.java:
#Override
protected void configureInbound(MessageSecurityMetadataSourceRegistry messages) {
//...
//User can only subscribe to own institution topic
.simpSubscribeDestMatchers("/topic/institution.{id}")
.access("#institutionIdGuard.checkInstitutionId(#id)")
//...
}
InstitutionIdGuard.java:
#Component
public class InstitutionIdGuard {
public boolean checkInstitutionId(Long institutionId) {
//validation logic for institutionId would go here
return true;
}
The problem:
Apparently the SpEL expression can't access {id} from the path because i get a nullpointer error with the following log:
2019-08-08 10:30:08.367 ERROR 31097 --- [ XNIO-1 I/O-1] o.s.w.s.m.StompSubProtocolHandler : Failed to send client message to application via MessageChannel in session j2a0jlos. Sending STOMP ERROR to client.
org.springframework.messaging.MessageDeliveryException: Failed to send message to ExecutorSubscribableChannel[clientInboundChannel]; nested exception is java.lang.IllegalArgumentException: Failed to evaluate expression '#institutionIdGuard.checkInstitutionId(#id)'
at org.springframework.messaging.support.AbstractMessageChannel.send(AbstractMessageChannel.java:146)
at org.springframework.messaging.support.AbstractMessageChannel.send(AbstractMessageChannel.java:122)
at org.springframework.web.socket.messaging.StompSubProtocolHandler.handleMessageFromClient(StompSubProtocolHandler.java:284)
at org.springframework.web.socket.messaging.SubProtocolWebSocketHandler.handleMessage(SubProtocolWebSocketHandler.java:324)
at org.springframework.web.socket.handler.WebSocketHandlerDecorator.handleMessage(WebSocketHandlerDecorator.java:75)
at org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator.handleMessage(LoggingWebSocketHandlerDecorator.java:56)
at org.springframework.web.socket.handler.ExceptionWebSocketHandlerDecorator.handleMessage(ExceptionWebSocketHandlerDecorator.java:58)
at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.delegateMessages(AbstractSockJsSession.java:386)
at org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession.handleMessage(WebSocketServerSockJsSession.java:195)
at org.springframework.web.socket.sockjs.transport.handler.SockJsWebSocketHandler.handleTextMessage(SockJsWebSocketHandler.java:93)
at org.springframework.web.socket.handler.AbstractWebSocketHandler.handleMessage(AbstractWebSocketHandler.java:43)
at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.handleTextMessage(StandardWebSocketHandlerAdapter.java:113)
at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.access$000(StandardWebSocketHandlerAdapter.java:42)
at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$3.onMessage(StandardWebSocketHandlerAdapter.java:84)
at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$3.onMessage(StandardWebSocketHandlerAdapter.java:81)
at io.undertow.websockets.jsr.FrameHandler$7.run(FrameHandler.java:286)
at io.undertow.websockets.jsr.ServerWebSocketContainer$1.call(ServerWebSocketContainer.java:170)
at io.undertow.websockets.jsr.ServerWebSocketContainer$1.call(ServerWebSocketContainer.java:167)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at io.undertow.websockets.jsr.ServerWebSocketContainer.invokeEndpointMethod(ServerWebSocketContainer.java:604)
at io.undertow.websockets.jsr.ServerWebSocketContainer.invokeEndpointMethod(ServerWebSocketContainer.java:594)
at io.undertow.websockets.jsr.FrameHandler.invokeTextHandler(FrameHandler.java:266)
at io.undertow.websockets.jsr.FrameHandler.onFullTextMessage(FrameHandler.java:317)
at io.undertow.websockets.core.AbstractReceiveListener$2.complete(AbstractReceiveListener.java:156)
at io.undertow.websockets.core.AbstractReceiveListener$2.complete(AbstractReceiveListener.java:152)
at io.undertow.websockets.core.BufferedTextMessage.read(BufferedTextMessage.java:105)
at io.undertow.websockets.core.AbstractReceiveListener.readBufferedText(AbstractReceiveListener.java:152)
at io.undertow.websockets.core.AbstractReceiveListener.bufferFullMessage(AbstractReceiveListener.java:90)
at io.undertow.websockets.jsr.FrameHandler.onText(FrameHandler.java:182)
at io.undertow.websockets.core.AbstractReceiveListener.handleEvent(AbstractReceiveListener.java:44)
at io.undertow.websockets.core.AbstractReceiveListener.handleEvent(AbstractReceiveListener.java:33)
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
at io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(AbstractFramedChannel.java:951)
at io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(AbstractFramedChannel.java:932)
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:88)
at org.xnio.nio.WorkerThread.run(WorkerThread.java:561)
Caused by: java.lang.IllegalArgumentException: Failed to evaluate expression '#institutionIdGuard.checkInstitutionId(#id)'
at org.springframework.security.access.expression.ExpressionUtils.evaluateAsBoolean(ExpressionUtils.java:30)
at org.springframework.security.messaging.access.expression.MessageExpressionVoter.vote(MessageExpressionVoter.java:57)
at org.springframework.security.messaging.access.expression.MessageExpressionVoter.vote(MessageExpressionVoter.java:39)
at org.springframework.security.access.vote.AffirmativeBased.decide(AffirmativeBased.java:63)
at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:233)
at org.springframework.security.messaging.access.intercept.ChannelSecurityInterceptor.preSend(ChannelSecurityInterceptor.java:69)
at org.springframework.messaging.support.AbstractMessageChannel$ChannelInterceptorChain.applyPreSend(AbstractMessageChannel.java:178)
at org.springframework.messaging.support.AbstractMessageChannel.send(AbstractMessageChannel.java:132)
... 37 common frames omitted
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1004E: Method call: Method checkInstitutionId(null) cannot be found on type com.mycompany.websocketgateway.security.InstitutionIdGuard
at org.springframework.expression.spel.ast.MethodReference.findAccessorForMethod(MethodReference.java:225)
at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:134)
at org.springframework.expression.spel.ast.MethodReference.access$000(MethodReference.java:54)
at org.springframework.expression.spel.ast.MethodReference$MethodValueRef.getValue(MethodReference.java:390)
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:90)
at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:114)
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:300)
at org.springframework.security.access.expression.ExpressionUtils.evaluateAsBoolean(ExpressionUtils.java:26)
... 44 common frames omitted
I would be grateful for any ideas how to make my solution work or other other ways of performing checks in the id.
I found the solution on the Spring Security issue tracker. Apparently before Spring Security 5.2 you can pass the implicit message variable to the SpEL expression
.simpSubscribeDestMatchers("/topic/institution.*")
.access("#institutionIdGuard.checkInstitutionId(authentication, message)")
Then in the verification method its possible to get the path from the message and do your own verification with it:
public boolean checkInstitutionId(Authentication authentication, Message<?> message) {
StompHeaderAccessor sha = StompHeaderAccessor.wrap(message);
String topic = sha.getDestination();
String id = topic.replace("/topic/institution/", "");
//validation logic for institutionId would go here
return true;
}
Spring Security 5.2 should have fixed the issue according to this pull request.

Spring Boot & RabbitMQ: message conversion content type

We are using Spring Boot 2.1.3.RELEASE and RabbitMQ. MessagePack is used for serialization.
We are using convertAndSend:
rabbitTemplate.convertAndSend("exchange", "routingKey", object);
And getting the following exception:
java.lang.UnsupportedOperationException: null
at org.msgpack.jackson.dataformat.MessagePackFactory.createGenerator(MessagePackFactory.java:102)
at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:3219)
at org.springframework.amqp.support.converter.AbstractJackson2MessageConverter.createMessage(AbstractJackson2MessageConverter.java:259)
at org.springframework.amqp.support.converter.AbstractMessageConverter.toMessage(AbstractMessageConverter.java:70)
at org.springframework.amqp.support.converter.AbstractMessageConverter.toMessage(AbstractMessageConverter.java:58)
at org.springframework.amqp.rabbit.core.RabbitTemplate.convertMessageIfNecessary(RabbitTemplate.java:1726)
at org.springframework.amqp.rabbit.core.RabbitTemplate.convertAndSend(RabbitTemplate.java:1048)
at org.springframework.amqp.rabbit.core.RabbitTemplate.convertAndSend(RabbitTemplate.java:1041)
This is the line where the exception is thrown:
return getRequiredMessageConverter().toMessage(object, new MessageProperties());
Is there a way to set the content type in MessageProperties to application/json? The default is application/octet-stream.

How to read Oracle OAQ queue from Camel

I am writing a Camel app that reads LCR's from an Oracle oaq ("ANYDATA") queue. We are not using Weblogic, and are running under Spring Boot. Right now I'm trying to create a minimal app that reads the LCR's and dumps them to a log. We are getting an exception (full trace shown at bottom) that says:
c.c.j.DefaultJmsMessageListenerContainer : Setup of JMS message listener invoker failed for destination 'AQADMIN.MULEBUS_ANYDATA_Q' - trying to recover. Cause: JMS-120: Dequeue failed; nested exception is oracle.jms.AQjmsException: JMS-224: Typemap is invalid - must be populated with SQLType/OraDataFactory mappings to receive messages from Sys.AnyData destinations
I think I need to grab the session and populate the type map. The LCR's are in XML format; from 1 example on the web I saw I could probably do something like this:
((AQjmsSession) session).getTypeMap().put(("SYS.XMLTYPE", Class.forName("oracle.xdb.XMLType"));
.. but I am a Camel newbie (not to mention an ANYDATA newbie), and am not sure whether that will work or how to do it. Also wondering whether I am using the wrong driver (I see stuff indicating the thin driver (which I am using), other stuff pointing to oci. Note that we're connecting, as nothing happens till we generate an lcr.
Any pointers on how to set up a minimal app to read the lcr in Camel and dump it to a log would be most gratefully appreciated.
The route looks like this currently:
from("oracleAQ:{{xyz.oracleaq.datasource.srcaq}}")
.to("log:out");
.. and the referenced component is:
#Qualifier("oracleAQ")
#Bean
public Object oracleAQ() throws JMSException {
LOG.info("OracleAQ startup - url={}, user={}", url, username);
try {
QueueConnectionFactory f = AQjmsFactory.getQueueConnectionFactory(url, new Properties());
UserCredentialsConnectionFactoryAdapter adapter = new UserCredentialsConnectionFactoryAdapter();
adapter.setTargetConnectionFactory(f);
adapter.setUsername(username);
adapter.setPassword(password);
return JmsComponent.jmsComponent(adapter);
} catch (JMSException jmse) {
LOG.error("Error starting OracleAQ component: {}", jmse);
throw jmse;
}
}
TIA.
Stack trace follows:
2016-06-06 11:12:58.632 INFO 110904 --- [EBUS_ANYDATA_Q]] c.c.j.DefaultJmsMessageListenerContainer : Successfully refreshed JMS Connection
2016-06-06 11:13:03.682 WARN 110904 --- [EBUS_ANYDATA_Q]] c.c.j.DefaultJmsMessageListenerContainer : Setup of JMS message listener invoker failed for destination 'AQADMIN.MULEBUS_ANYDATA_Q' - trying to recover. Cause: JMS-120: Dequeue failed; nested exception is oracle.jms.AQjmsException: JMS-224: Typemap is invalid - must be populated with SQLType/OraDataFactory mappings to receive messages from Sys.AnyData destinations
oracle.jms.AQjmsException: JMS-120: Dequeue failed
at oracle.jms.AQjmsError.throwEx(AQjmsError.java:315) ~[aqapi-11.2.0.3.jar:na]
at oracle.jms.AQjmsConsumer.jdbcDequeue(AQjmsConsumer.java:1626) ~[aqapi-11.2.0.3.jar:na]
at oracle.jms.AQjmsConsumer.receiveFromAQ(AQjmsConsumer.java:1035) ~[aqapi-11.2.0.3.jar:na]
at oracle.jms.AQjmsConsumer.receiveFromAQ(AQjmsConsumer.java:960) ~[aqapi-11.2.0.3.jar:na]
at oracle.jms.AQjmsConsumer.receiveFromAQ(AQjmsConsumer.java:938) ~[aqapi-11.2.0.3.jar:na]
at oracle.jms.AQjmsConsumer.receive(AQjmsConsumer.java:790) ~[aqapi-11.2.0.3.jar:na]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveMessage(AbstractPollingMessageListenerContainer.java:420) ~[spring-jms-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:300) ~[spring-jms-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:253) ~[spring-jms-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1164) ~[spring-jms-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1156) ~[spring-jms-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1053) ~[spring-jms-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_77]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_77]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_77]
Caused by: oracle.jms.AQjmsException: JMS-224: Typemap is invalid - must be populated with SQLType/OraDataFactory mappings to receive messages from Sys.AnyData destinations
at oracle.jms.AQjmsError.throwEx(AQjmsError.java:292) ~[aqapi-11.2.0.3.jar:na]
at oracle.jms.AQjmsConsumer.convertAnydataToMessage(AQjmsConsumer.java:1791) ~[aqapi-11.2.0.3.jar:na]
at oracle.jms.AQjmsConsumer.jdbcDequeue(AQjmsConsumer.java:1437) ~[aqapi-11.2.0.3.jar:na]
... 13 common frames omitted

AMQAuthenticationException for WSO2 ESB Publisher

I'm trying to integrate WSO2 ESB (4.7.0) with WSO2 Message Broker (2.1.0).
This is my use case:
A generic HTTP Client sends a REST request to a PassThrough Proxy
deployed on WSO2 ESB
The ESB Proxy has an outsequence: forwards the request to the real
REST service, then, in the outsequence, it sends the response to a
mediator class (deployed inside the WSO2 ESB)
The mediator class make some stuff and has this method inside, by
which it can publish an event to a topic on the Message Broker:
Code:
private void publishEvent(){
String topicName = "MyEvent";
Properties properties = new Properties();
TopicConnection topicConnection = null;
properties.put("java.naming.factory.initial", "org.wso2.andes.jndi.PropertiesFileInitialContextFactory");
String connectionString = "amqp://admin:admin#clientID/carbon?brokerlist='tcp://localhost:5673'";
properties.put("connectionfactory.QueueConnectionFactory", connectionString);
try {
InitialContext ctx = new InitialContext(properties);
TopicConnectionFactory tcf = (TopicConnectionFactory) ctx.lookup("QueueConnectionFactory");
TopicConnection connection = tcf.createTopicConnection();
TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
Topic topic = session.createTopic(topicName);
TopicPublisher publisher= session.createPublisher(topic);
TextMessage textMessage =
session.createTextMessage("<asd>sono il publisher di WSO2 message Broker!</asd>");
publisher.publish(textMessage);
publisher.close();
}catch (Exception e){
e.printStackTrace();
}
}
On the other end there is a subscriber to the "MyEvent" topic which
is already running.
(I took the code both for Publisher and subscriber from this URL: http://wso2.com/library/articles/2011/12/wso2-esb-example-pubsub-soa/)
When the client sends the REST request to the proxy (1), the mediator is invoked correctly but when it tries to execute the PublishEvent method (3), nothing happens and the WSO2 ESB logs this 530 error:
INFO - ConnectionCloseMethodHandler ConnectionClose frame received
[2013-10-17 12:43:47,733] INFO - ConnectionCloseMethodHandler Error :530: not allowed:Thread-33
[2013-10-17 12:43:47,734] ERROR - AMQStateManager No Waiters for error saving as last error:Attempt to redeclare exchange: amq.topic of type topic to null.
[2013-10-17 12:43:47,735] ERROR - AMQConnection Throwable Received but no listener set: org.wso2.andes.client.AMQAuthenticationException: Attempt to redeclare exchange: amq.topic of type topic to null. [error code 530: not allowed]
ERROR - AMQStateManager No Waiters for error saving as last error:Attempt to redeclare exchange: amq.topic of type topic to null.
[2013-10-17 20:53:44,996] ERROR - AMQConnection error:
org.wso2.andes.client.AMQAuthenticationException: Attempt to redeclare exchange: amq.topic of type topic to null. [error code 530: not allowed]
at org.wso2.andes.client.handler.ConnectionCloseMethodHandler.methodReceived(ConnectionCloseMethodHandler.java:79)
at org.wso2.andes.client.handler.ClientMethodDispatcherImpl.dispatchConnectionClose(ClientMethodDispatcherImpl.java:192)
at org.wso2.andes.framing.amqp_0_91.ConnectionCloseBodyImpl.execute(ConnectionCloseBodyImpl.java:140)
at org.wso2.andes.client.state.AMQStateManager.methodReceived(AMQStateManager.java:111)
at org.wso2.andes.client.protocol.AMQProtocolHandler.methodBodyReceived(AMQProtocolHandler.java:515)
at org.wso2.andes.client.protocol.AMQProtocolSession.methodFrameReceived(AMQProtocolSession.java:456)
at org.wso2.andes.framing.AMQMethodBodyImpl.handle(AMQMethodBodyImpl.java:96)
at org.wso2.andes.client.protocol.AMQProtocolHandler$2.run(AMQProtocolHandler.java:466)
at org.wso2.andes.pool.Job.processAll(Job.java:109)
at org.wso2.andes.pool.Job.run(Job.java:157)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
javax.jms.JMSException: Error closing connection: org.wso2.andes.client.AMQAuthenticationException: Attempt to redeclare exchange: amq.topic of type topic to null. [error code 530: not allowed]
at org.wso2.andes.client.AMQConnection.doClose(AMQConnection.java:920)
at org.wso2.andes.client.AMQConnection.close(AMQConnection.java:855)
at org.wso2.andes.client.AMQConnection.close(AMQConnection.java:846)
at org.wso2.andes.client.AMQConnection.close(AMQConnection.java:841)
at innova.esb.mediator.TopicPublisher.publishMessage(TopicPublisher.java:49)
at innova.esb.mediator.MediatorEventPublisher.mediate(MediatorEventPublisher.java:35)
at org.apache.synapse.mediators.ext.ClassMediator.mediate(ClassMediator.java:78)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:114)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:239)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:443)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:166)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:222)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: org.wso2.andes.client.AMQAuthenticationException: Attempt to redeclare exchange: amq.topic of type topic to null. [error code 530: not allowed]
at org.wso2.andes.client.handler.ConnectionCloseMethodHandler.methodReceived(ConnectionCloseMethodHandler.java:79)
at org.wso2.andes.client.handler.ClientMethodDispatcherImpl.dispatchConnectionClose(ClientMethodDispatcherImpl.java:192)
at org.wso2.andes.framing.amqp_0_91.ConnectionCloseBodyImpl.execute(ConnectionCloseBodyImpl.java:140)
at org.wso2.andes.client.state.AMQStateManager.methodReceived(AMQStateManager.java:111)
at org.wso2.andes.client.protocol.AMQProtocolHandler.methodBodyReceived(AMQProtocolHandler.java:515)
at org.wso2.andes.client.protocol.AMQProtocolSession.methodFrameReceived(AMQProtocolSession.java:456)
at org.wso2.andes.framing.AMQMethodBodyImpl.handle(AMQMethodBodyImpl.java:96)
at org.wso2.andes.client.protocol.AMQProtocolHandler$2.run(AMQProtocolHandler.java:466)
at org.wso2.andes.pool.Job.processAll(Job.java:109)
at org.wso2.andes.pool.Job.run(Job.java:157)
Obviously the subscriber doesn't catch any event.
What is wrong? Why do I have this Connection Exception?
Thanks a lot.

Resources