You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by atokle <at...@gmail.com> on 2014/11/04 21:51:55 UTC

cxf 3.0.1 don't let me configure local lookup of jms ConnectionFactory

I did earlier use cxf 2.4.3, and configured soap over jms using the
JMSConfiguration style which is deprecated in cxf 3.0.

Now I use the new SOAP / JMS spec compliant configuration - recommended
style for CXF 3.
I deploy my application on a weblogic server version 10.3.3.6, on a ExaLogic
server.

If the queue is located on a remote cluster, I use an URI like this:
jms:jndi:jms.myapplication.queue?jndiInitialContextFactory=weblogic.jndi.WLInitialContextFactory&jndiURL=t3://server1:8001,server2:8001,server2:8001&jndiConnectionFactoryName=weblogic.jms.XAConnectionFactory

This works fine, but when connection to the queue from an application on the
local cluster, I don't want to do a remote lookup. It's a more complicated
configuration, and it's slower since the request have to leave the internal
infiniband, and try the different servers on the cluster until it find one
that is up.
I tried this URI:
jms:jndi:jms.myapplication.queue?jndiConnectionFactoryName=weblogic.jms.XAConnectionFactory

But then I get this Exception:
java.lang.IllegalArgumentException: connectionFactory may not be null
	at
org.apache.cxf.transport.jms.JMSConfiguration.ensureProperlyConfigured(JMSConfiguration.java:97)
~[_wl_cls_gen.jar:3.0.1]
	at
org.apache.cxf.transport.jms.JMSDestination.activate(JMSDestination.java:106)
~[cxf-rt-transports-jms-3.0.1.jar:3.0.1]
	at
org.apache.cxf.transport.AbstractObservable.setMessageObserver(AbstractObservable.java:49)
~[cxf-core-3.0.1.jar:3.0.1]
	at
org.apache.cxf.binding.AbstractBindingFactory.addListener(AbstractBindingFactory.java:96)
~[cxf-core-3.0.1.jar:3.0.1]

I was able to make it work by changing two classes:
org.apache.cxf.transport.jms.JMSConfigFactory.createFromEndpoint(....)
Changed from:
        if (endpoint.getJndiURL() != null) {
            // Configure Connection Factory using jndi
           
jmsConfig.setJndiEnvironment(JMSConfigFactory.getInitialContextEnv(endpoint));
           
jmsConfig.setConnectionFactoryName(endpoint.getJndiConnectionFactoryName());
Changed to:
       
jmsConfig.setConnectionFactoryName(endpoint.getJndiConnectionFactoryName());
        if (endpoint.getJndiURL() != null) {
            // Configure Connection Factory using jndi
           
jmsConfig.setJndiEnvironment(JMSConfigFactory.getInitialContextEnv(endpoint));


org.apache.cxf.transport.jms.JMSFactory.getConnectionFactoryFromJndi(....)
Changed from:
        if (jmsConfig.getJndiEnvironment() == null ||
jmsConfig.getConnectionFactoryName() == null) {
            return null;
        }
Changed to:
        if(jmsConfig.getConnectionFactoryName() == null){
            LOG.error("ConnectionFactoryName is not specified.");
            return null;
        }
        if (jmsConfig.getJndiEnvironment() == null) {
            LOG.warn("JndiEnvironment is not specified. Trying local
lookup");
            try {
                Context ctx = new InitialContext();
                Object located =
ctx.lookup(jmsConfig.getConnectionFactoryName());
                if (located == null) {
                    throw new NameNotFoundException("JNDI object with [" +
jmsConfig.getConnectionFactoryName() + "] not found");
                }
                return (ConnectionFactory) located;
            } catch (NamingException e) {
                throw new RuntimeException(e);
            }
        }

Have two questions:
1. Did I configure the URI wrong when trying to lookup from JNDI locally. If
so, what is the correct syntax.
2. If there is no solution to look up CF from JNDI locally, can you please
implement a fix that give the same functionality as the one with the code
posted above.



--
View this message in context: http://cxf.547215.n5.nabble.com/cxf-3-0-1-don-t-let-me-configure-local-lookup-of-jms-ConnectionFactory-tp5750700.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: cxf 3.0.1 don't let me configure local lookup of jms ConnectionFactory

Posted by Christian Schneider <ch...@die-schneider.net>.
Something like that should work.

About XAConnectionfactory you should keep in mind that jms only can 
handle ConnectionFactory.
You typically use a Pooling wrapper around a XAConnectionFactory. You 
can find a description of this
for ActiveMQ here: http://cxf.apache.org/docs/jms-transactions.html

Not sure how this is done for weblogic though but if you find out we can 
document it.

Christian



Am 05.11.2014 10:06, schrieb atokle:
> Thank you for quick response.
>
> With a ConnectionFactoryFeature, I guess I can wire up this in spring with
> something like this:
>
>      <bean id="cxfMyApplicationJmsSubscriber"
> class="no.mycompany.myapp.MyApplicationJmsSubscriber" />
>
>      <bean id="jmsConnFactory"
> class="org.springframework.jndi.JndiObjectFactoryBean">
>          <property name="jndiName" value="weblogic.jms.XAConnectionFactory"/>
>      </bean>
>
>      <jaxws:endpoint id="myapplication"
> implementor="#cxfMyApplicationJmsSubscriber"
> address="jms:jndi:jms.myapplication.queue">
>          <jaxws:features>
>              <bean
> class="org.apache.cxf.transport.jms.ConnectionFactoryFeature">
>                  <constructor-arg ref="jmsConnFactory" />
>              </bean>
>          </jaxws:features>
>      </jaxws:endpoint>
>
> Will try it when I get permission to do some test deploys to weblogic server
> again.
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/cxf-3-0-1-don-t-let-me-configure-local-lookup-of-jms-ConnectionFactory-tp5750700p5750708.html
> Sent from the cxf-user mailing list archive at Nabble.com.


-- 
  
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com


Re: cxf 3.0.1 don't let me configure local lookup of jms ConnectionFactory

Posted by atokle <at...@gmail.com>.
Thank you for quick response.

With a ConnectionFactoryFeature, I guess I can wire up this in spring with
something like this:

    <bean id="cxfMyApplicationJmsSubscriber"
class="no.mycompany.myapp.MyApplicationJmsSubscriber" />

    <bean id="jmsConnFactory"
class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName" value="weblogic.jms.XAConnectionFactory"/>
    </bean>

    <jaxws:endpoint id="myapplication"
implementor="#cxfMyApplicationJmsSubscriber"
address="jms:jndi:jms.myapplication.queue">
        <jaxws:features>
            <bean
class="org.apache.cxf.transport.jms.ConnectionFactoryFeature">
                <constructor-arg ref="jmsConnFactory" />
            </bean>
        </jaxws:features>
    </jaxws:endpoint>

Will try it when I get permission to do some test deploys to weblogic server
again.



--
View this message in context: http://cxf.547215.n5.nabble.com/cxf-3-0-1-don-t-let-me-configure-local-lookup-of-jms-ConnectionFactory-tp5750700p5750708.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: cxf 3.0.1 don't let me configure local lookup of jms ConnectionFactory

Posted by Christian Schneider <ch...@die-schneider.net>.
You can use the ConnectionFactoryFeature to manually set a connection 
factory. You can find some examples here: 
http://cxf.apache.org/docs/soap-over-jms-10-support.html

Using java code it should be easy to do the lookup and spring allows to 
lookup the connection
factory from jndi too.

For the next version we could implement the changes you did if they have 
no side effects. Can you open a jira issue for this?

Best regards

Christian


Am 04.11.2014 21:51, schrieb atokle:
> I did earlier use cxf 2.4.3, and configured soap over jms using the
> JMSConfiguration style which is deprecated in cxf 3.0.
>
> Now I use the new SOAP / JMS spec compliant configuration - recommended
> style for CXF 3.
> I deploy my application on a weblogic server version 10.3.3.6, on a ExaLogic
> server.
>
> If the queue is located on a remote cluster, I use an URI like this:
> jms:jndi:jms.myapplication.queue?jndiInitialContextFactory=weblogic.jndi.WLInitialContextFactory&jndiURL=t3://server1:8001,server2:8001,server2:8001&jndiConnectionFactoryName=weblogic.jms.XAConnectionFactory
>
> This works fine, but when connection to the queue from an application on the
> local cluster, I don't want to do a remote lookup. It's a more complicated
> configuration, and it's slower since the request have to leave the internal
> infiniband, and try the different servers on the cluster until it find one
> that is up.
> I tried this URI:
> jms:jndi:jms.myapplication.queue?jndiConnectionFactoryName=weblogic.jms.XAConnectionFactory
>
> But then I get this Exception:
> java.lang.IllegalArgumentException: connectionFactory may not be null
> 	at
> org.apache.cxf.transport.jms.JMSConfiguration.ensureProperlyConfigured(JMSConfiguration.java:97)
> ~[_wl_cls_gen.jar:3.0.1]
> 	at
> org.apache.cxf.transport.jms.JMSDestination.activate(JMSDestination.java:106)
> ~[cxf-rt-transports-jms-3.0.1.jar:3.0.1]
> 	at
> org.apache.cxf.transport.AbstractObservable.setMessageObserver(AbstractObservable.java:49)
> ~[cxf-core-3.0.1.jar:3.0.1]
> 	at
> org.apache.cxf.binding.AbstractBindingFactory.addListener(AbstractBindingFactory.java:96)
> ~[cxf-core-3.0.1.jar:3.0.1]
>
> I was able to make it work by changing two classes:
> org.apache.cxf.transport.jms.JMSConfigFactory.createFromEndpoint(....)
> Changed from:
>          if (endpoint.getJndiURL() != null) {
>              // Configure Connection Factory using jndi
>             
> jmsConfig.setJndiEnvironment(JMSConfigFactory.getInitialContextEnv(endpoint));
>             
> jmsConfig.setConnectionFactoryName(endpoint.getJndiConnectionFactoryName());
> Changed to:
>         
> jmsConfig.setConnectionFactoryName(endpoint.getJndiConnectionFactoryName());
>          if (endpoint.getJndiURL() != null) {
>              // Configure Connection Factory using jndi
>             
> jmsConfig.setJndiEnvironment(JMSConfigFactory.getInitialContextEnv(endpoint));
>
>
> org.apache.cxf.transport.jms.JMSFactory.getConnectionFactoryFromJndi(....)
> Changed from:
>          if (jmsConfig.getJndiEnvironment() == null ||
> jmsConfig.getConnectionFactoryName() == null) {
>              return null;
>          }
> Changed to:
>          if(jmsConfig.getConnectionFactoryName() == null){
>              LOG.error("ConnectionFactoryName is not specified.");
>              return null;
>          }
>          if (jmsConfig.getJndiEnvironment() == null) {
>              LOG.warn("JndiEnvironment is not specified. Trying local
> lookup");
>              try {
>                  Context ctx = new InitialContext();
>                  Object located =
> ctx.lookup(jmsConfig.getConnectionFactoryName());
>                  if (located == null) {
>                      throw new NameNotFoundException("JNDI object with [" +
> jmsConfig.getConnectionFactoryName() + "] not found");
>                  }
>                  return (ConnectionFactory) located;
>              } catch (NamingException e) {
>                  throw new RuntimeException(e);
>              }
>          }
>
> Have two questions:
> 1. Did I configure the URI wrong when trying to lookup from JNDI locally. If
> so, what is the correct syntax.
> 2. If there is no solution to look up CF from JNDI locally, can you please
> implement a fix that give the same functionality as the one with the code
> posted above.
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/cxf-3-0-1-don-t-let-me-configure-local-lookup-of-jms-ConnectionFactory-tp5750700.html
> Sent from the cxf-user mailing list archive at Nabble.com.


-- 
  
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com