-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate Programatic Configuration not working
PostPosted: Fri Jan 06, 2012 7:06 am 
Newbie

Joined: Fri Jan 06, 2012 6:40 am
Posts: 2
Code:
ServiceRegistryBuilder serviceRegistryBuilder = new ServiceRegistryBuilder();
serviceRegistryBuilder.applySetting(AvailableSettings.DATASOURCE,  "java:/myJNDIds");
serviceRegistryBuilder.configure(ServiceRegistryBuilder.DEFAULT_CFG_RESOURCE_NAME);
MetadataSources metadataSources = new MetadataSources(serviceRegistryBuilder.buildServiceRegistry());
resolveAndConfigureMappingJars(metadataSources); // adding mapping files to metadatasource
resolveAndConfigureAnnotedClass(metadataSources); // adding hibernate annotated class files  to metadatasource
SessionFactory  sessionFactory= metadataSources.buildMetadata().buildSessionFactory();


When i run this configuration i'm getting the following error.

Code:
16:26:50,929 ERROR [org.egov.infstr.client.filter.HibSessionServletFilter] (http-127.0.0.1-127.0.0.1-8080-1) org.hibernate.internal.util.config.ConfigurationException: Unable to perform unmarshalling at line number 7 and column 1 in RESOURCE hibernate.cfg.xml. Message: cvc-elt.1: Cannot find the declaration of element 'hibernate-configuration'.
16:26:50,930 ERROR [org.egov.EGOVRuntimeException] (http-127.0.0.1-127.0.0.1-8080-1) Unable to perform unmarshalling at line number 7 and column 1 in RESOURCE hibernate.cfg.xml. Message: cvc-elt.1: Cannot find the declaration of element 'hibernate-configuration'.: org.hibernate.internal.util.config.ConfigurationException: Unable to perform unmarshalling at line number 7 and column 1 in RESOURCE hibernate.cfg.xml. Message: cvc-elt.1: Cannot find the declaration of element 'hibernate-configuration'.
   at org.hibernate.service.internal.JaxbProcessor.unmarshal(JaxbProcessor.java:120) [hibernate-core-4.0.0.Final.jar:]
   at org.hibernate.service.internal.JaxbProcessor.unmarshal(JaxbProcessor.java:69) [hibernate-core-4.0.0.Final.jar:]
   at org.hibernate.service.ServiceRegistryBuilder.configure(ServiceRegistryBuilder.java:162) [hibernate-core-4.0.0.Final.jar:]
   at org.egov.infstr.utils.HibernateUtil.createSessionFactory(HibernateUtil.java:74) [egov-infrastructure.jar:]
   at org.egov.infstr.utils.HibernateUtil.getSessionFactory(HibernateUtil.java:143) [egov-infrastructure.jar:]
   at org.egov.infstr.utils.HibernateUtil.getCurrentSession(HibernateUtil.java:150) [egov-infrastructure.jar:]
   at org.egov.infstr.utils.HibernateUtil.beginTransaction(HibernateUtil.java:163) [egov-infrastructure.jar:]
   at org.egov.infstr.client.filter.HibSessionServletFilter.doFilter(HibSessionServletFilter.java:54) [egov-infrastructure.jar:]
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.6.Final.jar:]
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.6.Final.jar:]
   at org.egov.infstr.client.filter.SetThreadLocals.doFilter(SetThreadLocals.java:49) [egov-infrastructure.jar:]
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.6.Final.jar:]
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.6.Final.jar:]
   at net.sf.ehcache.constructs.web.filter.GzipFilter.doFilter(GzipFilter.java:85) [ehcache-web-2.0.3.jar:]
   at net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:86) [ehcache-web-2.0.3.jar:]
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.6.Final.jar:]
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.6.Final.jar:]
   at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) [org.springframework.web-3.1.0.RELEASE.jar:]
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) [org.springframework.web-3.1.0.RELEASE.jar:]
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.6.Final.jar:]
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.6.Final.jar:]
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.6.Final.jar:]
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.6.Final.jar:]
   at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:151) [jboss-as-web-7.1.0.CR1-SNAPSHOT.jar:]
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.6.Final.jar:]
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.6.Final.jar:]
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.6.Final.jar:]
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.6.Final.jar:]
   at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:897) [jbossweb-7.0.6.Final.jar:]
   at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:626) [jbossweb-7.0.6.Final.jar:]
   at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:2033) [jbossweb-7.0.6.Final.jar:]
   at java.lang.Thread.run(Thread.java:619) [:1.6.0]
Caused by: javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'hibernate-configuration'.]
   at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:425)
   at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:362)
   at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:332)
   at org.hibernate.service.internal.JaxbProcessor.unmarshal(JaxbProcessor.java:108) [hibernate-core-4.0.0.Final.jar:]
   ... 31 more
Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'hibernate-configuration'.
   at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:196)
   at org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:132)
   at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:390)
   at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:322)
   at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:281)
   at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1982)
   at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:724)
   at org.apache.xerces.jaxp.validation.ValidatorHandlerImpl.startElement(ValidatorHandlerImpl.java:555)
   at com.sun.xml.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.startElement(ValidatingUnmarshaller.java:96)
   at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStartElement(StAXStreamConnector.java:242)
   at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:176)
   at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360)
   ... 33 more



and the following is my hibernate.cfg.xml


Code:
<?xml version='1.0' encoding='utf-8'?>

<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
   <session-factory>
      <property name="hibernate.cache.region.factory_class">org.hibernate.cache.infinispan.InfinispanRegionFactory</property>
      <property name="hibernate.cache.use_second_level_cache">true</property>
      <property name="hibernate.cache.use_query_cache">true</property>
      <property name="hibernate.cache.use_minimal_puts">true</property>
      <property name="hibernate.search.lucene_version">LUCENE_34</property>
      <property name="hibernate.dialect">org.hibernate.dialect.PostgresPlusDialect</property>
      <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
      <property name="hibernate.transaction.jta.platform">org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform</property>
      <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
      <property name="hibernate.transaction.flush_before_completion">true</property>
      <property name="hibernate.transaction.auto_close_session">true</property>
      <property name="hibernate.jdbc.use_streams_for_binary">false</property>
      <property name="hibernate.show.sql">true</property>
      <event type="save">
         <listener class="org.egov.infstr.event.listener.HibernateEventListener"/>
         <listener class="org.hibernate.event.internal.DefaultSaveOrUpdateEventListener"/>
      </event>
      <event type="update">
         <listener class="org.egov.infstr.event.listener.HibernateEventListener"/>
         <listener class="org.hibernate.event.internal.DefaultSaveOrUpdateEventListener"/>
      </event>
      <event type="save-update">
         <listener class="org.egov.infstr.event.listener.HibernateEventListener"/>
         <listener class="org.hibernate.event.internal.DefaultSaveOrUpdateEventListener"/>
      </event>
      <event type="pre-update">
          <listener class="org.egov.infstr.event.listener.HibernateEventListener"/>
      </event>
      <event type="post-update">
           <listener class="org.hibernate.search.event.impl.FullTextIndexEventListener"/>
       </event>
       <event type="post-insert">
           <listener class="org.hibernate.search.event.impl.FullTextIndexEventListener"/>
       </event>
       <event type="post-delete">
           <listener class="org.hibernate.search.event.impl.FullTextIndexEventListener"/>
       </event>
  </session-factory>
</hibernate-configuration>





Already sick and tiered of JBoss AS 7 , on top hibernate is beating like this...............

Can any expert kindly tell me how to solve this issue.?

When i used old way of configuring and getting SessionFactory its working but EventListner's are not getting invoked. The same cfg is working perfect with Hibernate 3.

Please give me some solution


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

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.