-->
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.  [ 22 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Problem with middlegen building .java from hbm.xml
PostPosted: Tue May 25, 2004 4:01 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
I use Middlegen and want to to generate java from hbm.xml filer. Middlegen doies this but has a fault in its building. It can't find the hibernate.cfg.xml file (or more exact the path to it.

The thing is that I can't find that file in the maps. What do I do??

This what Middlegen prints out in its building process:

Code:
[hbm2java] Caused by: java.io.FileNotFoundException: C:\Middlegen\middlegen-2.0-vo\samples\hibernat
\hibernate.cfg.xml (The system cannot find the path specified)



Best regards

Johan


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 4:02 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
This is from my build.xml

Code:
<target name="hbm2java" depends="middlegen" description="Generate .java from .hbm files.">
   <taskdef name="hbm2java"
   classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
   classpathref="lib.class.path"/>
   <hbm2java config="${config.dir}/hibernate/hibernate.cfg.xml" output="${src.dir}">
   <fileset dir="config\sar\mapping">
      <include name="**/*.hbm.xml"/>
   </fileset>
   </hbm2java>
</target>


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 4:15 am 
Regular
Regular

Joined: Wed Apr 21, 2004 10:57 am
Posts: 62
Location: Hasselt, Belgium
You should use another config file then your hibernate.cfg.xml.
I've had a problem when using my hibernate.cfg.xml and just using another xml file named hbm2java.cfg.xml (can be anything actually) got my hbm2java working. My file has the following lines in it, this should be sufficient.

<codegen>
<generate renderer="net.sf.hibernate.tool.hbm2java.BasicRenderer"/>
</codegen>

Also make sure the xml file is in the right directory. In your case this would be the C:\Middlegen\middlegen-2.0-vo\samples\

Peter


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 4:18 am 
Regular
Regular

Joined: Wed Apr 21, 2004 10:57 am
Posts: 62
Location: Hasselt, Belgium
I mean "C:\Middlegen\middlegen-2.0-vo\samples\hibernate\"


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 4:32 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
Hey Peter

Thanks, that worked but I have e new fault when running middlegen after the correction:

Code:
[middlegen] Updated preferences in C:\Middlegen\middlegen-2.0-vo\samples\src\airline-prefs.propertie
s

hbm2java:
[hbm2java] Processing 12 files.
[hbm2java] Building hibernate objects
[hbm2java] (hbm2java.ClassMapping               656 ) Could not find UserType: airline.hibernate.De
liveryaddressT. Using the type 'airline.hibernate.DeliveryaddressT' directly instead. (java.lang.Cla
ssNotFoundException: airline.hibernate.DeliveryaddressT)
[hbm2java] (hbm2java.ClassMapping               656 ) Could not find UserType: airline.hibernate.Cu
stomerorderT. Using the type 'airline.hibernate.CustomerorderT' directly instead. (java.lang.ClassNo
tFoundException: airline.hibernate.CustomerorderT)

BUILD SUCCESSFUL



Obviously it builds but it doesn't find the UserType. Hmm....got any idea to fix it? I mean i should just need the hbm files and then create the .java files or do I need something more??


From my build.xml:

Code:
<target name="hbm2java" depends="middlegen" description="Generate .java from .hbm files.">
   <taskdef name="hbm2java"
   classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
   classpathref="lib.class.path"/>
   <hbm2java config="build\gen-src\airline\hibernate\hbm2java.cfg.xml" output="${src.dir}">
   <fileset dir="config\sar\mapping">
      <include name="**/*.hbm.xml"/>
   </fileset>
   </hbm2java>
</target>


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 4:39 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
You re right but where do you have generate your XML files?
Maybe it's not the good directory when you use the ant task hbm2java.
Check if the destdir in the middlegen task is the same as the srcdir for XML files


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 4:50 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
A draft from build.xml


...

property name="src.dir" value="${basedir}/src"/>
<property name="java.src.dir" value="${src.dir}/java"/>
<property name="web.src.dir" value="${src.dir}/web"/>

<property name="build.dir" value="${basedir}/build"/>
<property name="build.java.dir" value="${build.dir}/java"/>
<property name="build.gen-src.dir" value="${build.dir}/gen-src"/>
<property name="build.gen-webui.dir" value="${build.dir}/gen-webui"/>
<property name="build.classes.dir" value="${build.dir}/classes"/> <property name="build.ejb-meta.dir" value="${build.dir}/ejb-meta"/>
<property name="build.web-meta.dir" value="${build.dir}/web-meta"/>


.....



<!-- =================================================================== -->
<!-- Compile business logic (ejb) -->
<!-- =================================================================== -->
<target name="compile-ejb" depends="ejbdoclet" description="Compile business logic (ejb)">
<javac
srcdir="${build.gen-src.dir}"
destdir="${build.classes.dir}"
classpathref="lib.class.path"
>
<include name="**/ejb/**/*"/>
<include name="**/interfaces/**/*"/>
</javac>
</target>

<!-- =================================================================== -->
<!-- Compile web -->
<!-- =================================================================== -->
<target name="compile-web" depends="webdoclet" description="Compile web">
<javac
srcdir="${build.gen-src.dir}" destdir="${build.classes.dir}"
classpathref="lib.class.path"
>
<include name="**/web/**/*"/>
<include name="**/sql/**/*"/>
</javac>
</target>

<!-- =================================================================== -->
<!-- Compile business logic (jdo) -->
<!-- =================================================================== -->
<target name="compile-jdo" depends="jdodoclet" description="Compile business logic (jdo)">
<javac
srcdir="${build.gen-src.dir}"
destdir="${build.classes.dir}"
classpathref="lib.class.path"
>
<include name="**/jdo/**/*"/>
</javac>
</target>


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 4:51 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
I can't see any fault. Do you?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 4:53 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
Bold area is when my hbm.xml files can be found.


<target name="hbm2java" depends="middlegen" description="Generate .java from .hbm files.">
<taskdef name="hbm2java"
classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="lib.class.path"/>
<hbm2java config="build\gen-src\airline\hibernate\hbm2java.cfg.xml" output="${src.dir}">
<fileset dir="config\sar\mapping">
<include name="**/*.hbm.xml"/>
</fileset>
</hbm2java>
</target>


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 5:01 am 
Regular
Regular

Joined: Wed Apr 21, 2004 10:57 am
Posts: 62
Location: Hasselt, Belgium
Show the middlegen task, perhaps there is some error in there.

The hibernate part should be something like

Code:
<hibernate
                destination="${build.gen-src.dir}"
                package="${name}.hibernate"
                genXDocletTags="true"
                genIntergratedCompositeKeys="true"
                javaTypeMapper="middlegen.plugins.hibernate.HibernateJavaTypeMapper"
            />


Only the build.gen-src.dir must be replaced with the map you access during hbm2java (config\sar\mapping).


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 5:04 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
Tried your hibernate-tag and it don't work. Here's my build.xml


Code:
<?xml version="1.0"?>

<!--
The DOCTYPE declaration declares the location of product-specific parts of the
Ant build file. You can change the values of these declarations to point to
other available files. This gives you an opportunity to choose what database
and EJB container to use for the Middlegen samples.

Note that this syntax has nothing to do with Ant or Middlegen. This
is the standard way defined by w3c to dynamically include external
files in an XML document. Any decent XML parser will do the include
transparently. Try to open this file in Internet Explorer and see
for yourself.
-->

<!DOCTYPE project [
   <!ENTITY database SYSTEM "file:./config/database/oracle.xml">
    <!ENTITY database SYSTEM "file:./config/database/hsqldb.xml">
     
   
    <!ENTITY ejb      SYSTEM "file:./config/ejb/jboss.xml">
    <!--ENTITY ejb      SYSTEM "file:./config/ejb/weblogic.xml"-->
    <!--ENTITY ejb      SYSTEM "file:./config/ejb/mvcsoft.xml"-->
]>

<project name="Middlegen Airlines" default="all" basedir=".">

   <property file="${basedir}/build.properties"/>
   <property name="name"                           value="airline"/>

   <!-- This was added because we were several people (in a course) deploying to same app server>
   <property environment="env"/>
   <property name="unique.name"                    value="${name}.${env.COMPUTERNAME}"/-->

   <property name="unique.name"                    value="${name}"/>

   <property name="appxml.src.file"                value="${basedir}/src/application.xml"/>
   <property name="lib.dir"                        value="${basedir}/lib"/>

   <property name="src.dir"                        value="${basedir}/src"/>
   <property name="java.src.dir"                   value="${src.dir}/java"/>
   <property name="web.src.dir"                    value="${src.dir}/web"/>

   <property name="build.dir"                      value="${basedir}/build"/>
   <property name="build.java.dir"                 value="${build.dir}/java"/>
   <property name="build.gen-src.dir"              value="${build.dir}/gen-src"/>
   <property name="build.gen-webui.dir"            value="${build.dir}/gen-webui"/>
   <property name="build.classes.dir"              value="${build.dir}/classes"/>
   <property name="build.ejb-meta.dir"             value="${build.dir}/ejb-meta"/>
   <property name="build.web-meta.dir"             value="${build.dir}/web-meta"/>

   <property name="ear.dir"                        value="${build.dir}/ear"/>
   <property name="ear.file"                       value="${ear.dir}/${unique.name}.ear"/>
   <property name="ear.meta.dir"                   value="${build.dir}/ear-meta"/>

   <property name="ejb.dir"                        value="${build.dir}/ejb"/>
   <property name="ejb.jar.file"                   value="${ejb.dir}/${unique.name}-ejb.jar"/>

   <property name="war.dir"                        value="${build.dir}/war"/>
   <property name="war.file"                       value="${war.dir}/${unique.name}-web.war"/>
     
   <property name="build.html.dir"                 value="${build.dir}/html"/>
   <property name="build.jdo.dir"                  value="${build.dir}/jdo"/>
   <property name="build.xmi.dir"                  value="${build.dir}/xmi"/>

   &database;
  &ejb;
   
   <!-- define the datasource.jndi.name in case the imported ejb file doesn't -->
   <property name="datasource.jndi.name"           value="${name}/datasource"/>

   <path id="lib.class.path">
      <pathelement path="${database.driver.classpath}"/>
      <fileset dir="${lib.dir}">
               <include name="*.jar"/>
      </fileset>
      <fileset dir="${lib.dir}">
         <include name="*.jar"/>
      </fileset>
      <!-- The middlegen jars -->
      <fileset dir="${basedir}/..">
         <include name="*.jar"/>
      </fileset>
   </path>

   <target name="init">
      <available property="xdoclet1.2+" classname="xdoclet.modules.ejb.EjbDocletTask" classpathref="lib.class.path"/>
   </target>

   <!-- =================================================================== -->
   <!-- Fails if XDoclet 1.2.x is not on classpath                          -->
   <!-- =================================================================== -->
   <target name="fail-if-no-xdoclet-1.2" unless="xdoclet1.2+">
      <fail>
      You must download several jar files before you can build Middlegen.
      Execute the "download-deps" target. Then try to build again.

      If you are behind a proxy, you should define the properties
      http.proxyHost and http.proxyPort. Example:
     
      ant -Dhttp.proxyHost=foo -Dhttp.proxyPort=bar
     
      It's also possible to download the jars manually.
      </fail>
   </target>

   <target name="download-deps" depends="setproxy">
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-1.2b2.jar" dest="${lib.dir}/xdoclet-1.2b2.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-apache-module-1.2b2.jar" dest="${lib.dir}/xdoclet-apache-module-1.2b2.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-bea-module-1.2b2.jar" dest="${lib.dir}/xdoclet-bea-module-1.2b2.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-ejb-module-1.2b2.jar" dest="${lib.dir}/xdoclet-ejb-module-1.2b2.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-hibernate-module-1.2b2.jar" dest="${lib.dir}/xdoclet-hibernate-module-1.2b2.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-jboss-module-1.2b2.jar" dest="${lib.dir}/xdoclet-jboss-module-1.2b2.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-jdo-module-1.2b2.jar" dest="${lib.dir}/xdoclet-jdo-module-1.2b2.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-jmx-module-1.2b2.jar" dest="${lib.dir}/xdoclet-jmx-module-1.2b2.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-libelis-module-1.2b2.jar" dest="${lib.dir}/xdoclet-libelis-module-1.2b2.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-mvcsoft-module-1.2b2.jar" dest="${lib.dir}/xdoclet-mvcsoft-module-1.2b2.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-solarmetric-module-1.2b2.jar" dest="${lib.dir}/xdoclet-solarmetric-module-1.2b2.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-tjdo-module-1.2b2.jar" dest="${lib.dir}/xdoclet-tjdo-module-1.2b2.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-web-module-1.2b2.jar" dest="${lib.dir}/xdoclet-web-module-1.2b2.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-xdoclet-module-1.2b2.jar" dest="${lib.dir}/xdoclet-xdoclet-module-1.2b2.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-xjavadoc-1.2b2.jar" dest="${lib.dir}/xdoclet-xjavadoc-1.2b2.jar"/>

      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/commons-collections/jars/commons-collections-2.1.jar" dest="${lib.dir}/commons-collections-2.1.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/commons-logging/jars/commons-logging-1.1-dev.jar" dest="${lib.dir}/commons-logging-1.1-dev.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/ejb/jars/ejb-2.0.jar" dest="${lib.dir}/ejb-2.0.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/hsqldb/jars/hsqldb-1.7.1.jar" dest="${lib.dir}/hsqldb-1.7.1.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/jdbc/jars/jdbc-2.0.jar" dest="${lib.dir}/jdbc-2.0.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/jdo/jars/jdo-1.0.jar" dest="${lib.dir}/jdo-1.0.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/log4j/jars/log4j-1.2.7.jar" dest="${lib.dir}/log4j-1.2.7.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/servletapi/jars/servletapi-2.3.jar" dest="${lib.dir}/servletapi-2.3.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/struts/jars/struts-1.0.2.jar" dest="${lib.dir}/struts-1.0.2.jar"/>
      <get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/velocity/jars/velocity-1.4-dev.jar" dest="${lib.dir}/velocity-1.4-dev.jar"/>
     
   </target>

   <target name="setproxy" if="http.proxyHost">
      <setproxy proxyHost="http.proxyHost" proxyPort="http.proxyPort"/>
   </target>


   <!-- =================================================================== -->
   <!-- Create tables                                                     -->
   <!-- =================================================================== -->
   <target
      name="create-tables"
      depends="init,fail-if-no-xdoclet-1.2,check-driver-present,panic-if-driver-not-present"
      description="Create tables"
   >
      <echo>Creating tables using URL ${database.url}</echo>
      <sql
         classpath="${database.driver.classpath}"
         driver="${database.driver}"
         url="${database.url}"
         userid="${database.userid}"
         password="${database.password}"
         src="${database.script.file}"
         print="true"
         output="result.txt"
      />
   </target>
   <target name="check-driver-present">
      <available file="${database.driver.file}" type="file" property="driver.present"/>
   </target>
   <target name="panic-if-driver-not-present" unless="driver.present">
      <fail>
      The JDBC driver you have specified by including one of the files in ${basedir}/config/database
      doesn't exist. You have to download this driver separately and put it in ${database.driver.file}
      Please make sure you're using a version that is equal or superior to the one we looked for.
      If you name the driver jar file differently, please update the database.driver.file property
      in the ${basedir}/config/database/xxx.xml file accordingly.
      </fail>
   </target>

   <!-- =================================================================== -->
   <!-- Run Middlegen                                                       -->
   <!-- =================================================================== -->

<target
name="middlegen"
description="Run Middlegen"
unless="middlegen.skip"
depends="init,fail-if-no-xdoclet-1.2,check-driver-present,panic-if-driver-not-present"
>
<mkdir dir="${build.gen-src.dir}"/>

<taskdef
name="middlegen"
classname="middlegen.MiddlegenTask"
classpathref="lib.class.path"
/>

<middlegen
appname="${name}"
prefsdir="${src.dir}"
gui="${gui}"
databaseurl="${database.url}"
initialContextFactory="${java.naming.factory.initial}"
providerURL="${java.naming.provider.url}"
datasourceJNDIName="${datasource.jndi.name}"
driver="${database.driver}"
username="${database.userid}"
password="${database.password}"
schema="${database.schema}"
catalog="${database.catalog}"
>

<table generate="true" name="ARTICLECOUNTRY_T" pktable="ARTICLECOUNTRY_T"/>
    <table generate="true" name="ARTICLELANGUAGE_T" pktable="ARTICLELANGUAGE_T"/>
    <table generate="true" name="COUNTRY_T" pktable="COUNTRY_T"/>
    <table generate="true" name="CUSTOMERORDERLINE_T" pktable="CUSTOMERORDERLINE_T"/>
    <table generate="true" name="CUSTOMERORDER_T" pktable="CUSTOMERORDER_T"/>
    <table generate="true" name="CUSTOMER_T" pktable="CUSTOMER_T"/>
    <table generate="true" name="DELIVERYADDRESS_T" pktable="DELIVERYADDRESS_T"/>
    <table generate="true" name="STORE_T" pktable="STORE_T"/>
    <table generate="true" name="STORESTOCK_T" pktable="STORESTOCK_T"/>





<!--
<table name="PERSON" pktable="id" singular="person" plural="persons" />
<table name="ADDRESS" pktable="id" singular="address" plural="addresses" />

-->


<hibernate
destination="${build.gen-src.dir}"
package="${name}.hibernate" javaTypeMapper="middlegen.plugins.hibernate.HibernateJavaTypeMapper"
/>



</middlegen>

<mkdir dir="${build.classes.dir}"/>
</target>

<target name="hbm2java" depends="middlegen" description="Generate .java from .hbm files.">
   <taskdef name="hbm2java"
   classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
   classpathref="lib.class.path"/>
   <hbm2java config="build\gen-src\airline\hibernate\hbm2java.cfg.xml" output="${src.dir}">
   <fileset dir="config\sar\mapping">
      <include name="**/*.hbm.xml"/>
   </fileset>
   </hbm2java>
</target>


   <!-- =================================================================== -->
   <!-- Run Ejbdoclet on Middlegen-generated sources                        -->
   <!-- =================================================================== -->
   <target
      name="ejbdoclet"
      depends="middlegen"
   >
      <mkdir dir="${build.ejb-meta.dir}"/>

      <taskdef
         name="ejbdoclet"
         classname="xdoclet.modules.ejb.EjbDocletTask"
         classpathref="lib.class.path"
      />

      <!-- first run xdoclet to generate facade objects only -->
      <ejbdoclet
         destdir="${build.gen-src.dir}"
         excludedtags="@version,@author"
         ejbspec="2.0"
      >
         <fileset dir="${build.gen-src.dir}">
            <include name="**/ejb/**/*Bean.java" />
            <exclude name="**/ejb/**/SeqBlockBean.java" />
            <exclude name="**/ejb/**/SequenceBean.java" />
         </fileset>
         
         <packageSubstitution packages="ejb" substituteWith="interfaces"/>
         
         <entityfacade>
         </entityfacade>
      </ejbdoclet>

      <ejbdoclet
         destdir="${build.gen-src.dir}"
         excludedtags="@version,@author"
         ejbspec="2.0"
      >
         <packageSubstitution packages="ejb" substituteWith="interfaces"/>

         <fileset dir="${build.gen-src.dir}">
            <include name="**/ejb/**/*Bean.java" />
            <include name="**/ejb/**/*FacadeEJB.java" />
         </fileset>

         <utilobject kind="physical" includeGUID="true"/>
         <localinterface/>
         <localhomeinterface/>
         <!--dataobject/-->
         <valueobject/>
         <remoteinterface/>
         <homeinterface/>
         <session/>
         <entitypk/>
         <entitycmp/>
         <deploymentdescriptor
            xmlencoding="ISO-8859-1"
            destdir="${build.ejb-meta.dir}/META-INF"
            validatexml="true"
         />
         <weblogic
            version="6.1"
            xmlencoding="ISO-8859-1"
            destdir="${build.ejb-meta.dir}/META-INF"
            validatexml="true"
            datasource="${datasource.jndi.name}"
            createtables="true"
         />
         
         <jboss
            version="3.0"
            xmlencoding="ISO-8859-1"
            destdir="${build.ejb-meta.dir}/META-INF"
            validatexml="true"
            datasource="${datasource.jndi.name}"
            datasourcemapping="${jboss.datasource.mapping}"
         />

         <mvcsoft
            xmlencoding="ISO-8859-1"
            destdir="${build.ejb-meta.dir}/META-INF"
            validatexml="true"
         />
      </ejbdoclet>
   </target>
     
   <!-- =================================================================== -->
   <!-- Run Webdoclet on Middlegen-generated sources                        -->
   <!-- =================================================================== -->
   <target
      name="webdoclet"
      depends="postprocess-ejb-jar"
   >
      <mkdir dir="${build.web-meta.dir}"/>
     
      <taskdef
         name="webdoclet"
         classname="xdoclet.modules.web.WebDocletTask"
         classpathref="lib.class.path"
      />
     
      <webdoclet
         destdir="${build.web-meta.dir}/WEB-INF"
         excludedtags="@version,@author"
      >
         <fileset dir="${build.gen-src.dir}">
            <include name="**/web/**/*.java" />
         </fileset>

         <deploymentdescriptor
            servletspec="2.3"
            validatexml="true"
            mergedir="${basedir}/src/xdoclet"
         />
         <weblogicwebxml
            description="Web application for ${ant.project.name}"
         />
         <strutsconfigxml
            destdir="${build.web-meta.dir}/WEB-INF"
         >
            <configParam name="version" value="1.0"/>
         </strutsconfigxml>
         <!--webworkconfigproperties destdir="${build.ejb.classes.dir}"/-->
      </webdoclet>
   </target>

   <!-- =================================================================== -->
   <!-- Run Jdodoclet on Middlegen-generated sources                        -->
   <!-- =================================================================== -->
   <target
      name="jdodoclet"
      depends="middlegen"
   >
      <mkdir dir="${build.jdo.dir}/META-INF"/>
     
      <taskdef
         name="jdodoclet"
         classname="xdoclet.modules.jdo.JdoDocletTask"
         classpathref="lib.class.path"
      />
     
      <jdodoclet
         destdir="${build.classes.dir}"
         excludedtags="@version,@author"
      >
         <fileset dir="${build.gen-src.dir}">
            <include name="**/jdo/**/*.java" />
         </fileset>

         <jdometadata jdospec="1.0" generation="class"/>
         <lido version="1.3"/>
         <kodo version="2.3"/>
      </jdodoclet>
   </target>

   <!-- =================================================================== -->
   <!-- Make ear file                                                       -->
   <!-- =================================================================== -->
   <target
      name="ear"
      depends="war"
      description="Make ear file"
   >
      <mkdir dir="${ear.meta.dir}/META-INF"/>
      <copy todir="${ear.meta.dir}/META-INF" file="${appxml.src.file}">
         <filterset>
            <filter token="name" value="${unique.name}" />
            <filter token="appname" value="${ant.project.name}" />
         </filterset>
      </copy>

      <mkdir dir="${ear.dir}"/>
      <ear
         earfile="${ear.file}"
         appxml="${ear.meta.dir}/META-INF/application.xml"
      >
         <fileset dir="${ejb.dir}"/>
         <fileset dir="${war.dir}"/>
         <fileset dir="${lib.dir}">
            <include name="log4j*.jar"/>
         </fileset>
      </ear>
   </target>

   <!-- =================================================================== -->
   <!-- Make war file                                                       -->
   <!-- =================================================================== -->
   <target name="war" depends="compile-web" description="Make ejb jar file">
      <mkdir dir="${war.dir}"/>
      <war
         warfile="${war.file}"
         webxml="${build.web-meta.dir}/WEB-INF/web.xml"
      >
         <classes dir="${build.classes.dir}">
            <include name="**/web/**/*"/>
         </classes>
         <lib dir="${lib.dir}">
            <include name="struts*.jar"/>
         </lib>
         <fileset dir="${build.web-meta.dir}">
            <include name="WEB-INF/**/*"/>
            <exclude name="WEB-INF/web.xml"/>
         </fileset>
         <fileset dir="${build.gen-webui.dir}">
            <include name="**/*"/>
         </fileset>
         <fileset dir="${web.src.dir}">
            <include name="**/*"/>
         </fileset>
      </war>
   </target>

   <!-- =================================================================== -->
   <!-- Make ejb jar file                                                   -->
   <!-- =================================================================== -->
   <target name="ejb-jar" depends="compile-ejb" description="Make ejb jar file">
      <mkdir dir="${ejb.dir}"/>
      <jar
         jarfile="${ejb.jar.file}"
      >
         <fileset dir="${build.classes.dir}">
            <include name="**/ejb/**/*"/>
            <include name="**/interfaces/**/*"/>
         </fileset>
         <fileset dir="${build.ejb-meta.dir}"/>
      </jar>
   </target>

   <!-- =================================================================== -->
   <!-- Compile business logic (ejb)                                        -->
   <!-- =================================================================== -->
   <target name="compile-ejb" depends="ejbdoclet" description="Compile business logic (ejb)">
      <javac
         srcdir="${build.gen-src.dir}"
         destdir="${build.classes.dir}"
         classpathref="lib.class.path"
      >
         <include name="**/ejb/**/*"/>
         <include name="**/interfaces/**/*"/>
      </javac>
   </target>
   
   <!-- =================================================================== -->
   <!-- Compile web                                                         -->
   <!-- =================================================================== -->
   <target name="compile-web" depends="webdoclet" description="Compile web">
      <javac
         srcdir="${build.gen-src.dir}"
         destdir="${build.classes.dir}"
         classpathref="lib.class.path"
      >
         <include name="**/web/**/*"/>
         <include name="**/sql/**/*"/>
      </javac>
   </target>
   
   <!-- =================================================================== -->
   <!-- Compile business logic (jdo)                                        -->
   <!-- =================================================================== -->
   <target name="compile-jdo" depends="jdodoclet" description="Compile business logic (jdo)">
      <javac
         srcdir="${build.gen-src.dir}"
         destdir="${build.classes.dir}"
         classpathref="lib.class.path"
      >
         <include name="**/jdo/**/*"/>
      </javac>
   </target>
   
   <!-- =================================================================== -->
   <!-- Build everything                                                    -->
   <!-- =================================================================== -->
   <target name="all" description="Build everything" depends="ear,compile-jdo"/>

   <!-- =================================================================== -->
   <!-- Clean everything                                                    -->
   <!-- =================================================================== -->
   <target name="clean" description="Clean all generated stuff">
      <delete dir="${build.dir}"/>
   </target>

   <!-- =================================================================== -->
   <!-- Brings up the hsqldb admin tool                                     -->
   <!-- =================================================================== -->
   <target name="hsqldb-gui" description="Brings up the hsqldb admin tool">
      <property name="database.urlparams" value="?user=${database.userid}&amp;password=${database.password}"/>
      <java
         classname="org.hsqldb.util.DatabaseManager"
         fork="yes"
         classpath="${lib.dir}/hsqldb-1.7.1.jar;${database.driver.classpath}"
         failonerror="true"
      >
         <arg value="-url"/>
         <arg value="${database.url}${database.urlparams}"/>
         <arg value="-driver"/>
         <arg value="${database.driver}"/>
      </java>
   </target>

   <!-- =================================================================== -->
   <!-- generate a Clover html report                                       -->
   <!-- =================================================================== -->
   <target name="clover">
      <property name="cp" refid="lib.class.path"/>
      <property name="cp2" value="${cp};${ant.home}/lib/clover.jar"/>
      <java
         classname="com.cortexeb.tools.clover.reporters.html.HtmlReporter"
         fork="no"
         classpath="${cp2}"
      >
         <arg line="-o ${build.dir}/clover -i C:/temp/clover/demo_coverage.db -t 'Middlegen coverage'"/>
      </java>
   </target>

   <!-- =================================================================== -->
   <!-- Deploys ear file                                                    -->
   <!-- =================================================================== -->
   <target name="deploy-ear" depends="ear" description="Deploys ear file">
      <copy file="${ear.file}" todir="${deploy.dir}"/>
   </target>

   <!-- =================================================================== -->
   <!-- Run hbm2java                                                        -->
   <!-- =================================================================== -->
   <target name="hbm2java" depends="middlegen" description="Generate .java from .hbm files.">
      <taskdef
         name="hbm2java"
         classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
         classpathref="lib.class.path"
      />
      
      <hbm2java output="${build.gen-src.dir}">
         <fileset dir="${build.gen-src.dir}">
            <include name="**/*.hbm.xml"/>
         </fileset>
      </hbm2java>
   </target>
</project>


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 5:08 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
Since ClassNotFoundException is thrown seems like middlegen is missing .class files for my hbm.xml files. Although with the airline example from the beginning perhaps those files already existed.

But, form what I can understand middlegen should create the .class files and .java files from the basis of the hbm.xml files..


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 5:09 am 
Regular
Regular

Joined: Wed Apr 21, 2004 10:57 am
Posts: 62
Location: Hasselt, Belgium
Why do you place your hibernate mapping in
<hibernate
destination="${build.gen-src.dir}"
package="${name}.hibernate"
javaTypeMapper="middlegen.plugins.hibernate.HibernateJavaTypeMapper"/>

And later in hbm2java you use this?
<fileset dir="config\sar\mapping">

Shouldn't it be this?
<fileset dir="${build.gen-src.dir}">


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 5:11 am 
Regular
Regular

Joined: Wed Apr 21, 2004 10:57 am
Posts: 62
Location: Hasselt, Belgium
You're right about the generation of java and class files. You only need your mapping file and hbm2java should create everything.

Would be rather stupid if it needed your class files too.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 5:18 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
You're right, I've fixed it now, but it didn't made my fault go away. I don't get why the build is successful but middlegen in the building process generate faults.

In my xml files it uses this link to the classes (airline.hibernate.*).

hbm2java:
[hbm2java] Processing 12 files.
[hbm2java] Building hibernate objects
[hbm2java] (hbm2java.ClassMapping 656 ) Could not find UserType: airline.hibernate.De
liveryaddressT. Using the type ['airline.hibernate.DeliveryaddressT' directly instead.
(java.lang.Cla
ssNotFoundException: airline.hibernate.DeliveryaddressT)
[hbm2java] (hbm2java.ClassMapping 656 ) Could not find UserType: airline.hibernate.Cu
stomerorderT. Using the type 'airline.hibernate.CustomerorderT'
directly instead. (java.lang.ClassNo
tFoundException: airline.hibernate.CustomerorderT)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 22 posts ]  Go to page 1, 2  Next

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.