Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!

anil rashnil

Greenhorn
+ Follow
since Jul 06, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by anil rashnil

Hi,
I m getting this exception, while running the hibernate program.

I have added all require jar for hibernate.

It throws :

Initial SessionFactory creation failed.org.hibernate.MappingException: invalid configuration

Caused by: org.xml.sax.SAXParseException: The content of element type "session-factory" must match "(property*,mapping*,(class-cache|collection-cache)*,event*,listener*)".


Folder are as follows.

Main class.


HibernateUtil.java



hibernate.cfg.xml files is as follows.

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/hibernatetutorial</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- Mapping files -->
<mapping resource="Event.hbm.xml"/>
</session-factory>
</hibernate-configuration>

Stack trace:

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Initial SessionFactory creation failed.org.hibernate.MappingException: invalid configuration
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.religare.sample.util.HibernateUtil.<clinit>(HibernateUtil.java:17)
at com.religare.sample.bean.EventManager.listEvents(EventManager.java:23)
at com.religare.sample.bean.EventManager.main(EventManager.java:17)
Caused by: org.hibernate.MappingException: invalid configuration
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1411)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1352)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1338)
at com.religare.sample.util.HibernateUtil.<clinit>(HibernateUtil.java:13)
... 2 more
Caused by: org.xml.sax.SAXParseException: The content of element type "session-factory" must match "(property*,mapping*,(class-cache|collection-cache)*,event*,listener*)".
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(XMLDTDValidator.java:2048)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(XMLDTDValidator.java:932)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:719)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1408)
... 5 more



When i m using struts2.1.6 dojo plugin.

It gives error here.

<script>
function show_details() {
dojo.event.topic.publish("show_detail"); /*...The function publish(String) is undefined.*/
}
</script>

Code where i m using this function.


<s:if test="conn!=null">
<td><s:url id="d_url" action="DetailAction.action" /></td>
<table width="600" align="Center">

<s:form name="DBLabelAction" id="DBLabelAction" action="UpdateRemoteDBLable">
<tr>
<td>System is connected to remote database.</td>
</tr>
<tr>
<s:select name="attributeName" list="dbLabelList"
label="Select Attribute" headerKey="0"
headerValue="--Please Select--" cssClass="textfield" required="true" />
</tr>
<tr>
<td> </td>
</tr>

<s:select name="remoteDbTable" list="remoteDbtableList"
label="Select Table" headerKey="0" headerValue="--Please Select--"
cssClass="textfield" required="true"
onchange= "show_details()"/>


<sx:div
showLoadingText="false" id="details" href="DetailAction" theme="ajax"
listenTopics="show_detail" formId="DBLabelAction">
</sx:div>



<s:submit value=" submit " align="center"></s:submit>
</s:form>
<tr>
<td> </td>
</tr>

</table>


</s:if>


Please help what to do, in order to run ajax successfully. i have tried all sources to run this, but not successful.
8 years ago