EnversHibernateToolTask in NetBean build file issue - netbeans

I'm trying to incorporate hibernate schema generator for Envers.
I've add this target:
<target name="schemaexport"
description="Exports a generated schema to DB and file">
<path id="hibernate.classpath">
<pathelement path="./lib/hibernate-persistence/*.jar" />
</path>
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.EnversHibernateToolTask"
classpathref="hibernate.classpath"/>
<hibernatetool destdir=".">
<classpath>
<fileset refid="lib.hibernate" />
<path location="${build.demo.dir}" />
<path location="${build.main.dir}" />
</classpath>
<jpaconfiguration persistenceunit="AuroraServicePU" />
<hbm2ddl
drop="false"
create="true"
export="false"
outputfilename="versioning-ddl.sql"
delimiter=";"
format="true"/>
</hibernatetool>
</target>
The problem is that I get the error
taskdef class org.hibernate.tool.ant.EnversHibernateToolTask cannot be found
using the classloader AntClassLoader[myproject\lib\hibernate-persistence*.jar]
Help will be great.
Thank you,
Ido.

I suspect your path is incorrect. I don't believe you can use wildcards in a pathelement.
Try changing your path to be:
<path id="hibernate.classpath">
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
</path>
If that fails, run ant with the -v tag and check the debug for more hints.

Related

Deployment with e(fx)clipse - Build Error

I am trying to deploy a stand-alone build of my JavaFx application and have followed the tutorial from Code.Makery.
I am getting this error:
init-fx-tasks:
[taskdef] Could not load definitions from resource com/sun/javafx/tools/ant/antlib.xml. It could not be found.
do-deploy:
[copy] Copying 1 file to C:_source\MasterGuildWarsCode\build\dist\libs
BUILD FAILED C:_source\MasterGuildWarsCode\build\build.xml:91:
C:_source\MasterGuildWarsCode\resources does not exist.
Total time: 2 seconds
This is the section of my build.xml file that seems to be the problem:
<mkdir dir="dist/resources" />
<copy todir="dist/resources" >
<fileset dir="../resources" />
</copy>
<mkdir dir="package" />
<!-- Icons only for Windows -->
<mkdir dir="package/windows" />
<copy todir="package/windows">
<fileset dir="..">
<include name="AXI.ico" />
<include name="AXI.bmp" />
</fileset>
</copy>
<!-- Icons only for MacOS -->
<mkdir dir="package/macosx" />
<copy todir="package/macosx">
<fileset dir="..">
<include name="AXI.icns" />
</fileset>
</copy>
<fx:resources id="appRes">
<fx:fileset dir="dist" includes="MasterGuildWarsCode.jar"/>
<fx:fileset dir="dist" includes="libs/*"/>
<fx:fileset dir="dist" includes="resources/**"/>
</fx:resources>
Any help is greatly appreciated!
You may want to try this tutorial instead: Efxclipse/Tutorials/AddingE(fx)clipse to eclipse. I've tested it and works perfectly.
Make sure you follow all the steps. Specially this one: "Configure eclipse to use a JDK not a JRE". This will guarantee that you won't have any trouble when you ant build and run your app.
Looking at that tutorial (Step 4), there is a section like this in the build.xml:
<path id="fxant">
<filelist>
<file name="${java.home}\..\lib\ant-javafx.jar"/>
<file name="${java.home}\lib\jfxrt.jar"/>
<file name="${basedir}"/>
</filelist>
</path>
Do those jars exist at the specified paths in the JDK that Ant executes with?
A very similar question was asked here: JAVAFx Build Failed, with suggestion to change from
<file name="${java.home}\lib\jfxrt.jar"/>
to
<file name="${java.home}\lib\ext\jfxrt.jar"/>
I don't know whether that is correct or not, but I do suggest checking those paths.

How to compile GWT project to jar file and add it to another GWT project?

I have Three GWT projects. 2 common GWT(Bootstrap & Data Transfer Objects) projects, it doesnt contain any UI part. So, I want to compile these two projects and create jar and want to include it in third GWT project. I have done in Eclipse[Project->Export->Jar file]. It works fine. I want do it command line or through ant build.xml. Please if you know anyone, can you help on this.
We have a similar case and here is the target we use for building an external jar for our task engine. This will build you a jar from command line that can be included in other projects. In our case we have a large project that contains all of our domain objects and some services. We wanted to include this into our task engine.
<target name="taskengine-jar" depends="enhance">
<mkdir dir="build" />
<mkdir dir="build/META-INF"/>
<copy todir="build/META-INF">
<fileset dir="src/META-INF">
<include name="persistence.xml" />
<include name="server.properties" />
<include name="crypto.properties" />
<include name="sqlDrivers.xml" />
</fileset>
</copy>
<jar destfile="taskengine-jobs.jar">
<fileset dir="war/WEB-INF/classes">
<include name="com/hp/vf/server/**" />
<include name="com/hp/vf/shared/**" />
</fileset>
<fileset dir="build">
<include name="META-INF/**" />
</fileset>
<zipgroupfileset dir="war/WEB-INF/lib">
<include name="axis2.jar" />
<include name="javamail-1.4.4.jar" />
<include name="commons-pool-1.6.jar" />
<include name="openjpa-all-2.2.0.jar" />
<include name="commons-logging-adapters-1.1.1.jar" />
<include name="commons-logging-api-1.1.1.jar" />
<include name="commons-vfs2-2.0.jar" />
<include name="postgresql-9.0-801.jdbc4.jar" />
<include name="poi-3.8-beta5-20111217.jar"/>
<include name="poi-ooxml-schemas-3.8-beta5-20111217.jar"/>
<include name="poi-ooxml-3.8-beta5-20111217.jar"/>
<include name="itext-2.1.7.jar"/>
<include name="REngine.jar" />
<include name="Rserve.jar" />
<include name="jsoup-1.6.1.jar" />
<include name="jfreechart-1.0.13.jar" />
<include name="jcommon-1.0.16.jar" />
</zipgroupfileset>
<fileset dir="war/WEB-INF/lib">
<include name="addressing-1.1.1.mar" />
<include name="rampart-1.1.mar" />
</fileset>
</jar>
<delete dir="build" />
</target>
I think, the most easy and flexible way is to use Maven. Each project represents the separate Maven artefact which is stored in your local repository. And only one thing you should do in your main project is to add couple of dependencies to your POM file. That's it. I use this schema for a long time.

Getting gwt hibernate example code to work with eclipse

I am starting out with GWT and hibernate. I'm going through the tutorial at https://developers.google.com/web-toolkit/articles/using_gwt_with_hibernate.
I downloaded the sample code provided with the tutorial (http://google-web-toolkit.googlecode.com/files/gwt_hibernate_base.zip). This is a simple music store where you can add an account and records. I am able to run this and successfully add accounts and records to the database by doing the following commands:
(in the data directory) java -cp ../lib/hsqldb.jar org.hsqldb.Server
ant build hosted
Here is the build.xml file used to build this:
<?xml version="1.0" encoding="utf-8" ?>
<project name="Guestbook" default="build" basedir=".">
<!-- Define gwt.home, gwt.dev.jar, appengine.sdk.home -->
<property file="build.properties"/>
<path id="project.class.path">
<pathelement location="war/WEB-INF/classes"/>
<pathelement location="${gwt.home}/gwt-user.jar"/>
<!-- Add any additional non-server libs (such as JUnit) -->
<fileset dir="war/WEB-INF/lib">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="libs" description="Copy libs to WEB-INF/lib">
<mkdir dir="war/WEB-INF/lib" />
<copy todir="war/WEB-INF/lib" file="${gwt.home}/gwt-servlet.jar" />
<!-- Add any additional server libs that need to be copied -->
<copy todir="war/WEB-INF/lib" flatten="true">
<fileset dir="lib/">
<include name="**/*.jar"/>
</fileset>
</copy>
</target>
<target name="javac" depends="libs" description="Compile java source">
<mkdir dir="war/WEB-INF/classes"/>
<javac srcdir="src" includes="**" encoding="utf-8"
destdir="war/WEB-INF/classes"
source="1.5" target="1.5" nowarn="true"
debug="true" debuglevel="lines,vars,source">
<classpath refid="project.class.path"/>
</javac>
</target>
<!-- can add additional arguments like -logLevel INFO or -style PRETTY -->
<target name="gwtc" depends="javac" description="GWT compile to JavaScript">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
<pathelement location="${gwt.home}/${gwt.dev.jar}"/>
</classpath>
<!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
<jvmarg value="-Xmx256M"/>
<arg value="com.google.musicstore.MusicStore"/>
</java>
</target>
<target name="hosted" depends="javac" description="Run hosted mode">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.DevMode">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
<pathelement location="${gwt.home}/${gwt.dev.jar}"/>
</classpath>
<jvmarg value="-Xmx256M"/>
<arg value="-startupUrl"/>
<arg value="MusicStore.html"/>
<arg value="com.google.musicstore.MusicStore"/>
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
</java>
</target>
<target name="build" depends="gwtc" description="Build this project" />
<target name="clean" description="Cleans this project">
<delete dir="war/WEB-INF/classes" failonerror="false" />
<delete dir="war/musicstore" failonerror="false" />
</target>
Now I would like to get this simple example working in eclipse. I created a project called MusicStore using the gwt eclipse plugin. I then copied over the tutorial files without changing them. I can't post an image but here is a link to my eclipse project structure:
http://oi50.tinypic.com/t6rn2w.jpg
Again, I start by running
(in the data directory) java -cp ../lib/hsqldb.jar org.hsqldb.Server
Then I try to run my project in eclipse but hibernate doesn't work. When I try to add an account in the UI it alerts "Failed to save account" and I get the error java.lang.NoClassDefFoundError: org/hibernate/Session.
Please let me know how I should go about getting the sample code working with eclipse. I think that many users new to hibernate will also want to do this.
Thanks!
Basically eclipse cannot find your hibernate libraries. That is because your build.xml is for building a war file. Eclipse doesn't read it so it doesn't have any of your build information in there.
A quick solution to this is to just go to the "Build Path" properties in Eclipse and make sure your /lib directory is included in the "Libraries" tab. Then eclipse will know where you are keeping your libraries.
A better solution would be to use something like Maven. Then the Maven Plugin for Eclipse will automatically look at the Maven build file and configure the Eclipse project so that it can detect where the libraries are held etc...

ant eclipse: package org.apache.log4j does not exist

I'm a java-greenhorn trying to compile my project via ant, but nothing's working.
So, in my class I'm using log4j.jar and import junit. Everything's in Eclipse, either Ant.
Here is the build.xml file:
<path id="master-classpath">
<pathelement path="D:\.a lot of folders..\junit.jar"/>
<!--<pathelement path="D:\...\log4j-1.2.17.jar"/> -->
<fileset dir="D:\apache-log4j-1.2.17">
<include name="log4j-1.2.17.jar"/>
</fileset>
<pathelement path="${buildSrc}"/>
</path>
And compile block:
<target name="compile" depends="init">
<javac includeantruntime="false" srcdir="${src1}" destdir="${buildSrc}"/>
<javac includeantruntime="false" srcdir="${src2}" destdir="${buildSrc}"/>
<javac includeantruntime="false" srcdir="${test}" destdir="${buildTest}">
<classpath refid="master-classpath"/>
</javac>
<javac includeantruntime="false" srcdir="src" destdir="build/classes" classpath="${buildSrc}"/>
</target>
I've also tried some different approaches, like making the same in the javac-task, using property, etc, to no success. Could you please, identify my mistake and help deal with it?
Thanks in advance.
<javac includeantruntime="false" srcdir="${test}" destdir="${buildTest}">
<classpath refid="master-classpath"/>
</javac>
should work. As should "classpathref" as an attribute on javac itself.
Possibilities:
Typo in folder name
Typo in file name
D drive isn't mapped

Using SVNAnt in eclipse Build Failed (Could not load definitions from resource)

I want to use SVNAnt in eclipse.
But when I run my script, I have this message :
Buildfile: X:\XXX\bin\ant\axis_bujava.xml
[typedef] Could not load definitions from resource org/tigris/subversion/svnant/svnantlib.xml. It could not be found.
testSVNAnt:
BUILD FAILED
X:\XXX\bin\ant\axis_bujava.xml:11: Problem: failed to create task or type svn
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
Here is the Ant build file :
<?xml version="1.0"?>
<project default="testSVNAnt" basedir=".">
<path id="path.svnant">
<pathelement location="${basedir}/svnant.jar"/>
<pathelement location="${basedir}/svnClientAdapter.jar"/>
</path>
<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="path.svnant" />
<target name="testSVNAnt">
<svn username="username" password="pass">
<checkout url="svn://svnurl" destPath="localpath" revision="HEAD"/>
</svn>
<echo message= "Subversion repository url: ${repository.url}" />
</target>
</project>
The JAR files are of course in basedir. I can't find similar problem nor any solutions.
It finaly work using SvnAnt 1.3.1.
The checkout work fine using this code :
<?xml version="1.0"?>
<project default="main" basedir=".">
<path id="path.svnant">
<pathelement location="${basedir}/svnant.jar" />
<pathelement location="${basedir}/svnClientAdapter.jar" />
<pathelement location="${basedir}/svnjavahl.jar" />
</path>
<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="path.svnant" />
<target name="main">
<svn>
<checkout url="svn://xxx" destPath="X:/XXX" revision="HEAD" />
</svn>
</target>
</project>
Thanks for help.
You have to use
<taskdef />
instead of <typedef/>
Everything else looks fine.
had the same problem.. replacing the value of "resource" from "org/tigris/subversion/svnant/svnantlib.xml" TO "svntask.properties" did it for me.
sample below: (svn_1.0.0; eclipse juno)
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="D:/.../ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<path id="path.svnant">
<pathelement location="D:/.../lib/svnant.jar" />
<pathelement location="D:/.../lib/svnClientAdapter.jar" />
<pathelement location="D:/.../lib/svnjavahl.jar" />
</path>
<typedef **resource="svntask.properties"** classpathref="path.svnant"/>
<target name="ifAvailable">
<available classpathref="path.svnant" **resource="svntask.properties"**
property="temp"/>
<echo message="SVNAnt is available = ${temp}"></echo>
</target>
OUTPUT>>>>>
Buildfile: D:\...\build.xml
ifAvailable:
[echo] SVNAnt is available = true
BUILD SUCCESSFUL
Total time: 306 milliseconds
Replace
<taskdef resource="org/tigris/subversion/svnant/svnantlib.xml" />
with
<taskdef resource="svntask.properties"/>
The svntask.properties are present in the svnant.jar