-->
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: duplicate class: org.hibernate.tutorial.domain.Event
PostPosted: Thu Feb 19, 2009 12:38 pm 
Newbie

Joined: Thu Feb 19, 2009 12:24 pm
Posts: 14
Hello,

I have problems when trying to learn Hibernate and I am a newbie to this and not senior of Java either. Hope anyone can help out. Thanks in advance!

The short version of the problem is "duplicate class: org.hibernate.tutorial.domain.Event" when I am trying to build the tutorial (http://www.hibernate.org/hib_docs/v3/re ... stapp.html) with Ant. It gets stuck on the "Compile" tag. See below for more details. I believe I have followed the instructions correctly, except the part where I should enable some kind of logging. I guess that doesn't matter, right?

Version of Hibernate: 3.3.1.GA:

Mapping documents:
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="events.Event" table="EVENTS">
        <id name="id" column="EVENT_ID">
            <generator class="native"/>
        </id>
        <property name="date" type="timestamp" column="EVENT_DATE"/>
        <property name="title"/>
    </class>

</hibernate-mapping>[/b]


[b]Code between sessionFactory.openSession() and session.close():
Code:
Session session = HibernateUtil.getSessionFactory().getCurrentSession();

        session.beginTransaction();

        Event theEvent = new Event();
        theEvent.setTitle(title);
        theEvent.setDate(theDate);

        session.save(theEvent);

        session.getTransaction().commit();


Full stack trace of any exception that occurs:
C:\TestArea\Hibernate>ant
Code:
Buildfile: build.xml

clean:
   [delete] Deleting directory C:\TestArea\Hibernate\bin
    [mkdir] Created dir: C:\TestArea\Hibernate\bin

copy-resources:
     [copy] Copying 2 files to C:\TestArea\Hibernate\bin
     [copy] Copied 2 empty directories to 1 empty directory under C:\TestArea\Hi
bernate\bin

compile:
    [javac] Compiling 3 source files to C:\TestArea\Hibernate\bin
    [javac] C:\TestArea\Hibernate\src\events\Event.java:5: duplicate class: org.
hibernate.tutorial.domain.Event
    [javac] public class Event {
    [javac]        ^
    [javac] C:\TestArea\Hibernate\src\events\EventManager.java:26: cannot access
events.Event
    [javac] bad class file: C:\TestArea\Hibernate\src\events\Event.java
    [javac] file does not contain class events.Event
    [javac] Please remove or make sure it appears in the correct subdirectory of
the classpath.
    [javac]         Event theEvent = new Event();
    [javac]         ^
    [javac] 2 errors

BUILD FAILED
C:\TestArea\Hibernate\build.xml:21: Compile failed; see the compiler error outpu
t for details.

Total time: 2 seconds[/b]


[b]Name and version of the database you are using:
hsqldb 1.8.0.10


Best Regards
Niklas

_________________
Beginners must also learn!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 19, 2009 8:07 pm 
Senior
Senior

Joined: Tue Aug 01, 2006 9:24 pm
Posts: 120
Someone might want to correct me on this but it looks like there is something wrong with your directory structure


Code:
    [javac] C:\TestArea\Hibernate\src\events\Event.java:5: duplicate class: org.
hibernate.tutorial.domain.Event


This indicates that there is an Event.java in the "events" package. Where as there is also an Event class in the "org.hibernate.tutorial.domain" package.

Are you sure you don't have 2 of these?
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2009 6:12 am 
Newbie

Joined: Thu Feb 19, 2009 12:24 pm
Posts: 14
I solved the problem. If you do exactly as the tutorial expalains you will have this error since the Events class package is defined to
Quote:
Code:
package org.hibernate.tutorial.domain;

but it should be defined to
Quote:
Code:
packge events;


Thank you for your time!

Now I am heading to the next problem to solve....: http://forum.hibernate.org/viewtopic.php?p=2406621#2406621

Best Regards,
Niklas

_________________
Beginners must also learn!


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.