I am having trouble with GWTP Rest-Dispatch, when I include the Rest-Dispatch configurations (as stated in the wiki) these compiler errors: http://pastebin.com/eWNg2c94 (compile log)
I have no idea what is causing this, I am using Ivy dependency manager (IvyDE eclipse). I have verified all the gwtp-rest dependencies exist. I am using both Dispatchers (Rpc/Rest) here is my applications gwt module configuration.
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to="ims">
<!-- Inherit the core Web Toolkit stuff -->
<inherits name="com.google.gwt.user.User" />
<inherits name="com.google.gwt.logging.Logging"/>
<set-property name="gwt.logging.consoleHandler" value="DISABLED"/>
<set-property name="gwt.logging.popupHandler" value="DISABLED" />
<extend-property name="locale" values="en"></extend-property>
<!-- Core module inherits -->
<inherits name="nz.co.doltech.framework.module.Framework" />
<inherits name="nz.co.doltech.ims.Resources" />
<!-- Theme module inherits -->
<inherits name="nz.co.doltech.framework.themes.SyrenaTheme"/>
<!-- GXT -->
<!--stylesheet src="reset.css" /-->
<!--inherits name='com.sencha.gxt.ui.GXT' /-->
<!-- GXT Theme -->
<!-- <inherits name='com.sencha.gxt.theme.blue.Blue'/> -->
<!-- <inherits name='com.sencha.gxt.theme.gray.Gray' /> -->
<!--inherits name="com.sencha.gxt.theme.neptune.Theme" /-->
<!-- Library module inherits -->
<inherits name="com.gwtplatform.dispatch.rest.DispatchRest"/>
<inherits name="com.gwtplatform.dispatch.rpc.DispatchRpc"/>
<inherits name="com.gwtplatform.mvp.Mvp"/>
<inherits name="com.google.gwt.uibinder.UiBinder"/>
<inherits name="com.google.gwt.query.Query"/>
<inherits name="org.gwtbootstrap3.GwtBootstrap3CDN"/>
<inherits name="nz.co.doltech.framework.extensions.gwtbootstrap3.datepicker.Datepicker"/>
<inherits name="org.atmosphere.gwt.Client"/>
<replace-with class="org.atmosphere.gwt.client.impl.IEHTMLFileCometTransport">
<when-type-is class="org.atmosphere.gwt.client.impl.CometTransport"/>
<any>
<when-property-is name="user.agent" value="ie6"/>
<when-property-is name="user.agent" value="ie8"/>
<when-property-is name="user.agent" value="ie9"/>
</any>
</replace-with>
<!-- Framework module inherits -->
<inherits name="nz.co.doltech.framework.libraries.maydu.validation.ValidationLibrary" />
<inherits name="nz.co.doltech.framework.libraries.chosen.Chosen" />
<!-- Module entry point -->
<entry-point class="nz.co.doltech.ims.client.Application"/>
<extend-configuration-property name="gin.ginjector.modules"
value="nz.co.doltech.ims.client.gin.ClientModule" />
<set-configuration-property name="gwtp.bootstrapper"
value="nz.co.doltech.ims.client.BootstrapperImpl"/>
<set-configuration-property name="gwtp.prebootstrapper"
value="nz.co.doltech.ims.client.BootstrapperImpl.PreBootstrapperImpl"/>
<extend-configuration-property name="document.compatMode" value="BackCompat" />
<!-- Specify the paths for translatable code -->
<source path="client" />
<source path="shared" />
<generate-with class="com.google.gwt.uibinder.rebind.FixedUiBinderGenerator">
<when-type-assignable class="com.google.gwt.uibinder.client.UiBinder"/>
</generate-with>
<!-- RPC Serialization Ignores -->
<extend-configuration-property name="rpc.blacklist" value="javax.*"/>
<extend-configuration-property name="rpc.blacklist" value="com.google.gwt.user.client.ui.*"/>
<extend-configuration-property name="rpc.blacklist" value="com.google.gwt.query.client.*"/>
<extend-configuration-property name="rpc.blacklist" value="com.google.gwt.aria.client.*"/>
<extend-configuration-property name="rpc.blacklist" value="com.google.gwt.dom.client.*"/>
<extend-configuration-property name="rpc.blacklist" value="com.google.gwt.validation.client.*"/>
<extend-configuration-property name="rpc.blacklist" value="nz.co.doltech.framework.extensions.gwtbootstrap3.client.*"/>
<extend-configuration-property name="rpc.blacklist" value="nz.co.doltech.framework.libraries.maydu.validation.client.*"/>
<extend-configuration-property name="rpc.blacklist" value="nz.co.doltech.framework.themes.syrena.ui.*"/>
</module>
My ANT build script:
<!--
================================
Build Application Binaries
================================
-->
<target name="javac" depends="tests" description="Compile java source">
<mkdir dir="war/WEB-INF/classes" />
<javac srcdir="src" includes="**" encoding="utf-8" destdir="war/WEB-INF/classes" source="1.7" target="1.7"
nowarn="true" debug="true" debuglevel="lines,vars,source" includeantruntime="false">
<classpath refid="project.class.path" />
<classpath refid="tomcat.libs"/>
</javac>
<copy todir="war/WEB-INF/classes">
<fileset dir="src" excludes="**/*.java" />
<fileset dir="resources" excludes="**/*.java" />
<fileset dir="database" excludes="**/*.java" />
</copy>
</target>
<target name="gwtc" depends="javac" description="GWT compile to JavaScript">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler" maxmemory="512m">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
</classpath>
<arg value="-war"/>
<arg value="war"/>
<!--arg value="-strict" /-->
<!-- Logging level arguments -->
<!--arg value="-logLevel" />
<arg value="ERROR" /-->
<!-- Optimization arguments -->
<!--arg value="-XenableClosureCompiler"/>
<arg value="-XdisableClassMetadata"/-->
<!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
<jvmarg value="-Xmx512M"/>
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
<arg value="nz.co.doltech.framework.module.Framework"/>
<arg value="nz.co.doltech.framework.login.Login"/>
<arg value="nz.co.doltech.ims.Ims"/>
</java>
</target>
<target name="build" depends="gwtc" description="Build web application entry point"/>
If anyone else has had similar problems I would really really appreciate the help.
You are not using MvpWithEntryPoint but your own entry point, so you need to tell GIN to load the generated modules. Can you make sure your Ginjector looks like the one described here: https://github.com/ArcBees/GWTP/wiki/Rest-Dispatch#installing-with-your-own-ginjector
MOre specifically, in the #GinModules you need to add this argument: properties = {"gin.ginjector.modules"} and the following method to your interface: RestDispatch getRestDispatch();
Related
I am newbie to gwt and ant. Earlier I was working with maven/spring playFramework/sbt.
I would like to add some external jars to my gwt project like:
gwt3bootstrap
hibernate
mysql connector etc.
I've added jars to my lib folder in project:
- gwtbootstrap3-0.9.1.jar
- gwtbootstrap3-extras-0.9.1.jar
But I am getting an error on console:
Runing CodeServer with parameters: [-noprecompile, -port, 42543, -sourceLevel, 1.7, -bindAddress, 127.0.0.1, -launcherDir, /home/danielo/eclipseGwt/StockWatcher/war, -logLevel, INFO, com.google.gwt.sample.stockwatcher.StockWatcher]
Super Dev Mode starting up
workDir: /tmp/gwt-codeserver-6966154251496651044.tmp
Loading inherited module 'com.google.gwt.sample.stockwatcher.StockWatcher'
Loading inherited module 'com.github.gwtbootstrap.Bootstrap'
[ERROR] Unable to find 'com/github/gwtbootstrap/Bootstrap.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
Loading modules
com.google.gwt.sample.stockwatcher.StockWatcher
Loading inherited module 'com.google.gwt.sample.stockwatcher.StockWatcher'
Loading inherited module 'com.github.gwtbootstrap.Bootstrap'
[ERROR] Unable to find 'com/github/gwtbootstrap/Bootstrap.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
[ERROR] shell failed in doStartup method
MyProject.gwt.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.6.2//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.6.2/distro-source/core/src/gwt-module.dtd">
<module rename-to='stockwatcher'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.standard.Standard' />
<inherits name="com.github.gwtbootstrap.Bootstrap" />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point class='com.google.gwt.sample.stockwatcher.client.StockWatcher' />
</module>
build.xml:
<?xml version="1.0" encoding="utf-8" ?>
<project name="StockWatcher" default="build" basedir=".">
<!-- Configure path to GWT SDK -->
<property name="gwt.sdk" location="/path/to/gwt.sdk" />
<path id="project.class.path">
<pathelement location="war/WEB-INF/classes" />
<pathelement location="${gwt.sdk}/gwt-user.jar" />
<fileset dir="${gwt.sdk}" includes="gwt-dev*.jar" />
<!-- Add any additional non-server libs (such as JUnit) -->
<fileset dir="war/WEB-INF/lib" includes="**/*.jar" />
</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.sdk}/gwt-servlet.jar" />
<!-- Add any additional server libs that need to be copied -->
</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>
<copy todir="war/WEB-INF/classes">
<fileset dir="src" excludes="**/*.java" />
</copy>
</target>
<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" />
</classpath>
<!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
<jvmarg value="-Xmx256M" />
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
<arg value="com.google.gwt.sample.stockwatcher.StockWatcher" />
</java>
</target>
<target name="devmode" depends="javac" description="Run development mode">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.DevMode">
<classpath>
<pathelement location="src" />
<path refid="project.class.path" />
</classpath>
<jvmarg value="-Xmx256M" />
<arg value="-startupUrl" />
<arg value="StockWatcher.html" />
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
<arg value="com.google.gwt.sample.stockwatcher.StockWatcher" />
</java>
</target>
<target name="javac.tests" depends="javac" description="Compiles test code">
<javac srcdir="test" includes="**" encoding="utf-8" source="1.5" target="1.5" nowarn="true" debug="true" debuglevel="lines,vars,source">
<classpath location="path_to_the_junit_jar" />
<classpath refid="project.class.path" />
</javac>
</target>
<target name="test.dev" depends="javac.tests" description="Run development mode tests">
<mkdir dir="reports/htmlunit.dev" />
<junit fork="yes" printsummary="yes" haltonfailure="yes">
<jvmarg line="-Xmx256m" />
<sysproperty key="gwt.args" value="-logLevel WARN" />
<sysproperty key="java.awt.headless" value="true" />
<classpath>
<pathelement location="src" />
<pathelement location="test" />
<path refid="project.class.path" />
<pathelement location="path_to_the_junit_jar" />
</classpath>
<batchtest todir="reports/htmlunit.dev">
<fileset dir="test">
<include name="**/*Test.java" />
</fileset>
</batchtest>
<formatter type="plain" />
<formatter type="xml" />
</junit>
</target>
<target name="test.prod" depends="javac.tests" description="Run production mode tests">
<mkdir dir="reports/htmlunit.prod" />
<junit fork="yes" printsummary="yes" haltonfailure="yes">
<jvmarg line="-Xmx256m" />
<sysproperty key="gwt.args" value="-prod -logLevel WARN -out www-test" />
<sysproperty key="java.awt.headless" value="true" />
<classpath>
<pathelement location="src" />
<pathelement location="test" />
<path refid="project.class.path" />
<pathelement location="path_to_the_junit_jar" />
</classpath>
<batchtest todir="reports/htmlunit.prod">
<fileset dir="test">
<include name="**/*Test.java" />
</fileset>
</batchtest>
<formatter type="plain" />
<formatter type="xml" />
</junit>
</target>
<target name="test" description="Run development and production mode tests">
<antcall target="test.dev" />
<antcall target="test.prod" />
</target>
<target name="hosted" depends="devmode" description="Run development mode (NOTE: the 'hosted' target is deprecated)" />
<target name="build" depends="gwtc" description="Build this project" />
<target name="war" depends="build" description="Create a war file">
<zip destfile="StockWatcher.war" basedir="war" />
</target>
<target name="clean" description="Cleans this project">
<delete dir="war/WEB-INF/classes" failonerror="false" />
<delete dir="war/stockwatcher" failonerror="false" />
</target>
</project>
I've also tried to add this jars using in eclipse RMB on project -> Properties -> Java Build Path -> Libraries tab -> Add External JARs
But it dosn't helped me.
Please give me some help.
I have search many forum posts with the same issue, but couldn't resolve it on my own.
just use gwtBootstrap3 and you have to download the jar for it! here the link
than you have to declare the pathelement in your build.xml
<path id="project.class.path">
<pathelement location="war/WEB-INF/classes" />
<pathelement location="${gwt.sdk}/gwt-user.jar" />
<pathelement location="yourpathtojar/gwtbootstrap3-0.9.1.jar" />
<fileset dir="${gwt.sdk}" includes="gwt-dev*.jar" />
<!-- Add any additional non-server libs (such as JUnit) -->
<fileset dir="war/WEB-INF/lib" includes="**/*.jar" />
</path>
if you use a maven project instead you can follow this example
I create a jboss seam 2.2 application using seam-gen tool (ear file)
the application works fine on jboss 4.3,
I managed to run the application on websphere 7 after modifying the jars as per the documents available on seam reference docs,
the problem: i tried many ways to configure the persistence to connect to database, but didn't work.
what is the correct way to have the application connect to DB (oracle) i created a working data-srouce inside websphere 7 but i'm not sure what are the correct configuration inside (components.xml) and (persistence.xml)
Thanks in advance
1- persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- Persistence deployment descriptor for prod profile -->
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="shbCalc">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>shbCalcDS</jta-data-source>
<properties>
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WebSphereExtendedJTATransactionLookup"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="none"/>
</properties>
</persistence-unit>
</persistence>
2- components.xml
<?xml version="1.0" encoding="UTF-8"?>
<components xmlns="http://jboss.com/products/seam/components"
xmlns:core="http://jboss.com/products/seam/core"
xmlns:persistence="http://jboss.com/products/seam/persistence"
xmlns:security="http://jboss.com/products/seam/security"
xmlns:transaction="http://jboss.com/products/seam/transaction"
xmlns:drools="http://jboss.com/products/seam/drools"
xmlns:mail="http://jboss.com/products/seam/mail"
xmlns:web="http://jboss.com/products/seam/web"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.2.xsd
http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.2.xsd
http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.2.xsd
http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.2.xsd
http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.2.xsd
http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.2.xsd
http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.2.xsd
http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.2.xsd">
<transaction:ejb-transaction />
<core:init jndi-pattern="ejblocal:#{ejbName}" debug="true" ></core:init>
<persistence:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="#puJndiName#"/>
<core:manager concurrent-request-timeout="500"
conversation-timeout="120000"
conversation-id-parameter="cid"
parent-conversation-id-parameter="pid"/>
<!-- Make sure this URL pattern is the same as that used by the Faces Servlet -->
<web:hot-deploy-filter url-pattern="*.seam"/>
<security:identity authenticate-method="#{authenticator.authenticate}" />
<event type="org.jboss.seam.security.notLoggedIn">
<action execute="#{redirect.captureCurrentView}"/>
</event>
<event type="org.jboss.seam.security.loginSuccessful">
<action execute="#{redirect.returnToCapturedView}"/>
</event>
<mail:mail-session host="localhost" port="25"/>
</components>
3- web.xml
<?xml version="1.0" ?>
<!-- websphere flavor -->
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5" metadata-complete="true">
<!-- RichFaces -->
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<!-- Suppress spurious stylesheets -->
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
<param-value>disable</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING_CLASSES</param-name>
<param-value>disable</param-value>
</context-param>
<!-- Change load strategy to DEFAULT to disable sending scripts/styles as packs -->
<context-param>
<param-name>org.richfaces.LoadStyleStrategy</param-name>
<param-value>ALL</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.LoadScriptStrategy</param-name>
<param-value>ALL</param-value>
</context-param>
<!-- Seam -->
<listener>
<listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
</listener>
<filter>
<filter-name>Seam Filter</filter-name>
<filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Seam Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Seam Resource Servlet</servlet-name>
<servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Seam Resource Servlet</servlet-name>
<url-pattern>/seam/resource/*</url-pattern>
</servlet-mapping>
<!-- Facelets development mode (disable in production) -->
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>#debug#</param-value>
</context-param>
<!-- JSF -->
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.seam</url-pattern>
</servlet-mapping>
<security-constraint>
<display-name>Restrict raw XHTML Documents</display-name>
<web-resource-collection>
<web-resource-name>XHTML</web-resource-name>
<url-pattern>*.xhtml</url-pattern>
</web-resource-collection>
<auth-constraint/>
</security-constraint>
<!-- Add entries for each EJB session bean which is also a Seam component (not required on JBoss AS) -->
<persistence-unit-ref>
<persistence-unit-ref-name>jdbc/shbCalcDS</persistence-unit-ref-name>
</persistence-unit-ref>
<ejb-local-ref>
<!-- This matches the pattern set in components.xml -->
<ejb-ref-name>ejblocal:EjbSynchronizations</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local>org.jboss.seam.transaction.LocalEjbSynchronizations</local>
</ejb-local-ref>
</web-app>
Finally I found the proper configuration for the application to run on both jboss 4.3 and websphere 7
1- build.xml
<?xml version="1.0"?>
<project name="shbCalc" default="deploy" basedir=".">
<!-- Give user a chance to override without editing this file or typing -D -->
<property file="${basedir}/build.properties"/>
<!-- production is websphere flavor -->
<!-- Dev is jboss flavor -->
<property name="profile" value="prod"/>
<property file="build-${profile}.properties"/>
<!-- set global properties for this build -->
<property name="project.name" value="shbCalc"/>
<property name="project.ear" value="true"/>
<property name="richfaces.present" value="true"/>
<property name="dist.dir" value="dist"/>
<property name="src.model.dir" value="src/main"/>
<property name="src.action.dir" value="src/hot"/>
<property name="src.test.dir" value="src/test"/>
<property name="lib.dir" value="lib"/>
<property name="endorsed.dir" value="${lib.dir}/endorsed"/>
<property name="ear.dir" value="exploded-archives/${project.name}.ear"/>
<property name="exploded.archive.dir" value="${ear.dir}"/>
<property name="jar.dir" value="${ear.dir}/${project.name}_jar"/>
<property name="war.dir" value="${ear.dir}/${project.name}_war"/>
<property name="test.dir" value="test-build"/>
<property name="bootstrap.dir" value="${basedir}/bootstrap"/>
<property name="jboss.domain" value="default"/>
<property name="deploy.dir" value="${jboss.home}/server/${jboss.domain}/deploy"/>
<property name="ear.deploy.dir" value="${deploy.dir}/${project.name}.ear"/>
<property name="jar.deploy.dir" value="${ear.deploy.dir}/${project.name}.jar"/>
<property name="war.deploy.dir" value="${ear.deploy.dir}/${project.name}.war"/>
<property name="packaged.archive" value="${dist.dir}/${project.name}.ear"/>
<property name="testng.jar" value="${basedir}/lib/testng-jdk15.jar"/>
<property name="javac.debug" value="true"/>
<property name="javac.deprecation" value="false"/>
<property name="debug" value="false"/>
<!--Properties for validating configuration files -->
<property name="validate.resources.dir" value="${basedir}/exploded-archives"/>
<property name="schema.dir" value="${basedir}/exploded-archives/schemas"/>
<property name="src.schema.dir" value="${schema.dir}/org/jboss/seam"/>
<property name="schema.version" value="2.2"/>
<fileset id="lib" dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
<path id="build.classpath">
<fileset refid="lib"/>
</path>
<!-- Import GlassFish deployment targets -->
<import file="${basedir}/glassfish-build.xml"/>
<target name="init" description="Initialize the build">
<taskdef name="groovyc"
classname ="org.codehaus.groovy.ant.Groovyc"
classpathref="build.classpath"/> <!-- really only the groovy jar is necessary -->
<mkdir dir="${jar.dir}"/>
<mkdir dir="${ear.dir}"/>
<mkdir dir="${war.dir}"/>
<mkdir dir="${dist.dir}"/>
<condition property="is.debug" value="true">
<istrue value="${debug}"/>
</condition>
<property name="transactionManagerLookupClass" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
<property name="ejbJndiPattern" value="${project.name}/#{ejbName}/local"/>
<property name="seamBootstrapsPu" value="false"/>
<property name="seamEmfRef" value="#{null}"/>
<condition property="puJndiName" value="java:comp/env/${project.name}/pu" else="java:/${project.name}EntityManagerFactory">
<available file="${jboss.home}/lib/jboss-vfs.jar"/> <!-- JBoss AS >= 5.0 -->
</condition>
<filterset id="persistence">
<filter token="transactionManagerLookupClass" value="${transactionManagerLookupClass}"/>
</filterset>
<filterset id="seam">
<filter token="ejbJndiPattern" value="${ejbJndiPattern}"/>
<filter token="seamBootstrapsPu" value="${seamBootstrapsPu}"/>
<filter token="seamEmfRef" value="${seamEmfRef}"/>
<filter token="puJndiName" value="${puJndiName}"/>
</filterset>
<filterset id="profile">
<filter token="debug" value="${debug}"/>
</filterset>
<!-- if a .groovy file is in model or action, set groovy.present -->
<available property="groovy.present" value="true" file="" searchparents="true">
<filepath>
<fileset dir="${src.action.dir}">
<include name="**/*.groovy"/>
</fileset>
<fileset dir="${src.model.dir}">
<include name="**/*.groovy"/>
</fileset>
</filepath>
</available>
<condition property="groovy.test.present" value="true">
<or>
<isset property="groovy.present"/>
<available file="" searchparents="true">
<filepath>
<fileset dir="${src.test.dir}">
<include name="**/*.groovy"/>
</fileset>
</filepath>
</available>
</or>
</condition>
<!-- NOTE: Seam does not properly detect uncompiled groovy classes in an EAR -->
<condition property="groovy.dynamic" value="true">
<and>
<isset property="groovy.present"/>
<istrue value="${debug}"/>
</and>
</condition>
<condition property="groovy.static" value="true">
<and>
<isset property="groovy.present"/>
<isfalse value="${debug}"/>
</and>
</condition>
</target>
<target name="groovy.compile" if="groovy.static">
<groovyc classpathref="build.classpath"
destdir="${jar.dir}"
srcdir="${src.model.dir}">
</groovyc>
<path id="groovy.action.classpath">
<path refid="build.classpath"/>
<dirset dir="${jar.dir}"/>
</path>
<groovyc classpathref="groovy.action.classpath"
destdir="${jar.dir}"
srcdir="${src.action.dir}">
</groovyc>
</target>
<target name="groovy.copy" if="groovy.dynamic">
<copy todir="${jar.dir}">
<fileset dir="${src.action.dir}">
<include name="**/*.groovy"/>
</fileset>
</copy>
</target>
<target name="compile" depends="init,groovy.compile,groovy.copy"
description="Compile the Java source code"
unless="eclipse.running">
<javac classpathref="build.classpath"
destdir="${jar.dir}"
debug="${javac.debug}"
deprecation="${javac.deprecation}"
nowarn="on">
<src path="${src.model.dir}"/>
<src path="${src.action.dir}"/>
</javac>
</target>
<target name="copyclasses" depends="init"
description="Copy the classes that were compiled by eclipse"
if="eclipse.running">
<copy todir="${jar.dir}">
<fileset dir="classes/main">
<include name="**/*.class"/>
</fileset>
<fileset dir="classes/hot">
<include name="**/*.class"/>
</fileset>
</copy>
</target>
<target name="jar" depends="compile,copyclasses"
description="Build the JAR structure in a staging directory">
<copy todir="${jar.dir}">
<fileset dir="${src.model.dir}">
<include name="**/*.component.xml" />
</fileset>
<fileset dir="${basedir}/resources">
<include name="seam.properties"/>
<include name="*.drl"/>
<include name="META-INF/*.drl"/>
</fileset>
</copy>
<copy todir="${jar.dir}/META-INF">
<fileset dir="${basedir}/resources/META-INF">
<include name="ejb-jar.xml"/>
<include name="orm.xml"/>
</fileset>
</copy>
<copy todir="${jar.dir}/">
<fileset dir="${basedir}/resources">
<include name="log4j.xml"/>
</fileset>
</copy>
<copy tofile="${jar.dir}/META-INF/persistence.xml"
file="${basedir}/resources/META-INF/persistence-${profile}.xml">
<filterset refid="persistence"/>
</copy>
<copy tofile="${jar.dir}/import.sql"
file="${basedir}/resources/import-${profile}.sql"/>
</target>
<target name="war" depends="compile"
description="Build the WAR structure in a staging directory">
<copy todir="${war.dir}">
<fileset dir="${basedir}/view"/>
</copy>
<copy tofile="${war.dir}/WEB-INF/classes/seam-jndi.properties"
file="${basedir}/resources/seam-jndi-${profile}.properties">
</copy>
<copy tofile="${war.dir}/WEB-INF/classes/components.properties"
file="${basedir}/resources/components-${profile}.properties">
<filterset refid="seam"/>
<filterset refid="profile"/>
</copy>
<copy tofile="${war.dir}/WEB-INF/components.xml"
file="${basedir}/resources/WEB-INF/components-${profile}.xml">
<filterset refid="seam"/>
<filterset refid="profile"/>
</copy>
<copy todir="${war.dir}/WEB-INF">
<fileset dir="${basedir}/resources/WEB-INF">
<include name="*.*"/>
<include name="lib/*.*"/>
<exclude name="web-*.xml" />
<exclude name="components*.xml"/>
</fileset>
</copy>
<copy todir="${war.dir}/WEB-INF/lib">
<fileset dir="${lib.dir}">
<includesfile name="deployed-jars-war.list"/>
<exclude name="jboss-seam-gen.jar"/>
<exclude name="jboss-seam-debug.jar" unless="is.debug"/>
</fileset>
</copy>
<copy todir="${war.dir}/WEB-INF/classes">
<fileset dir="${basedir}/resources">
<include name="*.skin.properties" if="richfaces.present"/>
<include name="*_theme.properties"/>
<include name="**/*.xcss" if="richfaces.present"/>
</fileset>
<!-- move XCSS into classpath for now
loading from web context only works in JBoss AS 4 -->
<fileset dir="${basedir}/view">
<include name="**/*.xcss" if="richfaces.present"/>
</fileset>
</copy>
<copy tofile="${war.dir}/WEB-INF/web.xml"
file="${basedir}/resources/WEB-INF/web-${profile}.xml">
</copy>
<native2ascii encoding="UTF-8" src="${basedir}/resources"
dest="${war.dir}/WEB-INF/classes"
includes="messages*.properties" />
</target>
<target name="ear" description="Build the EAR structure in a staging directory">
<copy todir="${ear.dir}">
<fileset dir="${basedir}/resources">
<include name="*jpdl.xml"/>
<include name="*hibernate.cfg.xml"/>
<include name="jbpm.cfg.xml"/>
</fileset>
<fileset dir="${lib.dir}">
<include name="jboss-seam.jar"/>
</fileset>
</copy>
<copy todir="${ear.dir}/lib">
<fileset dir="${lib.dir}">
<includesfile name="deployed-jars-ear.list"/>
<exclude name="icefaces-ahs.jar" if="icefaces.present"/>
</fileset>
</copy>
<copy todir="${ear.dir}/META-INF">
<fileset dir="${basedir}/resources/META-INF">
<include name="application.xml"/>
</fileset>
</copy>
<copy tofile="${basedir}/resources/META-INF/jboss-app.xml"
file="${basedir}/resources/META-INF/jboss-app-${profile}.xml">
</copy>
</target>
<target name="clear-profile-artifacts" depends="init"
description="Clear compiled cache of profile-specific artifacts in anticipation of a profile change">
<delete file="${jar.dir}/META-INF/persistence.xml"/>
<delete file="${jar.dir}/import.sql"/>
<delete file="${war.dir}/WEB-INF/classes/components.properties"/>
</target>
<target name="stage" depends="jar,war,ear"/>
<target name="archive" depends="clear-profile-artifacts,stage"
description="Package the archives">
<jar jarfile="${dist.dir}/${project.name}.jar" basedir="${jar.dir}"/>
<jar jarfile="${dist.dir}/${project.name}.war" basedir="${war.dir}"/>
<jar jarfile="${dist.dir}/${project.name}.ear">
<fileset dir="${ear.dir}">
<exclude name="${project.name}_jar/**"/>
<exclude name="${project.name}_war/**"/>
</fileset>
<fileset dir="${dist.dir}">
<include name="${project.name}.jar"/>
<include name="${project.name}.war"/>
</fileset>
</jar>
</target>
<target name="datasource">
<fail unless="jboss.home">jboss.home not set</fail>
<copy file="${basedir}/resources/${project.name}-${profile}-ds.xml"
tofile="${deploy.dir}/${project.name}-ds.xml"/>
</target>
<target name="explode" depends="stage,datasource"
description="Deploy the exploded archive">
<fail unless="jboss.home">jboss.home not set</fail>
<copy todir="${ear.deploy.dir}">
<fileset dir="${ear.dir}">
<include name="**/*"/>
<exclude name="${project.name}_jar/**"/>
<exclude name="${project.name}_war/**"/>
</fileset>
</copy>
<copy todir="${jar.deploy.dir}">
<fileset dir="${jar.dir}"/>
</copy>
<copy todir="${war.deploy.dir}">
<fileset dir="${war.dir}"/>
</copy>
</target>
<target name="unexplode" description="Undeploy the exploded archive">
<delete failonerror="no">
<fileset dir="${ear.deploy.dir}">
<exclude name="**/*.jar"/>
</fileset>
</delete>
<delete file="${deploy.dir}/${project.name}-ds.xml" failonerror="no"/>
<delete dir="${ear.deploy.dir}" failonerror="no"/>
</target>
<target name="reexplode" depends="unexplode,clean,explode"
description="Undeploy the exploded archive, clean, then deploy the exploded archive"/>
<target name="check-deployed" description="Check to see if packaged archive is currently deployed">
<fail unless="jboss.home">jboss.home not set</fail>
<condition property="archive.deployed" value="true">
<available file="${ear.deploy.dir}" type="file"/>
</condition>
</target>
<target name="restart-exploded" unless="archive.deployed" description="Deploy exploded archive if not deployed as packaged archive">
<antcall target="explode"/>
<touch file="${ear.deploy.dir}/META-INF/application.xml"/>
</target>
<target name="restart-deployed" if="archive.deployed" description="Deploy packaged archive if deployed as packaged archive">
<antcall target="deploy"/>
</target>
<target name="restart" depends="check-deployed,clear-profile-artifacts,restart-exploded,restart-deployed" description="Restart the exploded archive"/>
<target name="deploy" depends="archive,datasource" description="Deploy the packaged archive">
<fail unless="jboss.home">jboss.home not set</fail>
<copy todir="${deploy.dir}" file="${dist.dir}/${project.name}.ear"/>
</target>
<target name="undeploy" description="Undeploy the packaged archive">
<delete file="${deploy.dir}/${project.name}.ear"/>
<delete file="${deploy.dir}/${project.name}-ds.xml"/>
</target>
<target name="redeploy" depends="undeploy,clean,deploy"
description="Undeploy the packaged archive, clean, then deploy the packaged archive"/>
<target name="clean" description="Cleans up the staging directory">
<delete dir="${dist.dir}"/>
<delete dir="${basedir}/exploded-archives"/>
<delete dir="${src.schema.dir}" failonerror="no"/>
<delete dir="${basedir}/test-report"/>
<delete dir="${basedir}/test-output"/>
<delete failonerror="no" includeemptydirs="true">
<fileset dir="${test.dir}">
<exclude name="**/*.class" if="eclipse.running"/>
</fileset>
</delete>
</target>
<target name="compiletest" depends="groovy.compiletest" unless="eclipse.running" description="Compile the Java source code for the tests">
<mkdir dir="${test.dir}"/>
<javac classpathref="build.classpath"
destdir="${test.dir}"
debug="${javac.debug}"
deprecation="${javac.deprecation}"
nowarn="on">
<src path="${src.action.dir}"/>
<src path="${src.model.dir}"/>
<src path="${src.test.dir}"/>
</javac>
</target>
<target name="groovy.compiletest" if="groovy.test.present" description="Compile the Groovy source code for the tests">
<mkdir dir="${test.dir}"/>
<groovyc classpathref="build.classpath"
destdir="${test.dir}">
<src path="${src.action.dir}"/>
<src path="${src.model.dir}"/>
<src path="${src.test.dir}"/>
</groovyc>
</target>
<target name="copytestclasses" if="eclipse.running" description="Copy classes compiled by eclipse to the test dir">
<mkdir dir="${test.dir}"/>
<copy todir="${test.dir}">
<fileset dir="classes/main">
<include name="**/*.class"/>
</fileset>
</copy>
<copy todir="${test.dir}">
<fileset dir="classes/hot">
<include name="**/*.class"/>
</fileset>
</copy>
<copy todir="${test.dir}">
<fileset dir="classes/test">
<include name="**/*.class"/>
</fileset>
</copy>
</target>
<target name="buildtest" depends="init,compiletest,copytestclasses" description="Build the tests">
<copy todir="${test.dir}">
<fileset dir="${basedir}/resources">
<exclude name="META-INF/persistence*.xml"/>
<exclude name="import*.sql"/>
<exclude name="${project.name}-*-ds.xml"/>
<exclude name="components-*.properties"/>
</fileset>
<fileset dir="${basedir}/view"/>
</copy>
<copy tofile="${test.dir}/META-INF/persistence.xml"
file="${basedir}/resources/META-INF/persistence-test.xml"/>
<copy tofile="${test.dir}/import.sql"
file="${basedir}/resources/import-test.sql"/>
<copy tofile="${test.dir}/components.properties"
file="${basedir}/resources/components-test.properties"/>
<copy todir="${test.dir}" flatten="true">
<fileset dir="${src.test.dir}">
<include name="**/*Test.xml"/>
</fileset>
</copy>
</target>
<target name="test" depends="buildtest" description="Run the tests">
<fail message="Cannot run tests because path to project contains spaces.">
<condition>
<contains string="${basedir}" substring=" "/>
</condition>
</fail>
<condition property="incompatible.jdk" value="true">
<and>
<equals arg1="${ant.java.version}" arg2="1.6"/>
<not><available classname="javax.xml.bind.JAXB"/></not>
</and>
</condition>
<fail if="incompatible.jdk">You are using an incompatible JDK 6. Please use Sun JDK 6 Update 4 (1.6.0_04) or newer or use Open JDK 6.</fail>
<taskdef resource="testngtasks" classpath="${testng.jar}"/>
<path id="test.path">
<path path="${test.dir}"/>
<fileset dir="${lib.dir}/test">
<include name="*.jar"/>
</fileset>
<path path="${bootstrap.dir}"/>
<path refid="build.classpath"/>
</path>
<testng outputdir="${basedir}/test-report">
<jvmarg line="-Dsun.lang.ClassLoader.allowArraySyntax=true"/>
<classpath refid="test.path"/>
<xmlfileset dir="${test.dir}" includes="*Test.xml"/>
</testng>
</target>
<target name="javadoc" depends="compile">
<mkdir dir="${dist.dir}/apidoc"/>
<javadoc classpathref="build.classpath" destdir="${dist.dir}/apidoc" use="true" protected="true" version="true" windowtitle="${project.name} API Documentation" doctitle="${project.name} API Documentation" link="http://java.sun.com/j2se/5.0/docs/api">
<packageset dir="${src.action.dir}" defaultexcludes="yes">
<include name="*/**"/>
</packageset>
<packageset dir="${src.model.dir}" defaultexcludes="yes">
<include name="*/**"/>
</packageset>
</javadoc>
</target>
<!-- deprecated -->
<target name="validateConfiguration" depends="validate"/>
<target name="validate" depends="stage" description="Validate the XML configuration files">
<mkdir dir="${schema.dir}"/>
<unjar src="${lib.dir}/jboss-seam.jar" dest="${schema.dir}">
<patternset>
<include name="org/jboss/seam/*.xsd"/>
<include name="org/jboss/seam/*.dtd"/>
</patternset>
</unjar>
<ant antfile="validate.xml" target="validateConfiguration"/>
</target>
<target name="purge" depends="undeploy" description="Clean out JBoss AS temporary deployment files">
<delete dir="${jboss.home}/server/default/tmp/deploy"/>
<mkdir dir="${jboss.home}/server/default/tmp/deploy/"/>
<delete dir="${jboss.home}/server/default/tmp/sessions"/>
<mkdir dir="${jboss.home}/server/default/tmp/sessions"/>
<delete dir="${jboss.home}/server/default/work/jboss.web/localhost/${project.name}"/>
</target>
</project>
2- components-prod.xml
<?xml version="1.0" encoding="UTF-8"?>
<components xmlns="http://jboss.com/products/seam/components"
xmlns:core="http://jboss.com/products/seam/core"
xmlns:persistence="http://jboss.com/products/seam/persistence"
xmlns:security="http://jboss.com/products/seam/security"
xmlns:drools="http://jboss.com/products/seam/drools"
xmlns:mail="http://jboss.com/products/seam/mail"
xmlns:web="http://jboss.com/products/seam/web"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.2.xsd
http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.2.xsd
http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.2.xsd
http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.2.xsd
http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.2.xsd
http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.2.xsd
http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.2.xsd">
<persistence:entity-manager-factory name="shbCalc"/>
<persistence:managed-persistence-context name="entityManager" auto-create="true"
entity-manager-factory="#{shbCalc}"/>
<core:init jndi-pattern="ejblocal:#{ejbName}" debug="true" ></core:init>
<core:manager concurrent-request-timeout="500"
conversation-timeout="120000"
conversation-id-parameter="cid"
parent-conversation-id-parameter="pid"/>
<!-- Make sure this URL pattern is the same as that used by the Faces Servlet -->
<web:hot-deploy-filter url-pattern="*.seam"/>
<security:identity authenticate-method="#{authenticator.authenticate}" />
<event type="org.jboss.seam.security.notLoggedIn">
<action execute="#{redirect.captureCurrentView}"/>
</event>
<event type="org.jboss.seam.security.loginSuccessful">
<action execute="#{redirect.returnToCapturedView}"/>
</event>
<mail:mail-session host="localhost" port="25"/>
</components>
3- persistence-prod.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- Persistence deployment descriptor for prod profile -->
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="shbCalc">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>shbCalcDS</jta-data-source>
<properties>
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WebSphereExtendedJTATransactionLookup"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="none"/>
</properties>
</persistence-unit>
</persistence>
4- deployed-jars-ear.list
antlr-runtime.jar
commons-beanutils.jar
#core.jar
drools-templates.jar
drools-decisiontables.jar
drools-compiler.jar
drools-api.jar
drools-core.jar
groovy-all.jar
janino.jar
jboss-el.jar
#jboss-seam-remoting.jar
mvel2.jar
richfaces-api.jar
jbpm-jpdl.jar
antlr.jar
commons-collections.jar
commons-digester.jar
dom4j.jar
el-ri.jar
hibernate-annotations.jar
hibernate-commons-annotations.jar
hibernate-core.jar
hibernate-entitymanager.jar
hibernate-validator.jar
javassist.jar
jboss-el.jar
log4j.jar
richfaces-api.jar
slf4j-api.jar
slf4j-log4j12.jar
jboss-common.jar
5- deployed-jars-war.list
#commons-digester.jar
jboss-seam-debug.jar
#jboss-seam-excel.jar
#jboss-seam-ioc.jar
#jboss-seam-mail.jar
## jboss-seam-pdf.jar
#jboss-seam-rss.jar
jboss-seam-ui.jar
jsf-facelets.jar
#jxl.jar
richfaces-impl.jar
richfaces-ui.jar
hibernate-entitymanager.jar
My Goal is to get a Enterprise Java Application to be built on Jenkins. The Application consists of 4 Projects (Client-Interfaces, Webapplcation (incl. Faces), EJB Application (incl. JPA), EAR-Container-Project).
When Eclipse deploys this projects to a glassfish server, it assembles the Webapplication (war-file), the Client-Interfaces (jar-file) and the EJB-Interfaces (jar-file) into one ear-File.
Now, if I want to use continous integration I need to achieve the same on the CI-Server jenkins.
My first idea was to solve this with ant, so I used the Export-Function of Eclipse and generated build-Files for the projects.
The Problem is that the generated Build-Files refer to the Java EE Libraries (such as Glassfish-Runtime, JPA-Library, etc) which are outside of the project directory. There are about 30 libraries.
This implies that I cannot use the file on jenkins, because this libraries are missing. Of course I can copy these, but I don't think this is how it should be done.
So, what is the best way to get the Java EE Enterprise Application to be built on the CI Server? Do I have to write the ANT-Script all by myself and copy the libraries into the project? Or am I Missing something obvious?
Since I did not found anything that suited for me, I wrote an ant script that covered my needs on my own.
Here is my solution if this helps anyone in the future:
`
<project basedir="." default="build" name="Project">
<available property="glassfishdir" value="/opt/glassfish3/glassfish/modules"
file="/opt/glassfish3/glassfish/modules" type="dir" />
<!-- ########### Property Declarations ################################################################################################################### -->
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.6"/>
<property name="source" value="1.6"/>
<property name="builddir" value="build" />
<property name="outputartifacts" value="out" />
<property name="web.name" value="ProjectWeb" />
<property name="web.projectpath" value="ProjectWeb"/>
<property name="web.src" value="${web.projectpath}/src" />
<property name="web.builddir" value="${builddir}/web" />
<property name="web.builddir.classes" value="${web.builddir}/WEB-INF/classes"/>
<property name="ejb.name" value="ProjectEJB" />
<property name="ejb.projectpath" value="ProjectEJB"/>
<property name="ejb.src" value="${ejb.projectpath}/src"/>
<property name="ejb.builddir" value="${builddir}/ejb" />
<property name="ejb.builddir.classes" value="${ejb.builddir}/classes" />
<property name="ejbclient.name" value="ProjectEJBClient" />
<property name="ejbclient.projectpath" value="ProjectEJBClient"/>
<property name="ejbclient.src" value="${ejbclient.projectpath}/src"/>
<property name="ejbclient.builddir" value="${builddir}/ejbclient" />
<property name="ejbclient.builddir.classes" value="${ejbclient.builddir}/classes"/>
<property name="ear.name" value="ProjectApplication" />
<property name="ear.dir" value="ProjectEAR" />
<!-- ########### Main Targets ################################################################################################################### -->
<target name="build" depends="create-ear">
</target>
<target name="clean-build">
<antcall target="clean" />
<antcall target="build" />
</target>
<target name="clean">
<delete dir="${builddir}"/>
<delete dir="${outputartifacts}"/>
</target>
<target name="init">
<mkdir dir="${outputartifacts}" />
</target>
<!-- ########### EJB App ################################################################################################################### -->
<target name="init-ejb" depends="init">
<mkdir dir="${ejb.builddir}" />
<copy includeemptydirs="false" todir="${ejb.builddir.classes}">
<fileset dir="${ejb.src}">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="build-ejb" depends="init-ejb">
<javac debug="true" debuglevel="${debuglevel}" destdir="${ejb.builddir.classes}" includeantruntime="false" source="${source}" target="${target}">
<src path="${ejb.src}"/>
<classpath>
<fileset dir="${glassfishdir}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${outputartifacts}">
<include name="**/*.jar"/>
</fileset>
</classpath>
</javac>
</target>
<!-- ########### WEB ################################################################################################################### -->
<target name="init-web" depends="init">
<mkdir dir="${web.builddir.classes}"/>
<copy includeemptydirs="false" todir="${web.builddir}">
<fileset dir="${web.projectpath}/WebContent">
</fileset>
</copy>
<copy includeemptydirs="false" todir="${web.builddir.classes}">
<fileset dir="${web.src}">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target depends="init-web,create-ejb-client" name="build-web">
<javac debug="true" debuglevel="${debuglevel}" destdir="${web.builddir.classes}" includeantruntime="false" source="${source}" target="${target}">
<src path="${web.src}"/>
<classpath>
<fileset dir="${glassfishdir}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="out/">
<include name="**/*.jar"/>
</fileset>
</classpath>
</javac>
</target>
<!-- ############## EJB CLIENT ################################################################################################################ -->
<target name="init-ejb-client" depends="init">
<mkdir dir="${ejbclient.builddir}"/>
<copy includeemptydirs="false" todir="${ejbclient.builddir.classes}">
<fileset dir="${ejbclient.src}">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target depends="init-ejb-client" name="build-ejb-client">
<javac debug="true" debuglevel="${debuglevel}" destdir="${ejbclient.builddir.classes}" includeantruntime="false" source="${source}" target="${target}">
<src path="${ejbclient.src}"/>
<classpath>
<fileset dir="${glassfishdir}">
<include name="**/*.jar"/>
</fileset>
</classpath>
</javac>
</target>
<!-- ############ CREATE ARCHIVES################################################################################################################## -->
<target name="create-web" depends="build-web">
<war destfile="${outputartifacts}/${web.name}.war" basedir="${web.builddir}" webxml="${web.projectpath}/WebContent/WEB-INF/web.xml"/>
</target>
<target name="create-ejb-client" depends="build-ejb-client">
<jar destfile="${outputartifacts}/${ejbclient.name}.jar" basedir="${ejbclient.builddir.classes}" includes="**/*"/>
</target>
<target name="create-ejb" depends="build-ejb">
<jar destfile="${outputartifacts}/${ejb.name}.jar" basedir="${ejb.builddir.classes}" includes="**/*">
<manifest>
<attribute name="Class-Path" value="${ejbclient.name}.jar"/>
</manifest>
</jar>
</target>
<target name="create-ear" depends="create-ejb-client,create-web,create-ejb">
<ear destfile="${outputartifacts}/${ear.name}.ear" appxml="${ear.dir}/EarContent/META-INF/application.xml">
<fileset dir="${outputartifacts}" includes="*.jar,*.war"/>
</ear>
</target>
</project>
`
Use Maven.
Maven allow to define all dependencies in a single xml file (pom), dependencies which will be automatically downloaded from internet at compilation phase.
Maven come with a set of plugin to facilitate continuous integration like being able to start a container, run the test and close it automatically.
Maven integrate natively with jenkins.
Maven defines a complex lifecycle designed for this kind of problematic and allowing to compile, run unit test, package, run integration test and deploy with a single command triggered from jenkins;
Maven is definitively THE solution here.
You can also auto-create the build.xml in Eclipse using "Export... > General\Ant Buildfile" from the project context menu. This way the correct classpath is generated to your JAR's already available in the project.
Chances are that if there are dependencies between the projects, you only need to configure one build file to be run on Jenkins, as it will automatically call the build files from the other projects.
I'm trying to make an Eclipse-compilable GWT project also compilable on the command line (via Ant).
Eclipse provides functionality to export a build.xml; this works fine for compiling the classes, but since GWT's special stuff is all provided via a plugin, these rules are not included.
Google provides a tool for creating build.xml files for new projects. I've incorporated the rules generated by this into the Eclipse-exported file.
Compiling (the part provided by Eclipse) is successful.
Here is the compile-things-to-javascript task:
<target name="gwtc" depends="build" description="GWT compile to JavaScript (production mode)">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="war/WEB-INF/classes"/>
<pathelement location="src"/>
<path refid="project.class.path"/>
<pathelement location="/Applications/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.4.0.v201201120043-rel-r37/gwt-2.4.0/validation-api-1.0.0.GA.jar" />
<pathelement location="/Applications/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.4.0.v201201120043-rel-r37/gwt-2.4.0/validation-api-1.0.0.GA-sources.jar" />
</classpath>
<!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
<jvmarg value="-Xmx256M"/>
<!--<arg line="-style PRETTY"/>-->
<arg line="-war"/>
<arg value="war"/>
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
<arg line="${gwt.args}"/>
<arg value="edu.calpoly.csc.scheduler"/>
</java>
</target>
The .gwt.xml file looks like so:
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='gwtview'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point class='edu.calpoly.csc.scheduler.view.client.GWTView'/>
<!-- Specify the paths for translatable code -->
<source path='client'/>
<source path='shared'/>
<source path='view'/>
</module>
When trying to run the task, I get this error:
gwtc:
[java] Compiling module edu.calpoly.csc.scheduler
[java] Finding entry point classes
[java] [ERROR] Unable to find type 'edu.calpoly.csc.scheduler.view.client.GWTView'
[java] [ERROR] Hint: Previous compiler errors may have made this type unavailable
[java] [ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
Which seems strange to me, since the class is very much there:
[$]> ls war/WEB-INF/classes/edu/calpoly/csc/scheduler/view/client
GWTView$1.class GWTView$1MyHandler.class GreetingService.class
GWTView$1MyHandler$1.class GWTView.class GreetingServiceAsync.class
Halp?
Are you sure you have sources of your GWT app on classpath? GWT is compiling java sources to js, not *.class files.
Make sure that you have that library/jar and any other SOURCE needed available on the classpath you pass to the GWT Compiler, as it will need to be able to find the Java source inside GWT libs to be able to compile them, unlike the Javac compiler than can compile against libraries using just the provided .class files.
Here is my ant gwtc compile macro. (removed leading <to avoid formatting problems...)
macrodef name="gwtCompileApplication" >
<attribute name="app" />
<attribute name="extraArgs" default="" />
<attribute name="gwtcExtras" default="" />
<sequential>
<java classpathref="gwtCompile.classpath" classname="com.google.gwt.dev.Compiler" fork="true" failonerror="true">
<jvmarg value="-Xmx512M" />
<arg value="-strict" />
<!-- Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
<arg value="-logLevel" />
<arg value="DEBUG" />
-->
<!-- request detailed, non-obfuscated JS output
<arg value="-style" />
<arg value="DETAILED" />
-->
<arg value="-localWorkers" />
<arg value="4" />
<arg value="-war" />
<arg value="${war.dir}" />
<arg value="-deploy" />
<arg value="deploy" />
<!-- These two lines have been removed as otherwise it won't work on Mac OS X
<arg value="#{extraArgs}" />
<arg value="#{gwtcExtras}" />
-->
<!-- This can be used to see more details about warnings, but they will be converted to errors and build will fail
<arg value="-strict" />
-->
<arg value="-logLevel" />
<arg value="INFO" />
<arg value="#{app}" />
</java>
</sequential>
</macrodef>
This can be invoked from any target thus:
A target to compile a specific module of mine called 'Admin" where the file Admin.gwt.xml file is inside .ta.Admin. I have a debug and production build type and a .gwt.xml different for each one to speed up compiling for debug (fewer user agents and languages = fewer permutations)
target name="gwtcAdmin" depends="compile, buildtype" description="GWT Compile Admin" >
<gwtCompileApplication app="com.bcntouch.ta.Admin.${build_type}_Admin" extraArgs="${gwtcArgs}" gwtcExtras="${gwtcExtras}"/>
</target>
But the key part if the GWT compile class path I use. Here is the target where I setup my paths:
target name="gwtPath">
<path id="gwt.classpath">
<pathelement location="${gwt.sdk.dir}/gwt-user.jar" />
<pathelement location="${gwt.sdk.dir}/gwt-servlet.jar" />
</path>
<!-- For GWT compile we need a path with source AND the GWT Compiler classes -->
<path id="gwtCompile.classpath">
<path refid="source.classpath" />
<!-- This is put after source, so GWT Compiler it doesn't pick up out of date versions of old css and uibinder
files in classes generated by Eclipse/GWT Plugin -->
<path refid="classpath" />
<path refid="tool.classpath" />
</path>
</target>
I need to use XML to JSON lib in my war.
I followed a tutorial explaining that dependencies are required in the project.
But when I add the following in my ant build.xml (the file used to create the war), Eclipse complains about the artifact:dependencies, seems like it does not like the :.I have the following error message:
The prefix artifact for element artifact:dependencies is not bound...
<artifact:dependencies filesetId="dependency.fileset"
sourcesFilesetId="sources.dependency.fileset"
javadocFilesetId="javadoc.dependency.fileset"
versionsId="dependency.versions">
<!-- DEPENCIES GO HERE -->
</artifact:dependencies>
Any idea ?
UPDATE
I have the same problem trying to define an in-memory pom with:
<artifact:pom id="mypom" groupId="org.acme" artifactId="project1" version="1.0">
<dependency groupId="junit" artifactId="junit" version="4.1"/>
<dependency groupId="org.codehaus.plexus" artifactId="plexus-utils" version="1.5.5"/>
<license name="apache" url="http://www.apache.org"/>
</artifact:pom>
The prefix artifact for element artifact:pom is not bound...
UPDATE 2
I installed maven-ant jar in ant/lib and change the build.xml so it contains the definition of the artifact stuff but I have an error message while running it.
<project name="test" default="install" xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<artifact:dependencies pathId="dependency.classpath">
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.3</version>
<type>jar</type>
<classifier>jdk15</classifier>
<scope>compile</scope>
</dependency>
...
The error message Eclipse gave is:
BUILD FAILED
D:\J2EE\workspace\Test\build.xml:3: Problem: failed to create task or type antlib:org.apache.maven.artifact.ant:dependencies
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.
No types or tasks have been defined in this namespace yet
This appears to be an antlib declaration.
Action: Check that the implementing library exists in one of:
-D:\eclipse\plugins\org.apache.ant_1.8.2.v20110505-1300\lib
-C:\Documents and Settings\luc\.ant\lib
-a directory added on the command line with the -lib argument
The maven-ant jar does exist in -D:\eclipse\plugins\org.apache.ant_1.8.2.v20110505-1300\lib
UPDATE 3
This is the build.xml file I'm using.
<!--
<project name="Monitoring" default="install" xmlns:artifact="urn:maven-artifact-ant" xmlns:test="urn:test-tasks">
-->
<project name="Monitoring" default="install" xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<!-- project-specific variables -->
<property environment="env" />
<property name="project_home" value="D:\J2EE\workspace\Monitoring"/>
<property name="webapp.dir" value="${project_home}/target" />
<property name="jboss.dir" value="D:\J2EE\jboss\standalone\deployments" />
<property name="package.name" value="monitoring.war" />
<property name="lib.dir" value="${project_home}/lib" />
<property name="src.dir" value="${project_home}/src" />
<property name="resources.dir" value="${project_home}/resources" />
<property name="dest.dir" value="${project_home}/target" />
<property name="package.file" value="${dest.dir}/${package.name}" />
<!-- put everything in a temp folder with the right structure during the build -->
<property name="temp.dir" value="${project_home}/temp" />
<property name="temp.dir.web-inf" value="${temp.dir}/WEB-INF" />
<property name="temp.dir.lib" value="${temp.dir.web-inf}/lib" />
<property name="temp.dir.classes" value="${temp.dir.web-inf}/classes" />
<property name="temp.dir.meta-inf" value="${temp.dir}/META-INF" />
<path id="build.class.path">
<fileset dir="${env.JAVA_HOME}/lib">
<include name="**/*.jar" />
</fileset>
<fileset dir="D:\ant\lib">
<include name="**/*.jar" />
</fileset>
</path>
<target name="deps">
<artifact:dependencies pathId="dependency.classpath">
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.3</version>
<type>jar</type>
<classifier>jdk15</classifier>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
<version>1.1</version>
</dependency>
</artifact:dependencies>
</target>
<target name="clean" depends="deps">
<delete>
<fileset dir="${dest.dir}" includes="**/*"/>
</delete>
<delete dir="${temp.dir}" />
<delete dir="${temp.dir.classes}" />
<delete dir="${temp.dir.meta-inf}" />
<delete dir="${temp.dir.web-inf}" />
</target>
<target name="prepare" depends="clean">
<mkdir dir="${dest.dir}" />
<mkdir dir="${temp.dir}" />
<mkdir dir="${temp.dir.lib}" />
<mkdir dir="${temp.dir.meta-inf}" />
<mkdir dir="${temp.dir.web-inf}" />
<mkdir dir="${temp.dir.classes}" />
</target>
<!-- COMPILE -->
<target name="compile" depends="prepare">
<echo>=== COMPILE ===</echo>
<echo>Compiling ${src.dir} files ...</echo>
<javac debug="on" srcdir="${src.dir}" destdir="${temp.dir.classes}" includes="**/*" includeantruntime="false">
<classpath refid="build.class.path" />
<classpath refid="dependency.classpath" />
</javac>
</target>
<!-- PACKAGE -->
<target name="package" depends="compile">
<echo>=== PACKAGE ===</echo>
<!-- copy the config files -->
<copy file="${resources.dir}/web.xml" tofile="${temp.dir.web-inf}/web.xml" overwrite="true" />
<copy file="${resources.dir}/manifest.mf" tofile="${temp.dir.meta-inf}/manifest.mf" overwrite="true" />
<copy todir="${temp.dir.classes}">
<fileset dir="${src.dir}">
<include name="**/*.xml"/>
<include name="**/*.xsl"/>
</fileset>
</copy>
<!-- the ant war task. with all resources in place, create the war file -->
<war destfile="${package.file}" webxml="${temp.dir.web-inf}/web.xml" basedir="${temp.dir}">
<lib dir="${lib.dir}" />
<classes dir="${temp.dir.classes}" />
</war>
</target>
<!-- INSTALL -->
<target name="install" depends="package">
<echo>=== INSTALL ===</echo>
<copy file="${package.file}" tofile="${webapp.dir}/${package.name}" overwrite="true" />
<copy file="${package.file}" tofile="${jboss.dir}/${package.name}" overwrite="true" />
</target>
</project>
It was working well before I added all the dependencies stuff... still cannot find out the pb here. Any help would be very welcome.
It looks like you're making use of Maven Ant Tasks. To do this you'll need a copy of the jar from the download area here.
Once (or if) you've got that, you'll need to modify your buildfile to use it.
The main things that are needed are to define the artifact namespace, and add the typedef for the ant-lib:
<project name="foo" default="foo" xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<path id="maven-ant-tasks.classpath" path="lib/maven-ant-tasks-2.1.3.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="antlib:org.apache.maven.artifact.ant"
classpathref="maven-ant-tasks.classpath" />
I had the same error message but the cause was different.
Going to Window -> Preferences -> Ant -> Runtime and setting Ant Home solved my problem.
So for anyone that above solution doesn't work, check if "Ant Home" is pointing to the right direction