-->
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: Could not parse mapping document from resource...
PostPosted: Tue Mar 16, 2010 1:53 pm 
Newbie

Joined: Tue Mar 16, 2010 1:40 pm
Posts: 1
hi, i'm trying to do something with hibernate using Netbeans...
i did the file hibernate.cfg.xml like this:
<?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">
Code:
<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="contact.hbm.xml"/>
</session-factory>
</hibernate-configuration>


and another file contact.hbm.xml like this:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
  <class name="tutorial.hibernate.Contact" table="CONTACT">
      <id name="id" type="long" column="ID" >
      <generator class="increment"/>
     </id>

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


    <class name="tutorial.hibernate.Book" table="BOOK">

        <composite-id>
            <key-property name="lngBookId" column="id" type="long">

                <column not-null="true" name="id"/>
                <type name="long"/>
            </key-property>

        </composite-id>
       
     
        <property name="strBookAuthor" >
         <column name="bookauthor" not-null="true"/>
            <type name="string"/>
      </property>
      <property name="strBookName">
         <column name="bookname" />
            <type name="string"/>
      </property>
   </class>

   <class name="tutorial.hibernate.Insurance" table="insurance">
      <id name="lngInsuranceId" type="long" column="ID" >
         <generator class="increment"/>
      </id>

      <property name="insuranceName">
         <column name="insurance_name" />
      </property>
      <property name="investementAmount">
         <column name="invested_amount" />
      </property>
      <property name="investementDate">
         <column name="investement_date" />
      </property>
   </class>



</hibernate-mapping>


now the problem is that when i run the project i have this error on the console :

Code:
18:44:19,140 INFO  [TomcatDeployer] undeploy, ctxPath=/provahib, warUrl=.../tmp/deploy/tmp49637provahib-exp.war/
18:44:19,312 INFO  [TomcatDeployer] deploy, ctxPath=/provahib, warUrl=.../tmp/deploy/tmp49638provahib-exp.war/
18:44:22,906 INFO  [Configuration] configuring from resource: /hibernate.cfg.xml
18:44:22,906 INFO  [Configuration] Configuration resource: /hibernate.cfg.xml
18:44:22,921 INFO  [Configuration] Reading mappings from resource : contact.hbm.xml
18:44:22,953 INFO  [HbmBinder] Mapping class: tutorial.hibernate.Contact -> CONTACT
18:44:22,953 INFO  [HbmBinder] Mapping class: tutorial.hibernate.Book -> BOOK
18:44:22,953 INFO  [STDOUT] Could not parse mapping document from resource contact.hbm.xml
18:44:23,375 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
        at org.apache.jsp.index_jsp._jspService(index_jsp.java:126)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
        at java.lang.Thread.run(Thread.java:619)


can someone help me??

when i use normal id and not composite-id it is ok
Code:
...<class name="tutorial.hibernate.Book" table="book">
      <id name="lngBookId" type="long" column="id" >
         <generator class="increment"/>
      </id>
    <property name="strBookAuthor">
         <column name="bookauthor" />
      </property>
      <property name="strBookName">
         <column name="bookname" />
      </property>
   </class>...




i can't understand where is the mistake... thanks in advance and sorry for my poor english .

Apollo982


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.