Deployment with e(fx)clipse - Build Error - deployment

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.

Related

How do I delete a folders that match pattern in phing

I have a build_ folders in my directory like build_10320 or build_10321.
I need to write a target clean that deletes such a folder.
I am trying doing this
<target name="clean">
<echo msg="clean directory ./build_" />
<delete includeemptydirs="true" verbose="true" failonerror="false" >
<fileset dir="./">
<include name="./build_*" />
</fileset>
</delete>
</target>
But this doesn't work. Kindly help.
Phing still doesn't have the <dirset> feature working (which would be the natural choice). You can however make this work using <exec> & the relevant command for deleting files from your operating system.
For linux:
<exec command = "rm -rf ./build_*" passthru = "true" />
A <fileset> returns, as the name suggests, only files.
There is an undocumented <dirset> type that unfortunately cannot be used with <delete> at the moment.
With Phing 3.x you can use <dirset> inside the <delete> task.
<project name="delete-with-dirset" default="clean" basedir=".">
<target name="clean">
<echo msg="clean directory ./build_" />
<delete includeemptydirs="true" verbose="true" failonerror="false">
<dirset dir="./">
<include name="./build_*" />
</dirset>
</delete>
</target>
</project>

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

EnversHibernateToolTask in NetBean build file issue

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.