How to read Oracle OAQ queue from Camel - oracle

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

Related

Flume HDFS Sink Write error "no protocol: value"

When trying to run a flume job I am getting the error given below. I am running this on a cloudera setup.
Kafka is the source
Morphline is used as an interceptor with avro records getting created from it.
Sink is HDFS
The exact same files (morphline, avro schema etc., flume config) on a test environment. But in another environment it throws this error.
2019-07-15 14:24:17,669 WARN org.apache.flume.sink.hdfs.BucketWriter: Caught IOException writing to HDFSWriter (no protocol: value). Closing file (hdfs://8.8.8.8:8020/user/hive/warehouse/folder/folder/FlumeData.1563162656585.tmp) and rethrowing exception.
2019-07-15 14:24:17,670 INFO org.apache.flume.sink.hdfs.BucketWriter: Closing hdfs://8.8.8.8:8020/user/hive/warehouse/folder/folder/FlumeData.1563162656585.tmp
2019-07-15 14:24:17,670 ERROR org.apache.flume.sink.hdfs.HDFSEventSink: process failed
java.lang.NullPointerException
at org.apache.flume.sink.hdfs.AvroEventSerializer.flush(AvroEventSerializer.java:187)
at org.apache.flume.sink.hdfs.HDFSDataStream.close(HDFSDataStream.java:131)
at org.apache.flume.sink.hdfs.BucketWriter$3.call(BucketWriter.java:327)
at org.apache.flume.sink.hdfs.BucketWriter$3.call(BucketWriter.java:323)
at org.apache.flume.sink.hdfs.BucketWriter$9$1.run(BucketWriter.java:701)
at org.apache.flume.auth.SimpleAuthenticator.execute(SimpleAuthenticator.java:50)
at org.apache.flume.sink.hdfs.BucketWriter$9.call(BucketWriter.java:698)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
2019-07-15 14:24:17,671 ERROR org.apache.flume.SinkRunner: Unable to deliver event. Exception follows.
org.apache.flume.EventDeliveryException: java.lang.NullPointerException
at org.apache.flume.sink.hdfs.HDFSEventSink.process(HDFSEventSink.java:451)
at org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:67)
at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:145)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at org.apache.flume.sink.hdfs.AvroEventSerializer.flush(AvroEventSerializer.java:187)
at org.apache.flume.sink.hdfs.HDFSDataStream.close(HDFSDataStream.java:131)
at org.apache.flume.sink.hdfs.BucketWriter$3.call(BucketWriter.java:327)
at org.apache.flume.sink.hdfs.BucketWriter$3.call(BucketWriter.java:323)
at org.apache.flume.sink.hdfs.BucketWriter$9$1.run(BucketWriter.java:701)
at org.apache.flume.auth.SimpleAuthenticator.execute(SimpleAuthenticator.java:50)
at org.apache.flume.sink.hdfs.BucketWriter$9.call(BucketWriter.java:698)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
... 1 more
I was able to locate the relevant code on flume:
https://github.com/apache/flume/blob/trunk/flume-ng-sinks/flume-hdfs-sink/src/main/java/org/apache/flume/sink/hdfs/BucketWriter.java (line:602)
// write the event
try {
sinkCounter.incrementEventDrainAttemptCount();
callWithTimeout(new CallRunner<Void>() {
#Override
public Void call() throws Exception {
writer.append(event); // could block
return null;
}
});
} catch (IOException e) {
LOG.warn("Caught IOException writing to HDFSWriter ({}). Closing file (" +
bucketPath + ") and rethrowing exception.",
e.getMessage());
close(true);
throw e;
}
Error: Caught IOException writing to HDFSWriter (no protocol: value). Closing file
I am not able to workout what the error no protocol: value means.
I am unable to find any reference to this error in any context related to Flume and HDFS.
Incerceptor protocol was missing from the configuration -- Added "file:/" in the flume configuration file which that fixed the issue.
Similar issue reference : https://community.cloudera.com/t5/Data-Ingestion-Integration/Flume-HDFS-sink-error-quot-unknown-protocol-hdfs-quot/td-p/19344

No converter found to convert to interface javax.jms.TextMessage

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.

exceptionListener and errorHandler in apache camle jms component, not working for me

I am connecting to IBM MQ using apache camel Jms component using below code and configuration. When MQ manager goes down by any reason while message polling or is down at the time of camel route startup, my errorHandler or exceptionListener is not invoked.
jmsComponenet = JmsComponent.jmsComponentAutoAcknowledge((ConnectionFactory) obj);
camelContext.addComponent("ibm-mq", jmsComponenet);
camelContext.addRoutes(new RouteBuilder() {
#Override
public void configure() throws Exception {
from("ibm-mq:queue:PE_OUTBOUND?concurrentConsumers=5&exceptionListener=#exceptionListener&errorHandler=#errorHandler").to(
"mqprocessor");
}
});
Spring Application-Context :
<bean id="exceptionListener" class="com.*****.JMSExceptionListener" />
<bean id="errorHandler" class="com.*****.JMSConnectionErrorHandler" />
The classess implements required interface
javax.jms.ExceptionListener and org.springframework.util.ErrorHandler
Despite of specifying Handler and Listener still MQ Connection error is just logged as WARN message in log and controll do not reach these classes.
I am missing / doing anything incorrect here?
Here is DEBUG log -
11:18:20,783 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] (http-localhost/127.0.0.1:8080-1) Returning cached instance of singleton bean 'errorHandler'
11:18:20,784 DEBUG [org.apache.camel.util.IntrospectionSupport] (http-localhost/127.0.0.1:8080-1) Configured property: errorHandler on bean: org.apache.camel.component.jms.JmsConfiguration#17b86db4 with value: com.manh.processors.JMSConnectionErrorHandler#4d2a5096
11:18:20,784 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] (http-localhost/127.0.0.1:8080-1) Returning cached instance of singleton bean 'exceptionListener'
11:18:20,784 DEBUG [org.apache.camel.util.IntrospectionSupport] (http-localhost/127.0.0.1:8080-1) Configured property: exceptionListener on bean: org.apache.camel.component.jms.JmsConfiguration#17b86db4 with value: com.manh.processors.JMSExceptionListener#6c8b8e49
11:18:20,785 DEBUG [org.apache.camel.spring.SpringCamelContext] (http-localhost/127.0.0.1:8080-1) ibm-mq://queue:PE_OUTBOUND?concurrentConsumers=5&errorHandler=%23errorHandler&exceptionListener=%23exceptionListener converted to endpoint: Endpoint[ibm-mq://queue:PE_OUTBOUND?concurrentConsumers=5&errorHandler=%23errorHandler&exceptionListener=%23exceptionListener] by component: org.apache.camel.component.jms.JmsComponent#fb03c67
11:18:20,785 TRACE [org.apache.camel.management.DefaultManagementLifecycleStrategy] (http-localhost/127.0.0.1:8080-1) Checking whether to register Endpoint[ibm-mq://queue:PE_OUTBOUND?concurrentConsumers=5&errorHandler=%23errorHandler&exceptionListener=%23exceptionListener] from route: null
default testConnectionOnStartup = false. I set it to ture and got exception on startup of route.
ErrorHandler come into play only if exception occurs while processing of message.
Thank you for the help Daniel.
Logging with a warn message is default when an error handler cannot be found, so I suspect Camel is not able to find an instance of the provided bean. Try setting the camel log level to debug and see what it says when the route is started, I would expect some kind of message saying that the referenced beans cannot be found.

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.

Calling session Bean deployed on jboss 5.x from client side

I'm running JBoss 5.1 GA with JDK 1.6 on Linux and trying to call session bean(jar containing this session bean is deployed on jboss server), Now i want to call this session bean from client, but didnt work.
Java Code at client Side
public class CallingJbossSessionBeanFromClient {
/**
* #param args
* #throws Exception
*/
public static void main(String[] args) throws Exception
{
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
p.put(Context.PROVIDER_URL, "jnp://182.158.93.41:8080");
Context context = new InitialContext(p);
System.out.println("Successfully Lookup and going to call SessionBean Function deployed on JBoss-5.1.0 Server");
SlsSessiongRemote remote=(SlsSessionRemote) context.lookup("SlsSessionBean/remote");
//SlsSessionBean/remote is RemoteBinding of session Bean
System.out.println("Called");
}
}
where 'SlsSessionBean/remote' is remote binding of session bean deployed on jboss server.
#Stateless
#RemoteBinding(jndiBinding="SlsSessionBean/remote")
but end up with following error
Exception in thread "main" javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
at CallingJbossSessionBeanFromClient.main(CallingJbossSessionBeanFromClient.java:20)
Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
... 4 more
After seeing above error i added jbossjmx-ant.jar in the classpath of 'CallingJbossSessionBeanFromClient' class and got following error
Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/logging/Logger
at org.jnp.interfaces.NamingContext.<clinit>(NamingContext.java:181)
at org.jnp.interfaces.NamingContextFactory.getInitialContext(NamingContextFactory.java:55)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
at CallingJbossSessionBeanFromClient.main(CallingJbossSessionBeanFromClient.java:20)
Caused by: java.lang.ClassNotFoundException: org.jboss.logging.Logger
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
... 7 more
After seeing above error i added jboss-logging-spi.jar in the classpath of 'CallingJbossSessionBeanFromClient' class and got following error
Exception in thread "main" javax.naming.CommunicationException: Could not obtain connection to any of these urls: 182.158.93.41:8080 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to retrieve stub from server /182.158.93.41:8080 [Root exception is java.io.EOFException]]
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1763)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:693)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at CallingJbossSessionBeanFromClient.main(CallingJbossSessionBeanFromClient.java:22)
Caused by: javax.naming.CommunicationException: Failed to retrieve stub from server /182.158.93.41:8080 [Root exception is java.io.EOFException]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:327)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1734)
... 4 more
Caused by: java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2281)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2750)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:780)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:312)
... 5 more
Plz tell me, am i on the right way to call sesion bean from client java class?
I have spent hours looking for solution on Google. However I cannot seem to find anything that holds the hand..try to be more clear, i'm in lack of ideas in this problem, even it sounds like a classic
Plz suggest solution
The solution to this problem is to open the JMX-Console and click on the service=Naming to view the MBean view of the Naming service. Check if the port used is still 1099.....
Changed the URL to jnp://182.158.93.41:1299, the client could communicate with the EJB.
If you are running over JBoss AS 5.x
Here is RMI based JNDI description.
RMI-Port: default -1099 / If dynamic port changed to ports-01 Then Port is 1199
Now, Remaining Things are OK, Modify code ass below
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
p.put(Context.PROVIDER_URL, "jnp://182.158.93.41:1199");
Another Point is case of accessing
SlsSessiongRemote remote=(SlsSessionRemote) context.lookup("SlsSessionBean/remote");
if - #Stateless(name="SlsSessionBean")
Then Remote JNDI- [SlsSessionBean/remote] and Local JNDI - [SlsSessionBean/local]
if - #Stateless(name="SlsSessionBean", mappedName="SlsSessionBeanGlobal")
Then Remote JNDI- [SlsSessionBeanGlobal] and Local JNDI - [SlsSessionBean/local]

Resources