-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 13 posts ] 
Author Message
 Post subject: Hibernate Search + Websphere 6 + Slave node configuration
PostPosted: Mon Apr 04, 2011 9:16 pm 
Beginner
Beginner

Joined: Fri Feb 18, 2011 7:30 pm
Posts: 41
I have configured a master/slave configuration for search and it all worked nicely when deployed on Tomcat. I am now trying to migrate to Websphere, and I am hitting the error below on deploying the slave application.

A quick search and look into search's source code revealed that in JMSBackendQueueProcessorFactory.prepareJMSTools(), there is a casting of the connection factory to a QueueConnectionFactory, hence the error. I have since modified the connection factory to be a QueueConnectionFactory, and still I get this error.

Any ideas? Has anyone else faced this issue? I can't find anything on the forums.

Thanks. (the error is below)

Caused by: java.lang.ClassCastException: com.ibm.ws.sib.api.jms.impl.JmsManagedQueueConnectionFactoryImpl incompatible with javax.jms.QueueConnectionFactory
at org.hibernate.search.backend.impl.jms.JMSBackendQueueProcessorFactory.prepareJMSTools(JMSBackendQueueProcessorFactory.java:92)
at org.hibernate.search.backend.impl.jms.JMSBackendQueueProcessorFactory.initialize(JMSBackendQueueProcessorFactory.java:61)
at org.hibernate.search.backend.impl.BatchedQueueingProcessor.<init>(BatchedQueueingProcessor.java:108)
at org.hibernate.search.backend.impl.TransactionalWorker.initialize(TransactionalWorker.java:98)
at org.hibernate.search.backend.WorkerFactory.createWorker(WorkerFactory.java:69)
at org.hibernate.search.spi.SearchFactoryBuilder.buildNewSearchFactory(SearchFactoryBuilder.java:277)
at org.hibernate.search.spi.SearchFactoryBuilder.buildSearchFactory(SearchFactoryBuilder.java:144)
at org.hibernate.search.event.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:137)
at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)


Top
 Profile  
 
 Post subject: Re: Hibernate Search + Websphere 6 + Slave node configuration
PostPosted: Tue Apr 05, 2011 5:16 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
It looks like a silly mistake in the IBM implementation. I'm sorry you have to use Websphere :)
I might be wrong on that, maybe you've looked up the wrong name?

You can easily workaround this by making your own extension of org.hibernate.search.backend.impl.jms.JMSBackendQueueProcessorFactory , and define the fully qualified classname as backend: Search will pick your implementation instead.
A JMS backend is a two-class service, should be quite easy to write your own using the IBM API.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Hibernate Search + Websphere 6 + Slave node configuration
PostPosted: Tue Apr 05, 2011 5:23 am 
Beginner
Beginner

Joined: Fri Feb 18, 2011 7:30 pm
Posts: 41
I can't imagine my horror of using web sphere. That is a story for another day :)

So do I need to specify the custom implementation in my configuration file somewhere? Or it will just be automatically picked up if it finds another implementation in my classpath?


Top
 Profile  
 
 Post subject: Re: Hibernate Search + Websphere 6 + Slave node configuration
PostPosted: Tue Apr 05, 2011 5:26 am 
Beginner
Beginner

Joined: Fri Feb 18, 2011 7:30 pm
Posts: 41
Forget that, I missed the part in your reply about specifying the fully qualified classname as backend. I'll try that and update you.


Top
 Profile  
 
 Post subject: Re: Hibernate Search + Websphere 6 + Slave node configuration
PostPosted: Wed Apr 06, 2011 1:42 pm 
Beginner
Beginner

Joined: Fri Feb 18, 2011 7:30 pm
Posts: 41
OK, it's almost there, but it is not working yet.

Now I get

java.lang.IncompatibleClassChangeError @ JMSBackendQueueProcessor.run() (Line 71)

Line 71 is trying to do this...
Code:
cnn = factory.getJMSFactory().createQueueConnection();


when the slave is trying to put a message on the queue.

I have cleaned the working directory and recompiled all classes, to no avail.

Here is a listing of my custom implementation...

Code:
public class WebsphereJMSBackendQueueProcessorFactory extends JMSBackendQueueProcessorFactory {
    private static final Logger log = Logger.getLogger(WebsphereJMSBackendQueueProcessorFactory.class);

    private String jmsQueueName;
   private String jmsConnectionFactoryName;
   private static final String JNDI_PREFIX = Environment.WORKER_PREFIX + "jndi.";
   private Properties properties;
//   private Queue jmsQueue;
//   private QueueConnectionFactory factory;
    private JmsManagedQueueConnectionFactoryImpl factory;
    private JmsQueueImpl jmsQueue;
   public static final String JMS_CONNECTION_FACTORY = Environment.WORKER_PREFIX + "jms.connection_factory";
   public static final String JMS_QUEUE = Environment.WORKER_PREFIX + "jms.queue";


    @Override
    public void initialize(Properties props, WorkerBuildContext context) {
        this.properties = props;
      this.jmsConnectionFactoryName = props.getProperty( JMS_CONNECTION_FACTORY );
      this.jmsQueueName = props.getProperty( JMS_QUEUE );
      prepareJMSTools();
    }

    @Override
    public void updateDirectoryProviders(Set<DirectoryProvider<?>> providers, WorkerBuildContext context) {
        //do nothing
    }

    @Override
    public Runnable getProcessor(List<LuceneWork> queue) {
        return new JMSBackendQueueProcessor(queue, this);
    }

    @Override
    public QueueConnectionFactory getJMSFactory() {
        return factory;
    }

    @Override
    public Queue getJmsQueue() {
        return jmsQueue;
    }

    @Override
    public String getJmsQueueName() {
        return jmsQueueName;
    }

    @Override
    public void close() {
        //do nothing
    }

    @Override
    public void prepareJMSTools() {
        log.debug(" in custom prepareJMSTools() ");

        if ( jmsQueue != null && factory != null ) {
         return;
      }
      try {
//         InitialContext initialContext = JNDIHelper.getInitialContext( properties, JNDI_PREFIX );
            InitialContext initialContext = new InitialContext();
         factory = (JmsManagedQueueConnectionFactoryImpl) initialContext.lookup( jmsConnectionFactoryName );
            log.debug(" done casting to IBM specific implementation");
         jmsQueue = (JmsQueueImpl) initialContext.lookup( jmsQueueName );
            log.debug(" done with queue lookup ");

            log.info("factory: " + factory);
            log.info("queue: " + jmsQueue);

      }
      catch ( NamingException e ) {
         throw new SearchException(
               "Unable to lookup Search queue ("
                     + ( jmsQueueName != null ?
                     jmsQueueName :
                     "null" ) + ") and connection factory ("
                     + ( jmsConnectionFactoryName != null ?
                     jmsConnectionFactoryName :
                     "null" ) + ")",
               e
         );
      }
    }
}


Any ideas?


Top
 Profile  
 
 Post subject: Re: Hibernate Search + Websphere 6 + Slave node configuration
PostPosted: Wed Apr 06, 2011 1:51 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
you're likely having different versions of some library. Possibly having a different version of something on the application server than what you compiled with.
I'd suggest to use tattletale to find out, it will create a nice html report of duplicate classes: http://www.jboss.org/tattletale

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Hibernate Search + Websphere 6 + Slave node configuration
PostPosted: Wed Apr 06, 2011 3:17 pm 
Beginner
Beginner

Joined: Fri Feb 18, 2011 7:30 pm
Posts: 41
Maybe. I'll try the utility and see, but I am preferring the application classpath over the servers'.
So are you saying there are incompatibilities within the jars packaged in my WAR?

Also, I have notice the websphere's implementation of the queue, factory, etc implement the required interfaces? So why is the cast failing when search is trying to do it?

e.g.

Code:
public class JmsManagedQueueConnectionFactoryImpl extends com.ibm.ws.sib.api.jms.impl.JmsManagedConnectionFactoryImpl implements javax.jms.QueueConnectionFactory{}


By all reasoning, I should be able to do ...

Code:
QueueConnectionFactory myQ = (QueueConnectionFactory) JmsManagedQueueConnectionFactoryImpl


So why can't it?


Top
 Profile  
 
 Post subject: Re: Hibernate Search + Websphere 6 + Slave node configuration
PostPosted: Wed Apr 06, 2011 3:21 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
that's another sign that you're having duplicate classes/jars on your classpath. Run the tool, it's not meant for a server classpath only, nor strongly coupled to JBossAS.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Hibernate Search + Websphere 6 + Slave node configuration
PostPosted: Wed Apr 06, 2011 10:21 pm 
Beginner
Beginner

Joined: Fri Feb 18, 2011 7:30 pm
Posts: 41
Thanks Sanne. You are right. The WAR was packaging jta and jms jars which the app server was not liking at all. Also, thanks for pointing me to tattletale, it seems like a good tool to have in my tool box (although, I am still trying to decipher the HTML report :))

That said, I was wondering if you could help with one more question.

So according to the docs, I can feed jndi stuff used to initialize the context via

Quote:
hibernate.search.worker.jndi.* Defines the JNDI properties to initiate the InitialContext (if needed). JNDI is only used by the JMS back end.


This will work fine for standard JNDI configuration constants like initial_context_factory, provider_url, etc (I assume).

What about specifying things that are vendor specific? For example, in websphere, to successfully java a standalone java client look up the destination on a running server and use it, in addition to specifying initial_context_factory and provider_url, we need to specify a third parameter which is vendor specific

i.e.
com.ibm.CORBA.ORBInit=com.ibm.ws.sib.client.ORB

If I wanted to pass this when configuring the slave node in search, how will I do it?

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: Hibernate Search + Websphere 6 + Slave node configuration
PostPosted: Thu Apr 07, 2011 12:50 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi, I'm not sure I understood. The slave configuration is up to you, you have to extend (or reimplement, as you wish) the org.hibernate.search.backend.impl.jms.AbstractJMSHibernateSearchController. So you're totally free on how to configure it.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Hibernate Search + Websphere 6 + Slave node configuration
PostPosted: Thu Apr 07, 2011 3:05 pm 
Beginner
Beginner

Joined: Fri Feb 18, 2011 7:30 pm
Posts: 41
Thanks Sanne. I have already overridden the default AbstractJMSHibernateSearchController as I need to handle some messages specially on onMessage().

My question is can you provide vendor specify jndi additional properties in hibernate.cfg.xml or persistence.xml?

For instance, you can provide

hibernate.search.worker.jndi.url=tcp://localhost:61616

which corresponds to the Context.PROVIDER_URL.

How about vendor specify options like the one I mentioned in my earlier post? Can you do that via this mechanism?


Top
 Profile  
 
 Post subject: Re: Hibernate Search + Websphere 6 + Slave node configuration
PostPosted: Thu Apr 07, 2011 6:23 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
ah, got it.
Should work according to what I read in org.hibernate.search.util.JNDIHelper : all properties beginning with that prefix are passed on, stripping away the prefix.

We're not hiding the source code ;) you can search for it as well.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Hibernate Search + Websphere 6 + Slave node configuration
PostPosted: Thu Apr 07, 2011 7:48 pm 
Beginner
Beginner

Joined: Fri Feb 18, 2011 7:30 pm
Posts: 41
Interesting, I just peeked in there now. It actually says that is it pass through. Thanks, I'll give that a shot.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 13 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.