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.  [ 3 posts ] 
Author Message
 Post subject: Changed Doctype, but still have problems :(
PostPosted: Tue Oct 03, 2006 8:00 am 
Newbie

Joined: Fri Aug 25, 2006 6:53 am
Posts: 13
Hi,

My web application is still complaining about the hibernate.cfg.xml file even after I changed the Doctype declaeration. From the console I read that the problem is because it can not find some of the tags, example it tells me that hibernate-configuration needs to be declared, however I do have that in my cfg.xml file. I really do not know what I need to change!! I do not know what to do. Could someone please give me advise on what I have wrong? Below I posted some documents which I think can be helpfull!

Thank You and Regards,
bormli

Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
   
<hibernate-configuration>

<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory name="systemSessionFactory">

  <!-- SQL Server (Local) Connection properties -->

  <property name="connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
  <property name="connection.url">jdbc:microsoft:sqlserver://localhost:1433;databaseName=system</property>
  <property name="connection.username">system</property>
  <property name="connection.password">password</property>
  <property name="dialect">org.hibernate.dialect.SQLServerDialect</property> 
  <property name="show_sql">true</property>


  <!-- mapping files -->
  <mapping resource="com/comp/cvmanager/common/impl/BaseAccount.hbm.xml"/>
  <mapping resource="com/comp/cvmanager/common/impl/BaseResource.hbm.xml"/>
  <mapping resource="com/comp/cvmanager/common/impl/BaseContact.hbm.xml"/>
  <mapping resource="com/comp/cvmanager/common/impl/BaseAddress.hbm.xml"/>
  <mapping resource="com/comp/cvmanager/common/impl/BaseEmployment.hbm.xml"/>
  <mapping resource="com/comp/cvmanager/common/impl/BaseProject.hbm.xml"/>
  <mapping resource="com/comp/cvmanager/common/impl/BaseSkillDefinition.hbm.xml"/>

</session-factory>
</hibernate-configuration>
However when I run the application with these settings (on JBoss), I get the following exception in my window:

Code:
13:45:05,203 INFO  [Environment] Hibernate 3.1
13:45:05,218 INFO  [Environment] hibernate.properties not found
13:45:05,218 INFO  [Environment] using CGLIB reflection optimizer
13:45:05,218 INFO  [Environment] using JDK 1.4 java.sql.Timestamp handling
13:45:05,296 INFO  [Configuration] configuring from resource: /hibernate.cfg.xml

13:45:05,296 INFO  [Configuration] Configuration resource: /hibernate.cfg.xml
13:45:05,343 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(7) Document
root element "hibernate-configuration", must match DOCTYPE root "hibernate-mapp
ing".
13:45:05,343 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(7) Element
type "hibernate-configuration" must be declared.
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(9) Element
type "session-factory" must be declared.
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(13) The con
tent of element type "property" must match "(meta*,(column|formula)*,type?)".
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(14) The con
tent of element type "property" must match "(meta*,(column|formula)*,type?)".
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(15) The con
tent of element type "property" must match "(meta*,(column|formula)*,type?)".
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(16) The con
tent of element type "property" must match "(meta*,(column|formula)*,type?)".
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(17) The con
tent of element type "property" must match "(meta*,(column|formula)*,type?)".
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(18) The con
tent of element type "property" must match "(meta*,(column|formula)*,type?)".
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(51) Element
type "mapping" must be declared.
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(52) Element
type "mapping" must be declared.
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(53) Element
type "mapping" must be declared.
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(54) Element
type "mapping" must be declared.
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(55) Element
type "mapping" must be declared.
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(56) Element
type "mapping" must be declared.
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(57) Element
type "mapping" must be declared.
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(58) Element
type "mapping" must be declared.
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(59) Element
type "mapping" must be declared.
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(60) Element
type "mapping" must be declared.
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(61) Element
type "mapping" must be declared.
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(62) Element
type "mapping" must be declared.
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(63) Element
type "mapping" must be declared.
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(64) Element
type "mapping" must be declared.
13:45:05,375 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(65) Element
type "mapping" must be declared.
13:45:05,390 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(66) Element
type "mapping" must be declared.
13:45:05,390 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(67) Element
type "mapping" must be declared.
13:45:05,390 ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(68) Element
type "mapping" must be declared.
13:45:05,390 INFO  [STDOUT] org.hibernate.MappingException: invalid configuratio
n
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1347)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1288)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1274)
        at com.comp.cvmanager.util.HibernateUtil.<clinit>(Unknown Source)
        at com.comp.cvmanager.dao.DAOFactory.getSession(Unknown Source)
        at com.comp.cvmanager.dao.DAOFactory.getAccountDAO(Unknown Source)
        at com.comp.cvmanager.service.impl.BaseAccountService.findByUsernam
e(Unknown Source)
        at com.comp.cvmanager.actions.LoginAction.getAccount(Unknown Source
)
        at com.comp.cvmanager.actions.LoginAction.doLogin(Unknown Source)
        at com.comp.cvmanager.actions.LoginAction.execute(Unknown Source)
        at org.apache.struts.action.RequestProcessor.processActionPerform(Reques
tProcessor.java:419)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:224)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:119
6)
        at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
lter.java:81)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
        at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrinc
ipalValve.java:39)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
yAssociationValve.java:159)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
e.java:59)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:856)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:744)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:527)
        at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWor
kerThread.java:112)
        at java.lang.Thread.run(Thread.java:595)
Caused by: org.xml.sax.SAXParseException: Document root element "hibernate-confi
guration", must match DOCTYPE root "hibernate-mapping".
        at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Un
known Source)
        at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.dtd.XMLDTDValidator.rootElementSpecified(Unkno
wn Source)
        at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown
Source)
        at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Sourc
e)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unkn
own Source)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.s
canRootElementHook(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent
Dispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Un
known Source)
        at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
        at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Sour
ce)
        at org.dom4j.io.SAXReader.read(SAXReader.java:465)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1344)
        ... 34 more
13:45:05,390 ERROR [[action]] Servlet.service() for servlet action threw excepti
on
java.lang.ExceptionInInitializerError
        at com.comp.cvmanager.util.HibernateUtil.<clinit>(Unknown Source)
        at com.comp.cvmanager.dao.DAOFactory.getSession(Unknown Source)
        at com.comp.cvmanager.dao.DAOFactory.getAccountDAO(Unknown Source)
        at com.comp.cvmanager.service.impl.BaseAccountService.findByUsernam
e(Unknown Source)
        at com.comp.cvmanager.actions.LoginAction.getAccount(Unknown Source
)
        at com.comp.cvmanager.actions.LoginAction.doLogin(Unknown Source)
        at com.comp.cvmanager.actions.LoginAction.execute(Unknown Source)
        at org.apache.struts.action.RequestProcessor.processActionPerform(Reques
tProcessor.java:419)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:224)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:119
6)
        at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
lter.java:81)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
        at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrinc
ipalValve.java:39)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
yAssociationValve.java:159)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
e.java:59)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:856)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:744)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:527)
        at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWor
kerThread.java:112)
        at java.lang.Thread.run(Thread.java:595)
Caused by: org.hibernate.MappingException: invalid configuration
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1347)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1288)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1274)
        ... 32 more
Caused by: org.xml.sax.SAXParseException: Document root element "hibernate-confi
guration", must match DOCTYPE root "hibernate-mapping".
        at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Un
known Source)
        at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.dtd.XMLDTDValidator.rootElementSpecified(Unkno
wn Source)
        at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown
Source)
        at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Sourc
e)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unkn
own Source)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.s
canRootElementHook(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent
Dispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Un
known Source)
        at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
        at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Sour
ce)
        at org.dom4j.io.SAXReader.read(SAXReader.java:465)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1344)
        ... 34 more
My mapping files are done automatically using XDoclet and an example of one of my *hbm.xml files is as follows:

Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
>
<class
  name="com.comp.cvmanager.common.impl.BaseAddress"
  table="contact"
>

  <id
   name="id"
   column="id"
   type="java.lang.Long"
  >
   <generator class="assigned">
     <!-- 
      To add non XDoclet generator parameters, create a file named
      hibernate-generator-params-BaseAddress.xml
      containing the additional parameters and place it in your merge dir.
     -->
   </generator>
  </id>

  <one-to-one
   name="contact"
   class="com.comp.cvmanager.common.impl.BaseContact"
   cascade="none"
   outer-join="auto"
   constrained="false"
  />

  <property
   name="house"
   type="java.lang.String"
   update="true"
   insert="true"
   column="address1"
  />

  <property
   name="street"
   type="java.lang.String"
   update="true"
   insert="true"
   column="address2"
  />

  <property
   name="city"
   type="java.lang.String"
   update="true"
   insert="true"
   column="city"
  />

  <property
   name="country"
   type="java.lang.String"
   update="true"
   insert="true"
   column="country"
  />

  <property
   name="postCode"
   type="java.lang.String"
   update="true"
   insert="true"
   column="postcode"
  />

  <!--
   To add non XDoclet property mappings, create a file named
    hibernate-properties-BaseAddress.xml
   containing the additional properties and place it in your merge dir.
  -->

</class>

</hibernate-mapping>
And finally my HibernateUtil class to load the session is as follows:

Code:
package com.comp.cvmanager.util;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

/**
* Basic Hibernate helper class for Hibernate configuration and startup.
*
* @author Bormli
*
*/
public class HibernateUtil {

    private static Configuration configuration;
    private static SessionFactory sessionFactory;
   
    static {
       try {
          // Karl: Instantiating the configuration object
          configuration = new Configuration();
          
          // Configure ORM from the default configuration file.
          configuration.configure();
          
          // Create the session factory.
            sessionFactory = configuration.buildSessionFactory();
        } catch (Throwable ex) {
          ex.printStackTrace();
          throw new ExceptionInInitializerError(ex);
        }
    }
   
    /**
     * Returns the global SessionFactory.
     *
     * @return SessionFactory
     */
    public static SessionFactory getSessionFactory() {
       return sessionFactory;
    }
}


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 03, 2006 1:34 pm 
Regular
Regular

Joined: Tue Sep 26, 2006 11:37 am
Posts: 115
Location: Sacramento, CA
Your doctype must match the root xml element. You need to use something like the following, you can use a differrnt version if one is available.

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 03, 2006 1:40 pm 
Senior
Senior

Joined: Wed Aug 17, 2005 12:56 pm
Posts: 136
Location: Erie, PA (USA)
You're using the mapping dtd in the configuration file.

Curtis ...

_________________
---- Don't forget to rate! ----


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