Announcement Announcement Module
Collapse
No announcement yet.
JMS Sending message from one Weblogic domain to a queue on another domain Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JMS Sending message from one Weblogic domain to a queue on another domain

    I am trying to send a message from a Weblogic 10.3.4 domain to a JMS queue hosted in another Weblogic 10.3.4 domain. Both domains run on the same host.

    I have been able to write a simple Java program that successfully sends a message to the queue in the other domain; but I am not able to do so by using the <jee:jndi-lookup... or the JndiObjectFactoryBean. The JNDI lookup fails with a name not found exception. It doesn't seem to be able to find it on the other domain's JNDI tree, even though I am using the provider URL of the domain where the queue is residing (The same as used by the programe below that works)...

    Is there some secret to getting this to work?
    Any assistance would be much appreciated.
    Thanks in advance...

    Here is the code that successfully sends the message:
    Code:
    	public Object invoke(Object object) throws ServiceInvocationException {
    		try {
    			Object convertedObject = object;
    			if (object instanceof Document) {
    				if (LOG.isInfoEnabled())
    				{
    					LOG.info(getClass().getName()+".invoke with Document type argument is called");
    				}
    				convertedObject = DOMSerializerHelper
    						.serializeDocument((Document) object);
    			}
    
    			Hashtable<String,String> props = new Hashtable<String,String>();
    			props.put(Context.INITIAL_CONTEXT_FACTORY,
    					"weblogic.jndi.WLInitialContextFactory");
    			props.put(Context.PROVIDER_URL, "t3://localhost:7003");
    			props.put(Context.SECURITY_PRINCIPAL, "weblogic");
    			props.put(Context.SECURITY_CREDENTIALS, "mypassword");
    			Context ctx = new InitialContext(props);
    			qconFactory = (QueueConnectionFactory) ctx.lookup(JMS_FACTORY);
    			if (qconFactory == null)
    			{
    				if (LOG.isErrorEnabled())
    				{
    					LOG.error("Queue connection factory is null.");
    					return object;
    				}
    			}
    			if (LOG.isInfoEnabled())
    			{
    				LOG.info("JMS connection factory "+JMS_FACTORY+" looked up");
    			}
    			qcon = qconFactory.createQueueConnection();
    			qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    			if (LOG.isInfoEnabled())
    			{
    				LOG.info("Queue connection created.");
    			}
    			queue = (Queue) ctx.lookup(QUEUE);
    			if (queue == null)
    			{
    				if (LOG.isErrorEnabled())
    				{
    					LOG.error("Queue lookup returns null.");
    					return object;
    				}
    			}
    			qsender = qsession.createSender(queue);
    			if (LOG.isInfoEnabled())
    			{
    				LOG.info("Create queue sender for "+QUEUE);
    			}
    			msg = qsession.createTextMessage();
    			msg.setText(convertedObject.toString());
    			if (LOG.isInfoEnabled())
    			{
    				LOG.info("Message to send "+msg.getText());
    			}
    			qcon.start();
    			qsender.send(msg);
    			if (LOG.isInfoEnabled())
    			{
    				LOG.info("Message sent");
    			}
    		} catch (Exception e) {
    			if (LOG.isErrorEnabled())
    			{
    				LOG.error("Failed to send message: "+e);
    				LOG.error(StackTraceUtil.getStackTrace(e));
    			}
    		} finally {
    			try {
    				if (qsender != null)
    				{
    					qsender.close();
    					if (LOG.isInfoEnabled())
    					{
    						LOG.info("Closed queue sender");
    					}
    				}
    				if (qsession != null) 
    				{
    					qsession.close();
    					if (LOG.isInfoEnabled())
    					{
    						LOG.info("Closed queue session");
    					}
    				}
    				if (qcon != null) 
    				{
    					qcon.close();
    					if (LOG.isInfoEnabled())
    					{
    						LOG.info("Closed queue connection");
    					}
    				}
    			} catch (JMSException ex) {
    				if (LOG.isErrorEnabled())
    				{
    					LOG.error("Failed to close JMS resources: "+ex);
    				}
    			}
    		}
    		return object;
    	}

  • #2
    You need to show us your Spring configuration.

    Also, in your example code above you are using the JMS 1.0.2 spec API (createQueueConnection() Vs. createConnection() for version 1.1).

    I am pretty sure WL 10 supports the 1.1 spec.

    Comment


    • #3
      JMS Sending message from one Weblogic domain to a queue on another domain

      Originally posted by Gary Russell View Post
      You need to show us your Spring configuration.

      Also, in your example code above you are using the JMS 1.0.2 spec API (createQueueConnection() Vs. createConnection() for version 1.1).

      I am pretty sure WL 10 supports the 1.1 spec.
      The reason I posted the code is to indicate that it is possible with Weblogic to send to a queue on another domain without using a bridge. I would expect 1.1 to work as well... but maybe not...

      Here is the configuration.

      Code:
      	  <jee:jndi-lookup id="externalAuditInboundQueue" jndi-name="${jms.audit.external.inbound.queue}" >
      		<jee:environment>
      			java.naming.factory.initial=${jndi.default.initialContextFactory}
      			java.naming.provider.url=${jms.audit.external.providerURL}
      			java.naming.security.principal=${jms.audit.external.username}
      			java.naming.security.credentials=${jms.audit.external.password}
      		</jee:environment>
      	</jee:jndi-lookup>
      Here are the property values:

      Code:
      jndi.default.initialContextFactory=weblogic.jndi.WLInitialContextFactory
      jms.audit.external.defaultConnectionFactory=jms.audit.ConnectionFactory
      jms.audit.external.inbound.queue=jms.audit.InboundMessageQueue
      jms.audit.external.providerURL=t3://localhost:7003
      jms.audit.external.username=weblogic
      jms.audit.external.password=weblogicdev1
      The context header is:
      <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
      xmlns="http://www.springframework.org/schema/p" xmlns:jee="http://www.springframework.org/schema/jee"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schem...-beans-2.5.xsd
      http://www.springframework.org/schema/jee http://www.springframework.org/schem...ng-jee-2.5.xsd
      http://www.springframework.org/schema/context
      http://www.springframework.org/schema/context/spring-context-2.5.xsd">

      I'm running Spring version 3.2.0. What it make any difference to change the version in the xsd refs?
      Last edited by flyeagle5683; Mar 25th, 2013, 05:43 PM.

      Comment


      • #4
        This may be helpful as well.

        <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
        xmlns="http://www.springframework.org/schema/p" xmlns:jee="http://www.springframework.org/schema/jee"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schem...-beans-2.5.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schem...ng-jee-2.5.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-2.5.xsd">

        Hmm, I'm running Spring 3.2.0. Would it make a difference if I referenced the 3.2 in the xsd references?

        Comment


        • #5
          Probably not, but it's best practice to use version-less schemas so you use the appropriate schema for the version on the classpath.

          Next step would be to turn on debug logging and see what's happening with the JNDI lookup, and compare it to what's happening with your version that works.

          Bottom line is the Spring JNDI code does effectively the same as your explicit code, so something must be different in the environment.

          Comment


          • #6
            JMS Sending message from one Weblogic domain to a queue on another domain

            After further analysis, it turns out that the JNDI lookup is actually working. The queue is found at startup. The failure occurs when attempting to send a message. I tried using the JmsTemplate102 to see if it was related to JMS 1.1; but had the same issue occur. It fails on line 242 of JmsTemplate102; ((QueueSender) producer).send(message);

            Code:
            Caused By: java.lang.Exception: Destination not found
            	at weblogic.messaging.dispatcher.InvocableManager.invocableFind(InvocableManager.java:107)
            	at weblogic.jms.dispatcher.InvocableManagerDelegate$MyInvocableManager.invocableFind(InvocableManagerDelegate.java:301)
            	at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:943)
            	at weblogic.messaging.dispatcher.DispatcherImpl.dispatchAsyncInternal(DispatcherImpl.java:139)
            	at weblogic.messaging.dispatcher.DispatcherImpl.dispatchAsync(DispatcherImpl.java:115)
            	at weblogic.messaging.dispatcher.Request.dispatchAsync(Request.java:1303)
            	at weblogic.jms.dispatcher.Request.dispatchAsync(Request.java:96)
            	at weblogic.jms.frontend.FEProducer.doDispatch(FEProducer.java:888)
            	at weblogic.jms.frontend.FEProducer.sendRetryDestination(FEProducer.java:1021)
            	at weblogic.jms.frontend.FEProducer.send(FEProducer.java:1405)
            	at weblogic.jms.frontend.FEProducer.invoke(FEProducer.java:1466)
            	at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:961)
            	at weblogic.messaging.dispatcher.DispatcherImpl.syncRequest(DispatcherImpl.java:184)
            	at weblogic.messaging.dispatcher.DispatcherImpl.dispatchSyncTran(DispatcherImpl.java:237)
            	at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSyncTran(DispatcherAdapter.java:51)
            	at weblogic.jms.client.JMSProducer.toFEProducer(JMSProducer.java:1289)
            	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:394)
            	at weblogic.jms.client.JMSProducer.send(JMSProducer.java:384)
            	at weblogic.jms.client.WLProducerImpl.send(WLProducerImpl.java:970)
            	at org.springframework.jms.core.JmsTemplate102.doSend(JmsTemplate102.java:242)
            	at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:569)
            	at org.springframework.jms.core.JmsTemplate$3.doInJms(JmsTemplate.java:536)
            	at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:466)
            	at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:534)
            	at org.springframework.jms.core.JmsTemplate.convertAndSend(JmsTemplate.java:612)
            	at org.springframework.jms.core.JmsTemplate.convertAndSend(JmsTemplate.java:604)
            	at gov.va.med.datasharing.common.messaging.jms.JmsTransport.send(JmsTransport.java:62)

            Comment


            • #7
              JMS Sending message from one Weblogic domain to a queue on another domain

              Never mind. I found the problem. The connection factory being references was in the application domain rather than the other domain. Thanks for your assistance. It was helpful...

              Comment


              • #8
                JMS Sending message from one Weblogic domain to a queue on another domain

                I spoke too soon. I have gotten past the 'Destination not found' issue; however, now a SecurityException is occurring. Upon startup, the createConnection method in JmsAccessor is called and successfully completes. However, at the point when a message is sent, the same call fails with a security exception. Here is the exception:
                Code:
                java.lang.SecurityException: [Security:090398]Invalid Subject: principals=[Some application security tokens]
                The principals listed in the exception above are those used for authorizing a user when logging into the Web GUI. The user initiates the send of the message from the Web GUI...

                My question is how in the world are the user authorization tokens being passed into the JmsAccessor. The code that is failing is:
                Code:
                	protected Connection createConnection() throws JMSException {
                		return getConnectionFactory().createConnection();
                	}
                Somehow the user authorization principals are being used to create the JMS connection.
                Can someone give me a clue as to how the JmsTemplate determines the prinicipals at the time a message is sent. The security on the JNDI lookup of the connection factory and queue work fine. Only when that method is called while sending a message does it fail.

                Comment


                • #9
                  Any assistance would be greatly appreciated.
                  Thanks in advance..

                  Here is the stacktrace:
                  Code:
                  org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [AnnotatedAction@1f2d8d8 targetAction = [EvaluateAction@7a8e88 expression = patientService.changeADCStatus(flowScope.patientView, flowScope.userLoginBean), resultExpression = flowScope.patientView], attributes = map[[empty]]] in state 'viewPatientADC' of flow 'patientADC' -- action execution attributes were 'map[[empty]]'
                  ... some Spring webflow code...
                  	at org.springframework.binding.expression.spel.SpringELExpression.getValue(SpringELExpression.java:84)
                  	at org.springframework.webflow.action.EvaluateAction.doExecute(EvaluateAction.java:75)
                  	at org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:188)
                  	at org.springframework.webflow.execution.AnnotatedAction.execute(AnnotatedAction.java:145)
                  	at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:51)
                  	... 42 more
                  Caused by: java.lang.SecurityException: [Security:090398]Invalid Subject: principals=[WebGUI login credentials]
                  	at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234)
                  	at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:348)
                  	at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)
                  	at weblogic.jms.frontend.FEConnectionFactoryImpl_1034_WLStub.connectionCreateRequest(Unknown Source)
                  	at weblogic.jms.client.JMSConnectionFactory.setupJMSConnection(JMSConnectionFactory.java:224)
                  	at weblogic.jms.client.JMSConnectionFactory.createConnectionInternal(JMSConnectionFactory.java:285)
                  	at weblogic.jms.client.JMSConnectionFactory.createConnection(JMSConnectionFactory.java:191)
                  	at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184)
                  	at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:456)
                  	at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:534)
                  	at org.springframework.jms.core.JmsTemplate.convertAndSend(JmsTemplate.java:612)
                  	at org.springframework.jms.core.JmsTemplate.convertAndSend(JmsTemplate.java:604)
                  	at gov.va.med.datasharing.common.messaging.jms.JmsTransport.send(JmsTransport.java:62)
                  	at gov.va.med.datasharing.common.messaging.service.jms.JmsServiceInvoker.invoke(JmsServiceInvoker.java:61)
                  .... some application code...
                  	at gov.va.med.datasharing.core.ServiceBusImpl.processInbound(ServiceBusImpl.java:118)
                  	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                  	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  	at java.lang.reflect.Method.invoke(Method.java:597)
                  	at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
                  	at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
                  	at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
                  	at com.bea.core.repackaged.springframework.jee.intercept.MethodInvocationInvocationContext.proceed(MethodInvocationInvocationContext.java:104)
                  	at com.bea.core.repackaged.springframework.jee.intercept.JeeInterceptorInterceptor.invoke(JeeInterceptorInterceptor.java:72)
                  	at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
                  	at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
                  	at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
                  	at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
                  	at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:37)
                  	at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
                  	at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:50)
                  	at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
                  	at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
                  	at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
                  	at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
                  	at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
                  	at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
                  	at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
                  	at $Proxy95.processInbound(Unknown Source)
                  	at gov.va.med.datasharing.core.ServiceBus_r6xnti_ServiceBusImpl.__WL_invoke(Unknown Source)
                  	at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:40)
                  	at gov.va.med.datasharing.core.ServiceBus_r6xnti_ServiceBusImpl.processInbound(Unknown Source)
                  	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                  	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  	at java.lang.reflect.Method.invoke(Method.java:597)
                  	at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:85)
                  	... 66 more
                  Caused by: java.lang.SecurityException: [Security:090398]Invalid Subject: principals=[WebGUI login credentials]
                  	at weblogic.security.service.SecurityServiceManager.seal(SecurityServiceManager.java:833)
                  	at weblogic.security.service.SecurityServiceManager.getSealedSubjectFromWire(SecurityServiceManager.java:522)
                  	at weblogic.rjvm.MsgAbbrevInputStream.getSubject(MsgAbbrevInputStream.java:349)
                  	at weblogic.rmi.internal.BasicServerRef.acceptRequest(BasicServerRef.java:953)
                  	at weblogic.rmi.internal.BasicServerRef.dispatch(BasicServerRef.java:351)
                  	at weblogic.rmi.cluster.ClusterableServerRef.dispatch(ClusterableServerRef.java:242)
                  	at weblogic.rjvm.RJVMImpl.dispatchRequest(RJVMImpl.java:1141)
                  	at weblogic.rjvm.RJVMImpl.dispatch(RJVMImpl.java:1023)
                  	at weblogic.rjvm.ConnectionManagerServer.handleRJVM(ConnectionManagerServer.java:240)
                  	at weblogic.rjvm.ConnectionManager.dispatch(ConnectionManager.java:888)
                  	at weblogic.rjvm.MsgAbbrevJVMConnection.dispatch(MsgAbbrevJVMConnection.java:512)
                  	at weblogic.rjvm.t3.MuxableSocketT3.dispatch(MuxableSocketT3.java:330)
                  	at weblogic.socket.BaseAbstractMuxableSocket.dispatch(BaseAbstractMuxableSocket.java:298)
                  	at weblogic.socket.SocketMuxer.readReadySocketOnce(SocketMuxer.java:950)
                  	at weblogic.socket.SocketMuxer.readReadySocket(SocketMuxer.java:888)
                  	at weblogic.socket.JavaSocketMuxer.processSockets(JavaSocketMuxer.java:339)
                  	at weblogic.socket.SocketReaderRequest.run(SocketReaderRequest.java:29)

                  Comment


                  • #10
                    The JmsTemplate is not involved; I suspect this is the app server's issue - best guess he is binding the user's Subject to the thread and the container is using it to establish the connection.

                    You may need to wrap your JNDI connection factory in a UserCredentialsConnectionFactoryAdapter.

                    See its javadocs for more information: http://static.springsource.org/sprin...ryAdapter.html

                    Comment


                    • #11
                      JMS Sending message from one Weblogic domain to a queue on another domain

                      I tried using the adapter you recommended and still have the same problem. I verified in the debugger that line 175 in the UserCredentialsConnectionFactoryAdapter is being called, which calls createConnection, passing in the username and password into the targetConnectionFactory... The adapter appears to be applied, but the same problem occurs.

                      Comment


                      • #12
                        I assume you see the UCCFA stack frame within the stack trace here (>>>>)...

                        Code:
                        Caused by: java.lang.SecurityException: [Security:090398]Invalid Subject: principals=[WebGUI login credentials]
                        	at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234)
                        	at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:348)
                        	at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)
                        	at weblogic.jms.frontend.FEConnectionFactoryImpl_1034_WLStub.connectionCreateRequest(Unknown Source)
                        	at weblogic.jms.client.JMSConnectionFactory.setupJMSConnection(JMSConnectionFactory.java:224)
                        	at weblogic.jms.client.JMSConnectionFactory.createConnectionInternal(JMSConnectionFactory.java:285)
                        	at weblogic.jms.client.JMSConnectionFactory.createConnection(JMSConnectionFactory.java:191)
                        >>>>
                        	at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184)
                        	at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:456)
                        ...in which case, you need to talk to WebLogic (or seek help in their documentation).

                        Comment


                        • #13
                          There's lots of information here http://docs.oracle.com/cd/E23943_01/...7/dahelper.htm

                          I haven't worked with WebLogic for years but a quick read of the above indicates your "test" code works because you are doing the send on the same thread as the one that did the JNDI lookup.

                          I also found this after a bit of googling... https://kr.forums.oracle.com/forums/...readID=2287667

                          It's about JDBC instead of JMS but it shows a similar error. It appears to have a number of suggestions for cross-domain security in WLS.

                          Comment


                          • #14
                            JMS Sending message from one Weblogic domain to a queue on another domain

                            Thank you for your assistance.

                            It was an issue with inter-domain security. Created global trust between the 2 domains and it worked!

                            Comment

                            Working...
                            X