-->
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: org.hibernate.InvalidMappingException
PostPosted: Mon Jun 30, 2008 3:33 am 
Newbie

Joined: Mon Jun 30, 2008 3:04 am
Posts: 2
Hallo zusammen,

ich habe versucht anhand des Tutorials ein kleines Beispiel zum Laufen zu bekommen. Aber es scheitert irgendwie am Mapping-File und ich weiß nicht warum.

Die ganze Sache läuft in einem Servlet. Ich benutze einen Tomcat-Server und habe alles JARs aus dem Hibernate-Core Lib-Verzeichnis in mein WEB-INF-Pfad kopiert und zu meinen Projekt-Bibliotheken hinzugefügt.

Ich bekomme stets folgende Meldung.

org.hibernate.InvalidMappingException: Could not parse mapping document from resource test/object/TestObject.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:545)
caused by: org.hibernate.MappingException: class test.object.TestObject not found while looking for property: id
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:74)
caused by: java.lang.ClassNotFoundException: test.object.TestObject
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)



Hat jemand ne Idee. Weitere Angaben zu meiner Laufzeitumgebung siehe unten.

Danke!

MfG
Robert


Hibernate version:
3.3


Mapping documents:
<?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="test.object.TestObject" table="TEST">
<id name="id" column="TEST_ID">
<generator class="native"/>
</id>
</class>
</hibernate-mapping>

Zugehörige Klasse:
Code:
public class TestObject
{   

    private Long id;       

    private String name;

    public TestObject()
    {
        id              = null;       
        name            = null;       
    }

   /** @return Returns the so-named property. */
    public Long getId()
    {
        return id;
    }

    /** @return Returns the so-named property. */
    public String getName()
    {
        return name;
    }

    /** Sets the so-named property. */
    public void setId(Long id)
    {
        this.id = id;
    }

    /** Sets the so-named property. */
    public void setName(String name)
    {
        this.name = name;
    }

}



Code before and between sessionFactory.openSession() and session.close():
Code:
Configuration cfg = new Configuration()
            .setProperty("connection.driver_class", "org.postgresql.Driver")
            .setProperty("connection.url", "jdbc:postgresql://localhost:5432")
            .setProperty("connection.username", "admin")
            .setProperty("connection.password", "")
            .setProperty("connection.pool_size", "1")
            .setProperty("dialect", "org.hibernate.dialect.PostgreSQLDialect")
            .setProperty("current_session_context_class", "thread")
            .setProperty("cache.provider_class", "org.hibernate.cache.NoCacheProvider")
            .setProperty("show_sql", "true")
            .setProperty("hbm2ddl.auto", "create")
            .addClass(test.object.TestObject.class);
           
       
            // Create the SessionFactory from hibernate.cfg.xml           
            SessionFactory sessionFactory = cfg.buildSessionFactory();
            Session session = sessionFactory.getCurrentSession();
           
             session.beginTransaction();
       
            TestObject test = new TestObject();
            test.setName("test1");

            session.save(test);
            session.getTransaction().commit();


Full stack trace of any exception that occurs:
org.hibernate.InvalidMappingException: Could not parse mapping document from resource test/object/TestObject.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:545)
at org.hibernate.cfg.Configuration.addClass(Configuration.java:592)
at test.object.TestManager.test(TestManager.java:36)
at common.TestServlet.service(TestServlet.java:48)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at com.atlassian.plugin.descriptors.servlet.ServletModuleContainerServlet.service(ServletModuleContainerServlet.java:38)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.atlassian.confluence.util.LoggingContextFilter.doFilter(LoggingContextFilter.java:49)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.atlassian.seraph.filter.SecurityFilter.doFilter(SecurityFilter.java:192)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.atlassian.seraph.filter.TrustedApplicationsFilter.doFilter(TrustedApplicationsFilter.java:114)
at com.atlassian.confluence.util.AbstractBootstrapHotSwappingFilter.doFilter(AbstractBootstrapHotSwappingFilter.java:28)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.atlassian.seraph.filter.BaseLoginFilter.doFilter(BaseLoginFilter.java:110)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.atlassian.confluence.util.ClusterHeaderFilter.doFilter(ClusterHeaderFilter.java:35)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.atlassian.johnson.filters.AbstractJohnsonFilter.doFilter(AbstractJohnsonFilter.java:72)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.springframework.orm.hibernate.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:170)
at com.atlassian.spring.filter.FlushingSpringSessionInViewFilter.doFilterInternal(FlushingSpringSessionInViewFilter.java:29)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.atlassian.util.profiling.filters.ProfilingFilter.doFilter(ProfilingFilter.java:142)
at com.atlassian.core.filters.ProfilingAndErrorFilter.doFilter(ProfilingAndErrorFilter.java:27)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.atlassian.confluence.core.datetime.RequestTimeThreadLocalFilter.doFilter(RequestTimeThreadLocalFilter.java:34)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.atlassian.confluence.util.RequestCacheThreadLocalFilter.doFilter(RequestCacheThreadLocalFilter.java:25)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.atlassian.gzipfilter.GzipFilter.doFilterInternal(GzipFilter.java:94)
at com.atlassian.gzipfilter.GzipFilter.doFilter(GzipFilter.java:64)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.atlassian.core.filters.AbstractEncodingFilter.doFilter(AbstractEncodingFilter.java:33)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.hibernate.MappingException: class test.object.TestObject not found while looking for property: id
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:74)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:279)
at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:401)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:334)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:273)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:144)
at org.hibernate.cfg.Configuration.add(Configuration.java:675)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:510)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:542)
... 61 more
Caused by: java.lang.ClassNotFoundException: test.object.TestObject
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1205)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:100)
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:70)
... 69 more

Name and version of the database you are using:
PostgreSQL 8.?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 30, 2008 5:02 am 
Expert
Expert

Joined: Thu Jul 05, 2007 9:38 am
Posts: 287
Irgendetwas ist faul mit deinem Classpath:

Caused by: java.lang.ClassNotFoundException: test.object.TestObject

Deine Klassen werden nicht gefunden (vielleicht eine falsche Package angabe?)

_________________
Please rate useful posts.


Schauderhaft: Softwaredevelopment, Projectmanagement, Qualitymanagement and all things "schauderhaft"


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 01, 2008 2:19 pm 
Newbie

Joined: Mon Jun 30, 2008 3:04 am
Posts: 2
Hallo,

danke für deine Antwort. Also ich bin jetzt ein Stück weiter hoffe ich. Und zwar ich habe in meinem Mapping-File nun mal explizit den Typ des "id"-elements gesetzt. Nun bekomme ich eine andere Exception, dass ich den Dialect angeben muss.


Das werde ich mal nachverfolgen.

mfg
Robert


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.