-->
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: deploying a hibernate project
PostPosted: Sun Dec 11, 2005 7:51 am 
Newbie

Joined: Sun Dec 11, 2005 7:30 am
Posts: 1
hi , I new in hibernate and ant.I jared my project using ant and I put all the external jars in the same directory with my jar file.when ı executed the jar ı got staleobjectexceptions message.my build.xml file is;

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project [<!ENTITY buildfile SYSTEM "file:./build-user.xml">]>
<!-- WARNING: Eclipse autogenerated file.
Any modifications will be overwritten.
Please edit build-user.xml instead.
-->
<project name="ayniyat" default="all" basedir=".">

<!-- Project-wide settings. All directories are relative to the -->
<!-- project directories -->
<property name="src.dir" value="src"/>
<property name="dist.dir" value="dist"/>
<property name="lib.dir" value="lib"/>
<property name="bin.dir" value="bin"/>

<!-- Build directories -->
<property name="build.dir" value="build"/>
<property name="build.classes" value="${build.dir}/classes"/>
<property name="build.lib" value="${build.dir}/lib"/>

<!-- Global property for <javac> -->
<property name="build.compiler" value="modern"/>
<path id="classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="prepare">
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.lib}"/>
</target>
<!-- Build the IRC bot application -->

<target name="bot" depends="prepare">
<mkdir dir="${build.classes}"/>
<javac destdir="${build.classes}"
debug="${debug.flag}"
deprecation="on">
<!-- We could have used javac's srcdir attribute -->
<src path="${src.dir}"/>
<exclude name="ayniyat/test/**"/>
<classpath refid="classpath"/>
</javac>
<jar jarfile="${build.lib}/ayniyat.jar"
basedir="${build.classes}" >
<manifest>
<attribute name="Main-Class" value="com.iztek.ayniyat.login.gui.LoginGui" />
</manifest>

<exclude name="ayniyat/test/**"/>
</jar>
</target>


<!-- Deploy the application in a "ready-to-run" state -->
<target name="deploy" depends="bot">

<!-- Create the distribution directory -->
<mkdir dir="${dist.dir}"/>
<mkdir dir="${dist.dir}/bin"/>
<mkdir dir="${dist.dir}/lib"/>

<!-- Copy the primary program and modules -->
<copy todir="${dist.dir}/lib">
<fileset dir="${build.classes}"/>
<fileset dir="${build.lib}" includes="ayniyat.jar"/>
<fileset dir="${lib.dir}" includes="*.jar"/>
</copy>

</target>

<!-- Delete class files built during previous builds. Leave
directories -->
<target name="clean" depends="deploy">
<delete>
<fileset dir="${build.classes}" includes="**/*.class"/>
</delete>
</target>

<!-- Delete any created directories and their contents -->
<target name="all" depends="clean">
<delete dir="${build.dir}"/>

</target>
</project>

how can i put my hibernate.cfg.xml and other hbm.xml files in to jared file


Top
 Profile  
 
 Post subject: I had to use zipfilesets
PostPosted: Mon Dec 12, 2005 4:17 pm 
Newbie

Joined: Mon Aug 15, 2005 3:57 pm
Posts: 13
I used zipfilesets to include the hibernate jar and associated jars in my application jar. Here's my build.xml that I run from within eclipse:

<?xml version="1.0" encoding="utf-8"?>

<project name="mainapp" default="Build" basedir=".">
<property name="srcDir" location="${basedir}" />
<property name="binDir" location="${basedir}/../../bin/" />
<property name="libDir" location="${basedir}/mainapp/lib" />
<property name="dataDir" location="${basedir}/mainapp/data" />
<property name="jarDir" location="${binDir}" />
<property name="classDir" location="${basedir}/mainapp/classes" />
<property name="jarFile" location="${jarDir}/mainapp.jar" />

<!-- Set up the class path for compilation and execution -->
<path id="project.class.path">
<!-- Include our own classes, of course -->
<pathelement location="${classDir}" />
<!-- Include jars in the project library directory -->
<fileset dir="${libDir}">
<include name="**/*.jar" />
</fileset>
</path>

<target name="Initialization">
<echo message="Deleting class directory"/>
<delete dir="${classDir}" quiet="true"/>
<echo message="Creating class directory"/>
<mkdir dir="${classDir}"/>

<echo message="basedir ${basedir}" />
<echo message="src ${srcDir}" />
<echo message="bin ${binDir}" />
<echo message="lib ${libDir}" />
<echo message="data ${dataDir}" />
<echo message="class ${classDir}" />
<echo message="jar ${jarDir}" />
<echo message="Deleting class files." />

<!-- Copy our property files and O/R mappings for use at runtime -->
<copy todir="${classDir}">
<fileset dir="${srcDir}">
<include name="**/*.properties" />
<include name="**/*.hbm.xml" />
<include name="**/*.xml" />
</fileset>
</copy>
<copy todir="${classDir}">
<fileset dir="${srcDir}">
<include name="**/*.gif" />
</fileset>
<fileset dir="${srcDir}">
<include name="**/*.gif" />
</fileset>
</copy>
</target>

<target name="Compilation" depends="Initialization">
<echo message="Compiling Java source" />
<javac srcdir="${srcDir}" destdir="${classDir}" debug="on" optimize="off" deprecation="on">
<classpath refid="project.class.path" />
</javac>
</target>

<target name="Jar" depends="Initialization, Compilation">
<echo message="Creating mainapp.jar" />
<jar destfile="${jarFile}" basedir="${classDir}">
<zipfileset dir="${classDir}" prefix="" />
<zipfileset src="${libDir}/antlr-2.7.5H3.jar"/>
<zipfileset src="${libDir}/asm-attrs.jar"/>
<zipfileset src="${libDir}/asm.jar"/>
<zipfileset src="${libDir}/cglib-2.1.jar"/>
<zipfileset src="${libDir}/commons-collections-2.1.1.jar"/>
<zipfileset src="${libDir}/commons-logging-1.0.4.jar"/>
<zipfileset src="${libDir}/dom4j-1.6.jar"/>
<zipfileset src="${libDir}/ehcache-1.1.jar"/>
<zipfileset src="${libDir}/hibernate3.jar"/>
<zipfileset src="${libDir}/jdbc2_0-stdext.jar"/>
<zipfileset src="${libDir}/jta.jar"/>
<zipfileset src="${libDir}/log4j-1.2.9.jar"/>
<zipfileset src="${libDir}/mysql-connector-java-3.1.10-bin.jar"/>
<zipfileset src="${libDir}/xml-apis.jar"/>
<include name="**/*.class" />
<include name="**/*.gif" />
<manifest>
<attribute name="Main-Class" value="mainapp.main" />
</manifest>
</jar>
</target>

<target name="Build" depends="Initialization, Compilation, Jar">
<echo message="Building main." />
</target>

<target name="test" description="Run the test driver"
depends="Initialization, Compilation">
<java classname="mainapp.TestDriver" fork="true">
<classpath refid="project.class.path"/>
</java>
</target>
</project>

_________________
Don't forget to rate!


Top
 Profile  
 
 Post subject: Re: deploying a hibernate project
PostPosted: Mon Dec 12, 2005 4:21 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
<target name="bot" depends="prepare">
<mkdir dir="${build.classes}"/>
<javac destdir="${build.classes}"
debug="${debug.flag}"
deprecation="on">
<!-- We could have used javac's srcdir attribute -->
<src path="${src.dir}"/>
<exclude name="ayniyat/test/**"/>
<classpath refid="classpath"/>
</javac>

<copy todir="${dir.classes}">
<fileset dir="${src.dir}" includes="**/*.hbm,**/*.xml"/>
</copy>

<jar jarfile="${build.lib}/ayniyat.jar"
basedir="${build.classes}" >
<manifest>
<attribute name="Main-Class" value="com.iztek.ayniyat.login.gui.LoginGui" />
</manifest>

<exclude name="ayniyat/test/**"/>
</jar>
</target>

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


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.