环境
tomcat6.0.18
spring2.5.6
hibernate-search-3.0.0.GA.jar(hibernate-search-3.1.0.GA.jar也不行)
hibernate-3.2.5.ga.jar
部分程式
import org.apache.lucene.analysis.StopAnalyzer;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
1 Session session = super.getSessionFactory().getCurrentSession();
2 FullTextSession fullTextSession = Search.createFullTextSession(session);
3 Transaction tx = fullTextSession.beginTransaction();
4 QueryParser parser = new QueryParser("keyword", new StopAnalyzer());
第1行可以得到current session 类型为org.hibernate.Session;
第2行抛
java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/catalina/loader/StandardClassLoader) previously initiated loading for a different type with name "org/hibernate/Session"
请大家帮忙看看,急坏了
[b]问题补充:[/b]
1.方法createFullTextSession是hibernate-search-3.0.0.GA.jar中的方法
/**
- Helper class to get a FullTextSession out of a regular session.
- @author Emmanuel Bernard
-
@author Hardy Ferentschik
*/
public final class Search {private Search() {
}public static FullTextSession getFullTextSession(Session session) {
if (session instanceof FullTextSessionImpl) {
return (FullTextSession) session;
}
else {
return new FullTextSessionImpl(session);
}
}/**
- @deprecated As of release 3.1.0, replaced by {@link #getFullTextSession(Session)} */ @Deprecated public static FullTextSession createFullTextSession(Session session) { return getFullTextSession(session); } }
2.我装的是解压版的tomcat6
3.不是tomcat/lib下的el-api.jar与项目WEB-INF/lib目录下的el-api.jar冲突。
[b]问题补充:[/b]
4.环境换成hibernate-search-3.1.0.GA.jar
hibernate-core-3.3.1.GA.jar
的组合,问题依然存在。。。
[b]问题补充:[/b]
5.很抱歉忘记注明“spring+hibernate search时抛java.lang.LinkageError”是在zk框架下应用的,脱离ZK,重新写了个测试的方法
通过ClassPathXmlApplicationContext获取有session的bean,在该bean中调用hibernate search 就没有错误了
还要try是不是zk下的包和和ibernate search中的jar有冲突