Hi,
Thanks a lot for your answer.
Actually, the configurations in my post are for my local Windows machine. I just want to do some testings before deploying to Linux server on Amazon (sorry for making confusion there).
With the SessionFactory problem, maybe you were right to say it was a kind of configuration error. Unfortunately, I have not figured it out and came up with a workaround: copy and modify the source codes of AbstartJMSHibernateSearchController class, replace the getSession() method with some configuration hard codes.
Here is my new classes:
Code:
/* Copy codes from class AbstartJMSHibernateSearchController of Emmanuel Bernard */
public class HSearchJMSHibernateSearchController implements MessageListener {
private static final Logger log = LoggerFactory.make();
/**
* Process the Hibernate Search work queues received
*/
@SuppressWarnings("unchecked")
public void onMessage(Message message) {
if ( !( message instanceof ObjectMessage ) ) {
log.error( "Incorrect message type: {}", message.getClass() );
return;
}
ObjectMessage objectMessage = (ObjectMessage) message;
List<LuceneWork> queue;
try {
queue = (List<LuceneWork>) objectMessage.getObject();
}
catch (JMSException e) {
log.error( "Unable to retrieve object from message: " + message.getClass(), e );
return;
}
catch (ClassCastException e) {
log.error( "Illegal object retrieved from message", e );
return;
}
Runnable worker = getWorker( queue );
worker.run();
}
private Runnable getWorker(List<LuceneWork> queue) {
Runnable processor = null;
/* Modified code: Directly get the SearchFactoryImplementor */
SearchFactoryImplementor factory = HSearchContextHelper.getSearchFactory();
processor = factory.getBackendQueueProcessorFactory().getProcessor( queue );
return processor;
}
@PostConstruct
public void initialize() {
//init the source copy process
//TODO actually this is probably wrong since this is now part of the DP
}
@PreDestroy
public void shutdown() {
//stop the source copy process
//TODO actually this is probably wrong since this is now part of the DP
}
}
Code:
public abstract class HSearchContextHelper {
public static SearchFactoryImplementor getSearchFactory() {
FullTextIndexEventListener listener = new FullTextIndexEventListener(Installation.SINGLE_INSTANCE);
Configuration cfg = new Configuration();
Properties properties = new Properties();
properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
properties.setProperty("hibernate.show_sql", "false");
properties.setProperty("hibernate.format_sql", "false");
properties.setProperty("hibernate.generate_statistics", "true");
properties.setProperty("hibernate.search.default.sourceBase", "/mnt/lucenedirs/master");
properties.setProperty("hibernate.search.default.refresh", "30");
properties.setProperty("hibernate.search.default.indexBase", "/usr/lucenedirs/master");
properties.setProperty("hibernate.search.default.directory_provider", "filesystem-master");
cfg.setProperties(properties);
cfg.addAnnotatedClass(Requirement.class);
cfg.addAnnotatedClass(TestCase.class);
cfg.addAnnotatedClass(Defect.class);
cfg.addAnnotatedClass(Project.class);
cfg.buildMappings();
cfg.buildSettings();
listener.initialize(cfg);
return listener.getSearchFactoryImplementor();
}
}
Honestly, I'm feeling good with this workaround and not sure whether it makes any sense to you guys, but at least it seems to work fine. Do you have any advice for that?
Thanks a lot and Best regards,