7 Replies Latest reply on Jan 7, 2011 1:18 PM by csmith72

    Camel not setting credentials properly

    csmith72

      I am trying to use Camel to publish to a WebLogic JMS queue. If there are no security policies on the queue then I have no issues, but if I create a policy and attempt to set the username/password within Camel, I get a JMS security exception stating that access is denied. I can connect to the queue using other JMS applications with the same credentials, so I suspect that Camel/ServiceMix is not correctly setting the username and password.

       

      I've attempted to use three different methods to set the credentials; all three are present in my  (simplified) camel config below:

       

      1) Using the username and password options on the "to" component in the route

      2) Using the environment settings in the JNDI lookup

      3) Using the UserCredentialsConnectionFactoryAdapter to wrap the connection factory object

       

      With any of these methods, it appears that a login is being performed, because if the password is specified incorrectly I get an authentication error. However, if the username and password are correct, I still get an authorization error. As I mentioned earlier, I can connect to the queue using other JMS applications with no problems; it seems that the credentials are not being set properly on the JMS connection.

       

      Is there another way I should be setting the credentials? What am I missing?

       

      Camel config is below:

       

              

        • 1. Re: Camel not setting credentials properly
          davsclaus

          I would assume setting the username/password on the connection factory is sufficient. Try removing the username from the endpoint uri.

          • 2. Re: Camel not setting credentials properly
            csmith72

            No luck. I've tried each of these methods independently, and none of them seem to work correctly.

            • 3. Re: Camel not setting credentials properly
              stlewis

              Can you post the stack trace from the exception?  Might help clarify things...

              • 4. Re: Camel not setting credentials properly
                csmith72

                Here's the stack trace. It just looks like a typical security exception, as though I didn't have authorization to publish to the queue.

                 

                -


                12:09:37,066 | WARN  | tenerContainer-1 | DefaultMessageListenerContainer  | AbstractMessageListenerContainer  694 | 73 - org.springframework.jms - 3.0.3.RELEASE | Execution of JMS message listener failed, and no ErrorHandler has been set.

                org.apache.camel.RuntimeCamelException: org.springframework.jms.JmsSecurityException: Access denied to resource: type=, application=JMS-Module, destinationType=queue, resource=output, action=send; nested exception is weblogic.jms.common.JMSSecurityException: Access denied to resource: type=, application=JMS-Module, destinationType=queue, resource=output, action=send

                        at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1126)

                        at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:105)

                        at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:560)

                        at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:498)

                        at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:467)

                        at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)

                        at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:261)

                        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1056)

                        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1048)

                        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:947)

                        at java.lang.Thread.run(Thread.java:619)

                Caused by: org.springframework.jms.JmsSecurityException: Access denied to resource: type=, application=JMS-Module, destinationType=queue, resource=output, action=send; nested exception is weblogic.jms.common.JMSSecurityException: Access denied to resource: type=, application=JMS-Module, destinationType=queue, resource=output, action=send

                        at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:291)

                        at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:168)

                        at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:469)

                        at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.send(JmsConfiguration.java:195)

                        at org.apache.camel.component.jms.JmsProducer.doSend(JmsProducer.java:375)

                        at org.apache.camel.component.jms.JmsProducer.processInOnly(JmsProducer.java:320)

                        at org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:150)

                        at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)

                        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)

                        at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:104)

                        at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:272)

                        at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:98)

                        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)

                        at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)

                        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)

                        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)

                        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)

                        at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)

                        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)

                        at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:99)

                        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)

                        at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)

                        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)

                        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)

                        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)

                        at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:290)

                        at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:202)

                        at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:256)

                        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)

                        at org.apache.camel.processor.Pipeline.process(Pipeline.java:143)

                        at org.apache.camel.processor.Pipeline.process(Pipeline.java:78)

                        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)

                        at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:290)

                        at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:202)

                        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)

                        at org.apache.camel.processor.MulticastProcessor.doProcessSequential(MulticastProcessor.java:334)

                        at org.apache.camel.processor.MulticastProcessor.doProcessSequential(MulticastProcessor.java:274)

                        at org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:179)

                        at org.apache.camel.processor.Splitter.process(Splitter.java:93)

                        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)

                        at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)

                        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)

                        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)

                        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)

                        at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)

                        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)

                        at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:99)

                        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)

                        at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)

                        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)

                        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)

                        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)

                        at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:290)

                        at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:202)

                        at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:256)

                        at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:99)

                        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)

                        at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)

                        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)

                        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)

                        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:91)

                        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:85)

                        at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:85)

                        ... 9 more

                Caused by: weblogic.jms.common.JMSSecurityException: Access denied to resource: type=, application=JMS-Module, destinationType=queue, resource=output, action=send

                        at weblogic.jms.dispatcher.DispatcherAdapter.convertToJMSExceptionAndThrow(DispatcherAdapter.java:110)

                        at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSyncNoTran(DispatcherAdapter.java:61)

                        at weblogic.jms.client.JMSProducer.toFEProducer(JMSProducer.java:1288)

                        at weblogic.jms.client.JMSProducer.deliveryInternal(JMSProducer.java:796)

                        at weblogic.jms.client.JMSProducer.sendInternal(JMSProducer.java:541)

                        at weblogic.jms.client.JMSProducer.sendWithListener(JMSProducer.java:425)

                        at weblogic.jms.client.JMSProducer.send(JMSProducer.java:410)

                        at weblogic.jms.client.WLProducerImpl.send(WLProducerImpl.java:1001)

                        at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:589)

                        at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.doSend(JmsConfiguration.java:282)

                        at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.doSendToDestination(JmsConfiguration.java:222)

                        at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.access$100(JmsConfiguration.java:164)

                        at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate$3.doInJms(JmsConfiguration.java:198)

                        at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:466)

                        ... 69 more

                Caused by: weblogic.jms.common.JMSSecurityException: Access denied to resource: type=, application=JMS-Module, destinationType=queue, resource=output, action=send

                        at weblogic.jms.dispatcher.Request.handleThrowable(Request.java:87)

                        at weblogic.jms.dispatcher.Request.getResult(Request.java:52)

                        at weblogic.jms.frontend.FEProducer.sendRetryDestination(FEProducer.java:1045)

                        at weblogic.jms.frontend.FEProducer.send(FEProducer.java:1399)

                        at weblogic.jms.frontend.FEProducer.invoke(FEProducer.java:1460)

                        at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:961)

                        at weblogic.messaging.dispatcher.DispatcherImpl.dispatchAsyncInternal(DispatcherImpl.java:139)

                        at weblogic.messaging.dispatcher.DispatcherImpl.dispatchAsync(DispatcherImpl.java:115)

                        at weblogic.jms.dispatcher.DispatcherAdapter.dispatchAsync(DispatcherAdapter.java:84)

                        at weblogic.jms.dispatcher.Request.run(Request.java:101)

                        at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)

                        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)

                        at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

                Caused by: weblogic.jms.common.JMSSecurityException: Access denied to resource: type=, application=JMS-Module, destinationType=queue, resource=output, action=send

                        at weblogic.messaging.dispatcher.Request.getResult(Request.java:500)

                        at weblogic.jms.dispatcher.Request.getResult(Request.java:50)

                        ... 11 more

                Caused by: weblogic.jms.common.JMSSecurityException: Access denied to resource: type=, application=JMS-Module, destinationType=queue, resource=output, action=send

                        at weblogic.jms.common.JMSSecurityHelper.checkPermission(JMSSecurityHelper.java:162)

                        at weblogic.jms.backend.BEDestinationSecurityImpl.checkSendPermission(BEDestinationSecurityImpl.java:74)

                        at weblogic.jms.backend.BEDestinationImpl.checkPermission(BEDestinationImpl.java:2494)

                        at weblogic.jms.backend.BEDestinationImpl.sendInitialize(BEDestinationImpl.java:1550)

                        at weblogic.jms.backend.BEDestinationImpl.send(BEDestinationImpl.java:2059)

                        at weblogic.jms.backend.BEDestinationImpl.wrappedSend(BEDestinationImpl.java:2031)

                        at weblogic.jms.backend.BEDestinationImpl.invoke(BEDestinationImpl.java:1524)

                        at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:961)

                        at weblogic.messaging.dispatcher.DispatcherServerRef.invoke(DispatcherServerRef.java:276)

                        at weblogic.messaging.dispatcher.DispatcherServerRef.handleRequest(DispatcherServerRef.java:141)

                        at weblogic.messaging.dispatcher.DispatcherServerRef.access$000(DispatcherServerRef.java:34)

                        at weblogic.messaging.dispatcher.DispatcherServerRef$2.run(DispatcherServerRef.java:111)

                 

                Edited by: csmith72 on Dec 6, 2010 1:19 PM

                • 5. Re: Camel not setting credentials properly
                  davsclaus

                  Try googling how to use WebLogic JMS with Spring JMS. That's the core issue you got.

                  • 6. Re: Camel not setting credentials properly
                    csmith72

                    After some research, it appears that the problem is that Spring JMS and WebLogic JMS don't play nicely together. When Spring looks up the connection factory, it does so using the proper credentials, but since the actual publish takes place in a different thread, the security information doesn't get passed on to that new thread.

                     

                    There is apparently a flag called "exposeAccessContext" that you can set on the connection factory in Spring to ensure that the security credentials are available to other threads, but enabling this didn't seem to work for me. I'm going to experiment with it some more; if I get something to work I will post here for the benefit of others. Thanks for the help so far.

                    • 7. Re: Camel not setting credentials properly
                      csmith72

                      For anyone else encountering this issue, here's how I eventually solved it:

                       

                      I created a Camel processor object, and in its constructor I pass in the provider URL and credentials as arguments and use these to open up a JNDI InitialContext. I then declared this processor in my bundle-context.xml file and filled in the appropriate values for provider URL and credentials there.

                       

                      I didn't even need to reference the processor within my Camel route for this to work -- it seems that as long as the processor is defined in the config file, each route-handling thread will create an instance of the processor, thereby opening a JNDI context with the proper credentials and allowing the publish calls to succeed. If this doesn't work, however, it would be a simple matter to add a call to the (empty) process() method in the camel route, thus ensuring that the processor class is instantiated in each publishing thread.