<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Re: Getting "association error" when reverse-engineering an existing schema with Hibernate tools
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/johnqcitizen">John Citizen</a> in <i>JBoss Tools</i> - <a href="https://community.jboss.org/message/801796#801796">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>So I decided to remove maven from the problem and wrote an ant build script that uses hibernate tools directly. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>But I still get the same error:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">[hibernatetool] An exception occurred while running exporter #2:hbm2java (Generates a set of .java files)</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">[hibernatetool] To get the full stack trace run ant with -verbose</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">[hibernatetool] org.hibernate.MappingException: <strong>An association from the table FOO refers to an unmapped class: com.whatever.domain.Bar</strong></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">BUILD FAILED</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">build.xml:23: org.hibernate.MappingException: An association from the table FOO refers to an unmapped class: com.whatever.domain.Bar</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1285)</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.hibernate.cfg.JDBCMetaDataConfiguration.secondPassCompileForeignKeys(JDBCMetaDataConfiguration.java:33)</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1203)</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1148)</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:56)</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:318)</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:94)</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.hibernate.tool.ant.Hbm2JavaExporterTask.configureExporter(Hbm2JavaExporterTask.java:34)</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Here's my ant <strong>build.xml</strong> file:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&lt;project basedir="." default="reveng"&gt;</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160; &lt;path id="toolslib"&gt;</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160; &lt;path location="/r/org/hibernate/hibernate-tools/3.2.3.GA/<strong>hibernate-tools-3.2.3.GA.jar</strong>" /&gt;</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160; &lt;path location="/r/org/hibernate/hibernate-core/3.3.1.GA/<strong>hibernate-core-3.3.1.GA.jar</strong>" /&gt;</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160; &lt;path location="/r/org/hibernate/hibernate-annotations/3.4.0.GA/hibernate-annotations-3.4.0.GA.jar" /&gt;</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160; &lt;path location="/r/freemarker/freemarker/2.3.8/freemarker-2.3.8.jar" /&gt;</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160; &lt;path location="/r/com/oracle/ojdbc/11.1.0.6.0/<strong>ojdbc-11.1.0.6.0.jar</strong>" /&gt;</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160; &lt;path location="/r/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar" /&gt;</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160; &lt;path location="/r/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar" /&gt;</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160; &lt;path location="/r/org/slf4j/slf4j-api/1.5.6/slf4j-api-1.5.6.jar" /&gt;</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160; &lt;path location="/r/org/slf4j/slf4j-log4j12/1.5.6/slf4j-log4j12-1.5.6.jar" /&gt;</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160; &lt;path location="/r/log4j/log4j/1.2.16/log4j-1.2.16.jar" /&gt;</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160; &lt;path location="/r/cglib/cglib/2.2.2/cglib-2.2.2.jar" /&gt;</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160; &lt;path location="/r/asm/asm/3.3.1/asm-3.3.1.jar" /&gt;</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160; &lt;path location="/r/commons-collections/commons-collections/3.1/commons-collections-3.1.jar" /&gt;</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160; &lt;/path&gt;</span></p><p style="padding-left: 30px;">&#160; </p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160; &lt;taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="toolslib" /&gt;</span></p><p style="padding-left: 60px;">&#160; </p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160; &lt;target name="reveng" description="Reverse-engineer a DB schema"&gt;</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160; &lt;hibernatetool destdir="${build.dir}/generated"&gt;</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; &lt;jdbcconfiguration propertyfile="<strong>hibernate.properties</strong>" packagename="com.whatever.domain" revengfile="<strong>reveng.xml</strong>" /&gt;</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160;&#160;&#160; &lt;hbm2java jdk5="true" ejb3="true" /&gt;</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160;&#160;&#160; &lt;/hibernatetool&gt;</span></p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier;">&#160; &lt;/target&gt;</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="padding-left: 30px;"><span style="font-family: 'courier new', courier; font-size: 10pt;">&lt;/project&gt;</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>It is accessing the same <strong>hibernate.properties</strong> file and <strong>reveng.xml</strong> file specified in the comment above.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Hope this helps.</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/801796#801796">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Tools at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2128">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>