-->
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.  [ 2 posts ] 
Author Message
 Post subject: ExceptionInInitializerError while creating session
PostPosted: Fri Oct 29, 2010 4:28 am 
Beginner
Beginner

Joined: Tue Sep 28, 2010 5:14 am
Posts: 25
Hi,

I am using hibernate-search with following jars and using annotations for configuration.

hibernate-commons-annotations-3.3.0.ga.jar
hibernate-search.jar
hibernate-annotations-3.4.0.GA.jar
hibernate-core.jar
lucene-core.jar
solr-common-1.3.0.jar
solr-core-1.3.0.jar

My code snippet:


SessionFactory sessionFactory = new org.hibernate.cfg.AnnotationConfiguration().configure().buildSessionFactory();

Session session =sessionFactory.openSession();
FullTextSession fts = Search.getFullTextSession(session);
Transaction transaction = fts.beginTransaction();


TermQuery termQuery = new TermQuery(new Term("firstName", "Batman"));

BooleanQuery booleanQuery = new BooleanQuery();
booleanQuery.add(termQuery, BooleanClause.Occur.SHOULD);

try {
//execute the query
List<Contact> contact = fts.createFullTextQuery(booleanQuery, Contact.class).list();
System.out.println("contact.size() " + contact.size());
for (Contact cont : contact) {
System.out.println(cont.getFirstName());
fts.index(cont);
}
} catch (Exception e){
e.printStackTrace();
}

transaction.commit();


Configuration :

<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@test.com:1524:LNGPD1</property>
<property name="hibernate.connection.username">testUser</property>
<property name="hibernate.connection.password">passw0rd</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>

<!-- Hibernate search configuration -->
<property name="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</property>
<property name="hibernate.search.deafult.indexBase">C:\Hibernateexample\hibernate\indexes</property>
<property name="hibernate.search.default.batch.merge_factor">10</property>
<property name="hibernate.search.default.batch.max_buffered_docs">10</property>

<!-- Mapping files -->
<mapping resource="contact.hbm.xml"/>
<!-- mapping class="com.test.poc.search.Contact" /-->
</session-factory>
</hibernate-configuration>

However, while trying to create a session I am getting following error :

java.lang.ExceptionInInitializerError
org.hibernate.cfg.AnnotationConfiguration.<clinit>(AnnotationConfiguration.java:78)
com.test.talentportfolio.esearch.tpSearchForm.TPSearchForm.onSubmit(TPSearchForm.java:68)
org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:267)
org.springframework.web.servlet.mvc.AbstractFormController.handleInvalidSubmit(AbstractFormController.java:671)
org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:272)
org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:523)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:463)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

What I gathered from previous discussion was that this could be because of incompatible jars, but I have tested this code with same jars on a stand alone application and it works fine, its causing a problem only when I use it in web application.

Can anyone throw some light on this please. Your help is much appreicated

--Manoj


Top
 Profile  
 
 Post subject: Re: ExceptionInInitializerError while creating session
PostPosted: Fri Oct 29, 2010 4:30 am 
Beginner
Beginner

Joined: Tue Sep 28, 2010 5:14 am
Posts: 25
Sorry missed entity configuration file : contact.hbm.xml

<hibernate-mapping>

<class name="com.test.talentportfolio.dao.Contact" table="CONTACT">
<id name="id" type="long" column="ID" >
<generator class="assigned"/>
</id>

<property name="firstName">
<column name="FIRSTNAME" />
</property>
<property name="lastName">
<column name="LASTNAME"/>
</property>
<property name="email">
<column name="EMAIL"/>
</property>
</class>
</hibernate-mapping>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.