Packaging JAR's using Ant in Eclipse

Hey,
I'm new to Ant, and xml for that matter. I need to rmi compile & package a set of simple classes whose objects call eachother remotely. I need seperate jars for a "server" and one for "client" containing whatever classes are needed for each. Using Ant the classes should be compiled, packaged into the jars and then the jars should be copied to some other specified directory. And of course, the jars should be executable.
The files I use are AddressBook (interface extends Remote), AddressBookImpl (extends UnicastRemoteObject implements AddressBook), BuddyInfoInterf (interface extends Remote), BuddyInfo (the implementation, extends Unicast... implements BuddyI...), and AddressBookUser.
The AddressBook is created on the server-side (in main() found in AddressBookImpl) and is populated with BuddyInfo's also created server-side.
AddressBookUser is just the client accessing some info from ABook or BInfo.
So, anyway, here's the xml file I've written to do the tasks assigned. The classes compile fine, and the jar files seem to contain the proper files. My problem is that the jar files don't execute properly. The main() in AddressBookImpl creates the ABook and binds it to the rmiregistry. When I run the server.jar that is "initially" created during the process (the one in the base dir) it works fine but this only seems to work correctly because it's in the same dir as all of the compiled classes. The copied jar file in the other directory, or even if I manually copy the server.jar file in the base dir to some other dir, causes an exception when trying to bind the AddressBook to the registry saying it can't find a stub that is definitely located in the jar. And I'm running the rmiregistry in whatever dir the server.jar is in each time:
Exception in thread "main" java.rmi.ServerException: RemoteException occurred in
server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
tion is:
java.lang.ClassNotFoundException: AddressBookImpl_Stub
at sun.rmi.server.....
<?xml version="1.0"?>
<project default="packaging">
<!-- Change location(s) to desired path(s) where client and/or
server jar files should be copied to, else will create folders
"client" and "server" in project directory and copy them to
there. -->
<property name="serverDir" location="./server"/>
<property name="clientDir" location="./client"/>
<!-- performs all tasks -->
<target name="packaging">
     <!-- Compiles all files in project directory. Necessary for
     AddressBookUser.java to be compiled -->
     <javac srcdir="."/>
     <!-- RMI compiles AddressBookImpl & BuddyInfo -->
     <rmic classname="AddressBookImpl" base="."/>
     <rmic classname="BuddyInfo" base="."/>
     <!-- Creates server jar file -->
     <jar destfile="./server.jar" basedir="." includes="**.class" excludes="AddressBookUser.**">
          <manifest>
               <attribute name="Main-Class" value="AddressBookImpl"/>
               <attribute name="Class-Path" value="."/>
          </manifest>
     </jar>
     <!-- Creates client jar file -->
     <jar destfile="./client.jar" basedir="." includes="**.class" excludes="AddressBookImpl.** BuddyInfo.** **Skel.class">
          <manifest>
               <attribute name="Main-Class" value="AddressBookUser"/>
               <attribute name="Class-Path" value="."/>
          </manifest>
     </jar>
     <!-- copy jar files to specified directories -->
     <copy file="./server.jar" todir="${serverDir}"/>
     <copy file="./client.jar" todir="${clientDir}"/>     
</target>
</project>
Sorry bout the length. Just want to cover my bases. Thanks for any help.

I am also having problem in building server.jar file using Ant. I am using EJB jar file in my web application, this jar file is called remotely from server to client. Client.jar file working correctly but the server.jar file contains error which is given below:
15:30:47,296 WARN [verifier] EJB spec violation:
Bean : Server
Section: 22.2
Warning: The Bean Provider must specify the fully-qualified name of the Java cla
ss that implements the enterprise bean's business methods in the <ejb-class> ele
ment.
Info : Class not found on 'com.ejb.ServerBean': No ClassLoaders found for: com.ejb.ServerBean
15:30:47,296 ERROR [MainDeployer] Could not create deployment: file:/C:/jboss-4.0.4.GA/server/default/deploy/server.jar
org.jboss.deployment.DeploymentException: Verification of Enterprise Beans failed, see above for error messages.
In above error, "Class not found on 'com.ejb.ServerBean' " is given. Will there be all the classes of EJB jar file in server.jar ? I think only the interface class file i.e. Server.class and serverHome.class must be included, am I correct or not?
Also the build.xml which I am using for creating server.jar is given below:
<project name="ServerEJB" default="make_server_jar" basedir=".">
<!-- Initialization variables -->
<property environment="env" />
<property name="app.name" value="${ant.project.name}"/>
<property name="source.dir" value="ejbModule"/>
<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="distribution.dir" value="dist"/>
     <property name="server.ejb.jar.name" value="server.jar"/>
<target name="clean" description="Deletes compiled and generated code">
<delete dir="${build.dir}"/>
</target>
<target name="make_server_jar" depends="" description="Builds a server.jar with stubs for apps to use">
<mkdir dir="${distribution.dir}" />
<jar destfile="${distribution.dir}/${server.ejb.jar.name}" basedir="${classes.dir}">
     <exclude name="**/*Bean.class"/>
</jar>
</target>     
</project>
I am using server.jar file in server as interface which will remotely call client.jar which will be kept at client location.
Anybody, can you provide me with the solution for this problem?...
Thank you.

Similar Messages

  • How to compile Java files using Ant in Eclipse

    Hi All ,
    I would like to compile all Java files using Ant in Eclipse.Since am very new to Ant and Eclipse can someone help me to create a build.xml file and let me know how to compile all the java files.
    For ex , I have placed my java files inside the path C:\HEC\Terab.Initially the Terab folder holds 7 jar files which i had decompiled using JD compiler and placed the unzipped 7 folders (which contains the java files ).Now i have imported the HEC project into Eclipse using New ->Project ->Java Project.after importig it throwed me an error saying missing jar files.again i copied the jar files and placed inside Terab folder with other 7 folder.
    Now How i can compile the java files and convert in to class files.Then after compiling the files i will again need to jar all the 7 folder.
    Please tell me the steps i need to follow.How to write an build.xml file ? where i should keep it ? only one build.xml file is enough or should i write 7 build.xml file for each folder ? Please help me out...
    Thanks & Regards
    Kar1983

    put it another way, what I am trying to do is to compile David Brackeen's ch 18 code from his book. The java sourse files can be downloaded here:
    http://www.brackeen.com/javagamebook/
    my question is that how would I complie all of these file so that I can get the program in ch18src\src\com\brackeen\javagamebook\test\ to run?

  • Running a JUnit test case using Ant in Eclipse

    If I have a "JUnit", how can I run it using "Ant" in Eclipse?
    Thanks.

    Right-click on the ant build script and select "Run as ant build". But why bother? Eclipse has its own JUnit runners

  • Building jars using ant and eclipse

    Note: If this post could be in a more appropriate forum category could someone please tell me which one is better.
    Vexing issue:
    I am using ANT so that it will take care of which classes have been modified and therefore which jars need to be updated.
    I noticed one way ANT can work is to look at the timestamp of the class files and then build the necessary jars. This works fine EXCEPT that eclipse has a nasty habit of sometimes recompiling everything, even when I dont ask it to. It would seem to make more sense basing the recompilation on the source files, and whether they have been modified. So I set this up with my build.xml, ie
    <target name="compile" depends="init"
    description="compile the source " >
    <!-- Compile the java code from ${src} into ${build} -->
    <javac srcdir="${src}" destdir="${build}" fork="true"/>
         </target>
    Now suppose I go and change one of my source files, ANT recompiles that file and that all works great. However, suppose that file had in it, which many do,
    public static String EXAMPLE_VARIABLE = "example";
    This static variable is referenced in many classes, and yet ANT only recompiles the one file, and thus there begins an inconsistency!
    Is there any way to get around this? I would have expected ANT to recompile all the files that depend on the class with the static variable but it doesnt.
    Any help much appreciated.
    Cel

    You know, that's a good question. I would think JVMs at runtime could resolve static variables, like when it compiles classes using that static variable it puts a placeholder "Hey, here I am using XXX, at runtime, figure it out and give me the value right at the start..". But I think it works like you suggest in that a static value is compiled into every location that uses it. The only thing I can think of is provide a target for a build-all in your ant and have it rebuild all.
    I agree though that the javac compiler should be smarter in how it compiles classes. Anytime a class has certain attributes that may be compiled in to other classes, it should check and recompile any class that depends on the static value that has changed.

  • How to increase memory for building project using ant in ECLIPSE

    Hi All,
    for all java projects and java applications in eclipse i am giving -Xms and -Xmx to increase heap memory.
    But the same failed when i run ant. it says Out of Memory Error.eventhough i had 1GB ram in system.
    How to increase memory for Building through ANT.
    Thanks,
    J.Kathir

    even if this is not a eclipse forum
    In the package explorer view or navigator view right click on the build file select "Run as / Ant Build ...". On the JRE Tab you can enter the VM Aguments like -Xmx512m
    Consult the java dokumentation how to set the memory of the jvm.

  • Weblogic.jspc outofmemory error while compiling jsps using ant in eclipse

    Hi all,
    I am trying to execute this target in my ant build:
         <target name="jspc">
              <java classname="weblogic.jspc" fork="yes">
                   <arg line="-verbose -verboseJavac -compileAll -webapp ${project.jsp.dir} -d ${project.jsp.class.dir}" />
                   <classpath>
                        <pathelement path="${classpath}" />
                   </classpath>
         </java>
         </target>
    I am getting the following error:
    [java] Error: [jspc]: 0 file(s) failed:
    [java] [Compilation errors : ]
    [java] The system is out of resources.
    [java] Consult the following stack trace for details.
    [java] java.lang.OutOfMemoryError
    [java] at weblogic.jspc.doCompile(jspc.java:861)
    [java] at weblogic.jspc.runJspc(jspc.java:654)
    [java] at weblogic.jspc.runBodyInternal(jspc.java:412)
    [java] at weblogic.jspc.runBody(jspc.java:319)
    [java] at weblogic.utils.compiler.Tool.run(Tool.java:192)
    I am using weblogic 8.1, eclipse3.1, java1.4.1.
    Can some one please help me with this issue?
    thanks in advance.

    --> some error on posting please refer to the next post...
    From the error logs we can trace it out to the web project's Build.xml file ....I was getting a similar error and by commenting out the following lines in the web project's Build.xml I am able to run the build script correctly and get a EAR file. The lines are
    <!--
    <assemble
    moduleDir="${generated.module.root}"
    moduleName="${project.name}"
    srcOutputDir="${assembly.src}"
    appRootDir="${ear.root}">
    <assemblyContext factory="org.apache.beehive.controls.runtime.assembly.WebAppAssemblyContext$Factory" />
    <assemblyContext factory="org.apache.beehive.controls.runtime.assembly.AppAssemblyContext$Factory" />
    <classpath refid="assembly.classpath" />
    <fileset dir="${project.dir}">
    <include name="**/*.controls.properties" />
    </fileset>
    </assemble>
         -->
    Please check it now, also if any one can let us know the function or role played by the above lines it would be great. Also if there would be any future or unseen problems by commenting out these lines please do let us know...
    Thanks
    -MiM
    Edited by prodigymonish83 at 10/22/2007 5:56 AM

  • Problem in reloading project using ANT in Eclipse

    Hello Friends,
    I have created one application in which i just put one jsp page and the application is based on Strtus.
    for loading project in tomcat i have done following step,
    all,install
    now for next time after changes made in jsp page i have perform all,reload
    but it will give me the error.
    BUILD FAILED
    *<Path of projct> \build.xml:192: FAIL - Encountered exception java.lang.NoSuchMethodError: org.apache.commons.logging.LogFactory.release(Ljava/lang/ClassLoader;)V*
    Total time: 30 seconds
    but for loading project i perform all,remove,install
    so now i have to perform 3 steps each time.
    anyone know about the above problem.
    i have put common-logging.jar file and in that there is a release method which is abstract.
    Thanks in advance,
    Ajay Patel

    Continueee....on above...
    when i perform all,remove,install for reinstalling application on tomcat,
    i also got same error while performing remove operation but still it delets from tomcat.
    And when i perform all,remove
    it gives me
    reload:
    *[reload] FAIL - Encountered exception java.lang.IllegalStateException: Container StandardContext[EventManagementSystem] has not been started*
    BUILD FAILED
    *C:\Documents and Settings\Ajay\Desktop\ajay\JspWorkspace\EventManagement\build.xml:192: FAIL - Encountered exception java.lang.IllegalStateException: Container StandardContext[EventManagementSystem] has not been started*
    Total time: 2 seconds
    can anyone know about this.....how can i solve the LogFactory error.
    Thank You in advance,
    Ajay Patel

  • Ant in eclipse

    when i use ant in eclipse.
    it says
    [javac] BUILD FAILED: file:D:/JavaProject/ACS/testAnt.xml:18: Unable to find a javac compiler;
    com.sun.tools.javac.Main is not on the classpath.
    Perhaps JAVA_HOME does not point to the JDK
    but i set the classpath as follow:
    CLASSPATH
    .;d:\j2sdk1.4.1_01\lib\dt.jar;D:\j2sdk1.4.0_01\lib\tools.jar
    JAVA_HOME
    D:\j2sdk1.4.0_01
    Path
    ......;D:\j2sdk1.4.0_01\bin;.;D:\j2sdk1.4.0_01\lib\dt.jar;D:\j2sdk1.4.0_01\lib\tools.jar
    how to slove that?

    Thanks for the solution E13, that fixed the same problem I was having. However, I'm thinking that this might be an Eclipse-specific bug, and not due to a shortcoming on M$ part (for once :)
    The reason I say this, is that when I was trying to debug this problem, I noticed that Eclipse kept wanting to set its internal java.home to the location of the System JRE (which was J2SDK1.4.2 in my case - run 'ant -diagnostics'). So I'm assuming that when it looked under ${java.home}/bin, it didn't find the javac compiler and failed.
    What's strange, is that no matter what I tried, I couldn't get Eclipse's Ant tool to point to a different java.home. My system JAVA_HOME is set correctly, but eclipse apparently clobbered it. I tried overwriting this value in the properties sheet to no avail. Even after applying your solution, the code compiles fine, but java.home is still pointing to the wrong directory.
    Is eclipse querying the Registry for Ant's java.home?? I grepped all the xml resource and property files in my Eclipse install dir looking for where this value was assigned, but it isn't there. Is anyone else seeing this problem? I'll probabally open up a Bug on Eclipse since this doesn't appear to be correct behavior.

  • Debug aplication started using ant

    Hello,
    I wonder if it is possible to stop and debug an aplication in a breakpoint when this aplication was started using ant from eclipse as IDE. I use eclipse ver. 3.0.
    thanks a lot for any help or ideea

    Not all WLST installations are equivalent. Have a read of [http://www.oracle.com/technetwork/articles/adf/part10-085778.html]this, specifically the paragraph right after Figure 13 for something to try. Bottom line - the WLST that comes with the base WLS server install cannot do the MDS operations.
    John

  • "Error running javac.exe compiler" when using ant to compile Eclipse plugin

    Hi
    I encounter an error "Error running C:\jdk1.5.0_06\bin\javac.exe compiler" when building my project using ant1.7.
    My project has 10 eclipse plugins, and each plugin is compiled by invoking following ant target
    <!-- ===================================================================
    Compile specified plugin
         target parameters:
              param.plugin.dir: the plugin directory
              param.plugin.targetJarFile: the name of jar file for the given plugin
              param.plugin.src.dir: the folder name of source codes. Note: it is relative path name
              param.fork: indicate if another process is forked to run javac
    =================================================================== -->
    <target name="compilePlugin">
         <!-- Prepare compile environment -->
         <!-- Delete obsolete build folder -->
         <delete dir="${param.plugin.dir}/${build.dir}" quiet="true"/>
         <!-- Delete obsolete jar file -->
         <delete file="${param.plugin.dir}/${param.plugin.targetJarFile}" quiet="true"/>
         <mkdir dir="${param.plugin.dir}/${build.dir}"/>
         <!-- Compile source codes -->
         <javac      srcdir="${param.plugin.dir}/${param.plugin.src.dir}"
                   destdir="${param.plugin.dir}/${build.dir}"
                   failonerror="${javacFailOnError}"
                   verbose="${javacVerbose}"
                   debug="${javacDebugInfo}"
                   deprecation="${javacDeprecation}"
              optimize="${javacOptimize}"
                   source="${javacSource}"
                   target="${javacTarget}"     
                   fork="${param.fork}" memoryInitialSize="256m" memoryMaximumSize="512m">
              <classpath refid="compile.classpath" />
         </javac>
         <!-- Create plugin jar file -->
         <copy todir="${param.plugin.dir}/${build.dir}" failonerror="true">
              <fileset dir="${param.plugin.dir}/${param.plugin.src.dir}" excludes="**/*.java, **/package.htm*" />
         </copy>
         <jar jarfile="${param.plugin.dir}/${param.plugin.targetJarFile}" basedir="${param.plugin.dir}/${build.dir}"/>
         <delete dir="${param.plugin.dir}/${build.dir}" quiet="true"/>
    </target>
    Since each of first 9 plugins contains less than 500 java source files, we always set "param.fork" to false when invoking this ant target.
    For the 10th plugin, it has about 1000 source files. If we set "param.fork" to false, we will get the error "Error running javac.exe compiler". So we have to set "param.fork" to true when compiling it. This week, this plugin contains about 1250 files and we get the same error again when compiling it. I tried to increase the "memoryMaximumSize" to "768", but still couldn't get through it.
    BTW, There are about 150 jar files in our classpath for compiling plugins. Do many jar files cause this problem?
    Any help is highly appreciated.
    Many thanks
    Oceanman

    I encountered a very similar error and I was able to resolve it by removing the following parameters from the javac task:
    fork="${param.fork}"
    memoryInitialSize="256m"
    memoryMaximumSize="512m"My values were not the same as yours, before I removed them, the values were set to:
    fork="true"
    memoryInitialSize="256m"
    memoryMaximumSize="256m" Not sure why this fixed my problem but it did. I was using Ant 1.7 and Java 1.6_07 hope this helps.

  • Export OSB configuration from eclipse using ant script

    I am trying to export an OSB project from eclipse using ant script
    I followed the link below http://biemond.blogspot.com/2010/07/osb-11g-ant-deployment-scripts.html
    It is using com.bea.alsb.core.ConfigExport to do the export. This export is always set to resource level.
    I see it generates a file ExportInfo setting some properties. It has a property that set the export level as below
    <imp:property name="projectLevelExport" value="false"/>*
    How can I export the project in project level? basically setting projectLevelExport to true?
    So that if a file does not exist in the sbconfig.jar file , then while importing the jar to OSB server it will delete the file from the server instead of skipping it?
    I appreciate any help
    here is the ant script snippet that gets executed to export from eclipse
    <target name="exportFromWorkspace">
         <delete failonerror="false" includeemptydirs="true"
    dir="${metadata.dir}"/>     
                   <!--eclipse.refreshLocal resource="${config.project}" depth="infinite"/-->
    <java dir="${eclipse.home}"
    jar="${eclipse.home}/plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar"
    fork="true" failonerror="true" maxmemory="768m">
    <jvmarg line="-XX:MaxPermSize=256m"/>
    <arg line="-data ${workspace.dir}"/>
    <arg line="-application com.bea.alsb.core.ConfigExport"/>
    <arg line="-configProject ${config.project}"/>
    <arg line="-configJar ${config.jar}"/>
    <arg line="-configSubProjects ${config.subprojects}"/>
              <arg line="-exportLevel true"/>
    <arg line="-includeDependencies ${config.includeDependencies}"/>
    <sysproperty key="weblogic.home" value="${weblogic.home}"/>
    <sysproperty key="osb.home" value="${osb.home}"/>
    <sysproperty key="osgi.bundlefile.limit" value="500"/>
    <sysproperty key="harvester.home" value="${osb.home}/harvester"/>
    <sysproperty key="osgi.nl" value="en_US"/>
    <sysproperty key="sun.lang.ClassLoader.allowArraySyntax" value="true"/>
    </java>
    </target>

    yes, I specified the project name to export the whole project.
    Here is few lines from my properties file
    # properties for workspace export
    config.project="OSB Configuration-GW"
    config.jar=D:/workspace/osb/scripts/gateway/mycode2/ant_osb/dist/sbconfig.jar
    config.subprojects="GatewaySecurity"
    config.includeDependencies=true
    workspace.dir=D:/workspace/osb/gateway-workspace
    But this property does not make it to export at project level ,it export the specified project at resource level.
    And while importing this jar to OSB server, if a file is missing it skips the file instead of deleting the file from the OSB server
    If I unjar sbconfig.jar file, open ExportInfo file and update the line in bold below to true then it deletes the file from OSB server, if not exist in sbconfig.jar
    <imp:property name="exporttime" value="Thu Dec 29 13:57:44 EST 2011"/>
    <imp:property name="productname" value="Oracle Service Bus"/>
    <imp:property name="productversion" value="11.1.1.4"/>
    *<imp:property name="projectLevelExport" value="false"/>*
    Here is few lines from Oracle API java doc
    http://docs.oracle.com/cd/E13171_01/alsb/docs26/javadoc/com/bea/wli/sb/management/importexport/ALSBImportOperation.Operation.html
    public static final ALSBImportOperation.Operation Delete
    Indicates that the resource is deleted in the importing domain. This is the default operation when the project is exported in its entirety and the resource exists in the target domain but not in the jar file
    public static final ALSBImportOperation.Operation Skip
    Indicates that the resource is skipped meaning the resource is not touched in the importing domain. This is the default operation if the jar file was exported at the resource level, and a resource that exists in the target domain, does not exist in the jar file.

  • Cannot make .war file using tomcat with eclipse and ant

    i have made all necesary configuration for deploying application using eclipse and ant for the tomcat server.
    when i start the server by clicking the tomcat icon on eclipse toolbar, the message is prompted that "missing application web.xml and using defaults". i have placed the web.xml file in the web/WEB-INF directory of the source project directory.
    also when i use ant by right-clicking on the build.xml file and choose Run as ant.. the process creates a desired .war file in webapps folder of the tomcat server but that war file does not works.
    where is the error i cannot figure out.
    am attaching the code of build.xml for reference.
    please help.
    build.xml:-
    <project name="BecilCTI" default="compile" basedir=".">
    <property file="build.properties"/>
    <property file="${user.home}/build.properties"/>
    <property name="app.name" value="BecilCTI"/>
    <property name="app.path" value="/${app.name}"/>
    <property name="app.version" value="0.1-dev"/>
    <property name="build.home" value="${basedir}/build"/>
    <property name="catalina.home" value="c:/Tomcat_5.5"/> <!-- UPDATE THIS! -->
    <property name="dist.home" value="${basedir}/dist"/>
    <property name="docs.home" value="${basedir}/docs"/>
    <property name="manager.url" value="http://localhost:8080/manager"/>
    <property name="src.home" value="${basedir}/src"/>
    <property name="web.home" value="${basedir}/web"/>
    <property name="compile.debug" value="true"/>
    <property name="compile.deprecation" value="false"/>
    <property name="compile.optimize" value="true"/>
    <!--<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>-->
    <path id="compile.classpath">
    <!-- Include all elements that Tomcat exposes to applications -->
    <pathelement location="${catalina.home}/common/classes"/>
    <fileset dir="${catalina.home}/common/endorsed">
    <include name="*.jar"/>
    </fileset>
    <fileset dir="${catalina.home}/common/lib">
    <include name="*.jar"/>
    </fileset>
    <pathelement location="${catalina.home}/shared/classes"/>
    <fileset dir="${catalina.home}/shared/lib">
    <include name="*.jar"/>
    </fileset>
    </path>
    <target name="all" depends="clean,compile"
    description="Clean build and dist directories, then compile"/>
    <target name="clean"
    description="Delete old build and dist directories">
         <echo message="Cleaning all dirs."/>
    <delete dir="${build.home}"/>
    <delete dir="${dist.home}"/>
    </target>
    <target name="compile" depends="prepare"
    description="Compile Java sources">
    <!-- Compile Java classes as necessary -->
    <mkdir dir="${build.home}/WEB-INF/classes"/>
    <javac srcdir="${src.home}"
    destdir="${build.home}/WEB-INF/classes"
    debug="${compile.debug}"
    deprecation="${compile.deprecation}"
    optimize="${compile.optimize}">
    <classpath refid="compile.classpath"/>
    </javac>
    <!-- Copy application resources -->
    <copy todir="${build.home}/WEB-INF/classes">
    <fileset dir="${src.home}" excludes="**/*.java"/>
    </copy>
    </target>
    <target name="dist" depends="compile"
    description="Create binary distribution">
    <!-- Copy documentation subdirectories
    <mkdir dir="${dist.home}/docs"/>
    <copy todir="${dist.home}/docs">
    <fileset dir="${docs.home}"/>
    </copy> -->
    <!-- Create application JAR file -->
    <jar jarfile="${catalina.home}/webapps/${app.name}.war"
    basedir="${build.home}"/>
    <!-- Copy additional files to ${dist.home} as necessary -->
    </target>
    <target name="install" depends="compile"
    description="Install application to servlet container">
    <deploy url="${manager.url}"
    username="${manager.username}"
    password="${manager.password}"
    path="${app.path}"
    localWar="file://${build.home}"/>
    </target>
    <target name="list"
    description="List installed applications on servlet container">
    <list url="${manager.url}"
    username="${manager.username}"
    password="${manager.password}"/>
    </target>
    <target name="prepare">
    <!-- Create build directories as needed -->
    <mkdir dir="${build.home}"/>
    <mkdir dir="${build.home}/WEB-INF"/>
    <mkdir dir="${build.home}/WEB-INF/classes"/>
    <!-- Copy static content of this web application -->
    <copy todir="${build.home}">
    <fileset dir="${web.home}"/>
    </copy>
    <mkdir dir="${build.home}/WEB-INF/lib"/>
    </target>
    <target name="reload" depends="compile"
    description="Reload application on servlet container">
    <reload url="${manager.url}"
    username="${manager.username}"
    password="${manager.password}"
    path="${app.path}"/>
    </target>
    <target name="remove"
    description="Remove application on servlet container">
    <undeploy url="${manager.url}"
    username="${manager.username}"
    password="${manager.password}"
    path="${app.path}"/>
    </target>
    </project>

    So is context.xml actually overwriting the settings found in server.xml?I think so. The way I understand it is the the context.xml file saves you from having to edit server.xml. It is preferred for each web app to do its own config, rather than lumping them all together in server.xml.
    And what would be the best way to create the war file? IAt its heart, a WAR is just a zip file with its contents laid out in according to the specification of a web application directory structure.
    So the simplest way to make a war file is to zip up your directory structure with a tool like winzip, and rename it to be myApp.war.
    Regarding ant, I would recommend you take a look through [url http://jakarta.apache.org/tomcat/tomcat-4.1-doc/appdev/index.html
    ]this tutorial. It explains the basics of website layout, configuration and deployment.
    On [url http://jakarta.apache.org/tomcat/tomcat-4.1-doc/appdev/source.html] this page  in particular, it includes a link to a basic ant file that you can use as a starting point.
    Cheers,
    evnafets

  • Ant in Eclipse Builds a Corrupt JAR

    When I build a JAR file in Eclipse using an Ant build file, the resulting JAR is corrupt. It cannot find the main class. Repairing the JAR using WinRAR fixes this issue. WinRAR reports repairing corrupt header information. This issue does not occur when manually exporting a JAR from Eclipse. In all cases, we are using the same manifest file. The Ant compile does not show any warnings or errors. The exact runtime error when executing the corrupt JAR is: "Could not find the main class. Program will exit."
    I am relatively new to Ant. I have searched the forums and google, but I have been unable to find anyone describing similar issues. I have spent three weeks trying to make this code work. None of the tutorials or FAQs I have found mention this issue, and none of the techniques they describe resolve it. Do you have any idea what might be causing this issue, or how to resolve it? The main reason I want to use Ant is to automate our build process. We can't do that if we have to manually repair the resulting JAR file after each build. I'm probably missing something obvious, but I don't have the Ant experience to know what that is. Any help would be greatly appreciated.
    Ant Version: 1.7
    Eclipse Version: 3.3.1.1
    Java Version: 1.6.0.3
    Platform: Windows XP (SP2)
    My build file (replacing my login with 'username' for privacy purposes):
    <?xml version="1.0" encoding="utf8"?>
    <project name="ecsMerlinJarBuild" default="MakeMerlinJar" basedir=".">
    <target name="Initialize" description="delete old .class files">
    <delete dir="JavaSource\com\ebsco\component" includes="*.class" />
    <delete dir="JavaSource\com\ebsco\core" includes="*.class" />
    <delete dir="JavaSource\com\ebsco\dao" includes="*.class" />
    <delete dir="JavaSource\com\ebsco\datatype" includes="*.class" />
    <delete dir="JavaSource\com\ebsco\dto" includes="*.class" />
    <delete dir="JavaSource\com\ebsco\interfaces" includes="*.class" />
    <delete dir="JavaSource\com\ebsco\module" includes="*.class" />
    <delete dir="JavaSource\com\ebsco\parents" includes="*.class" />
    <delete dir="JavaSource\com\ebsco\process" includes="*.class" />
    <delete dir="JavaSource\com\ebsco\screen" includes="*.class" />
    <delete dir="JavaSource\com\ebsco\util" includes="*.class" />
    <delete dir="JavaSource\com\ebsco\window" includes="*.class" />
    <delete dir="JavaSource\com\ebsco\windowwrapper" includes="*.class" />
    </target>
    <target name="Compile" description="Compile .java files">
    <javac srcdir="JavaSource\com" includes="ebsco\**\*.java" bootclasspath="C:\\Program Files\\Java\\jre1.6.0_03\\lib\\rt.jar" classpath="C:\\Documents and Settings\\username\\workspace\\merlin\\IBMLibraries.jar" />
    </target>
    <target name ="MakeMerlinJar" description="Create a jar for the Merlin project">
    <jar jarfile="Merlin.jar" excludes="*.jar, *.zip" manifest="MANIFEST.txt" update="true" duplicate="fail" >
    <zipfileset dir="JavaSource\com\ebsco\component" includes="*.class" prefix="com\ebsco\component" />
    <zipfileset dir="JavaSource\com\ebsco\core" includes="*.class" prefix="com\ebsco\core" />
    <zipfileset dir="JavaSource\com\ebsco\dao" includes="*.class" prefix="com\ebsco\dao" />
    <zipfileset dir="JavaSource\com\ebsco\datatype" includes="*.class" prefix="com\ebsco\datatype" />
    <zipfileset dir="JavaSource\com\ebsco\dto" includes="*.class" prefix="com\ebsco\dto" />
    <zipfileset dir="JavaSource\com\ebsco\interfaces" includes="*.class" prefix="com\ebsco\interfaces" />
    <zipfileset dir="JavaSource\com\ebsco\module" includes="*.class" prefix="com\ebsco\module" />
    <zipfileset dir="JavaSource\com\ebsco\parents" includes="*.class" prefix="com\ebsco\parents" />
    <zipfileset dir="JavaSource\com\ebsco\process" includes="*.class" prefix="com\ebsco\process" />
    <zipfileset dir="JavaSource\com\ebsco\screen" includes="*.class" prefix="com\ebsco\screen" />
    <zipfileset dir="JavaSource\com\ebsco\util" includes="*.class" prefix="com\ebsco\util" />
    <zipfileset dir="JavaSource\com\ebsco\window" includes="*.class" prefix="com\ebsco\window" />
    <zipfileset dir="JavaSource\com\ebsco\windowwrapper" includes="*.class" prefix="com\ebsco\windowwrapper" />
    <zipfileset dir="." includes=".classpath, .project, *.txt, *.xml" />
    </jar>
    </target>
    <target name="CopyJarFile" description="Copy the Merlin jar file to the set destination">
    <copy file="Merlin.jar" todir="C:\\Documents and Settings\\username\\Desktop\\JARs"/>
    </target>
    </project>

    And presumably that class actually exists? I can't see any reason why this build file wouldn't work, although I don't know why you're using zipfilesets. Maybe that's the problem. Another option is to export the jar from Eclipse, and ask it to generate an Ant script at the same time.
    But really, you ought to have a look at some [Ant tutorials|http://ant.apache.org/manual/index.html] , or better yet, get your company to buy a copy of [this book|http://www.amazon.co.uk/Java-Development-Ant-Erik-Hatcher/dp/1930110588/ref=sr_1_3?ie=UTF8&s=books&qid=1210364234&sr=8-3] because you're making more work for yourself than you need to here. For instance, you can use "**/*" to recursively include entire directory trees, rather than explicitly include each one

  • How to deploy jar file in WLS using ant script

    Hi,
    Im trying to deploy a jar file in weblogic 10.3 using ant script and am running into the below error.
    +[wldeploy] weblogic.management.DeploymentException: [J2EE:160177]The application at "/u01//RSJBObjects.jar" was not recognized as a valid application type. If this is an EAR file, please ensure the META-INF/application.xml exists. EJB-JARs should have a META-INF/ejb-jar.xml or corresponding annotations exist. If this is an exploded WAR, the name of directory must be end with ".war". RARs require a META-INF/ra.xml. A JMS deployment should be an XML file whose name ends with "-jms.xml". A JDBC deployment should be an XML file whose name ends with "-jdbc.xml". For other application types, please consult the WebLogic Server documentation.+
    When i try to deploy the same manually from the console, i get a warning stating that WLS thought this as a library and hence proceeding to deploy as a library. After this warning the deployment continues and completes.
    Problem is when i try to deploy using ant, it breaks at this point.
    Is there any means that we can deploy a jar to WLS using ant script. This has to be deployed as a library as other apps would be using this jar.
    Im unable to create a ear file for this single jar file.
    If there is any suggestion on can this be done, please share.
    Thanks,
    Vijay.

    Hi Sunil,
    Thanks for the reply, it worked.
    Another doubt on the same lines. Now that the jar has been deployed as a library in WLS, when i try to deploy a WAR which refers to this deployed jar library, im unable to. I run into and error stating that the library is inaccessible.
    I have to bounce the server and before doing that, i have to manually copy the library.jar from <WLS_domain>/servers/AdminServer/upload/ directory to <WLS_domain>/lib/ directory, once copied i then try to deploy the WAR, then the deployment goes fine.
    Is there any means that this deployed library jar be made available soon after deployment and also to avoid copying the file.
    Thanks,
    Vijay.

  • Updating a JAR that uses packages

    Hi There,
    I have a problem in that I am trying to update a class within a JAR which uses packages. The issue is that when updating the JAR, the class I have requested to update is simply placed in the root of the JAR and not in the required package.
    I need to to this within a Java program, so unpacking and re-packing the JAR is not an option.
    Here is what i've been trying:
    I have a class called UserProfile.class, which resides within my messages package - Structure: /messages/UserProfile.class
    When I call the update command:
    jar uf C:\AdminUI.jar E:\project\code\Eclipse_Proj\messages\UserProfile.class
    It creates the folder structure /project/code/Eclipse_Proj/messages within the JAR file and places UserProfile.class within this folder - when in fact the UserProfile.class should be placed within the /messages folder.
    Any ideas on how I can place the class in the correct folder would be much appreciated.
    Thanks very much
    K
    null

    Thanks for the reply!
    Yeah that works, but i'm trying to update the JAR from a Java program using
    Runtime.getRuntime().exec()
    but when I try to run the command Runtime.getRuntime().exec("cd c:") I get the below exception:
    java.io.IOException: CreateProcess: cd c: error=2
    I understand there is a -C parameter to temporarily change directory so I tried the following command:
    jar uf C:\AdminUI.jar -C E:\project\code\Eclipse_Proj \messages\UserProfile.class
    But this simply inserts the UserProfile.class into a jar under the following directory structure:
    project/code/Eclipse_Proj/messages/UserProfile.class
    Thanks again for your help.
    Any input much appreciated
    K

Maybe you are looking for

  • RG1 Register

    Dear Gurus I am trying to update RG1 register through T-code J1I5 for movement type 921. Table J_1RG1 get updated for this transaction. But when i use T-code J2I5 for Excise Register Extraction entry does not reflect in table J_2RG1BAL hence opening

  • Pie chart

    In Obiee 11g Pie chart based on hierarchy , once click on the pie chart it is going to next level , but if there is no result for the next level it has to be constant(no drill need's to happens) instead of that it displays like "Maching results not f

  • Adding a variable in a Message Popup

    Hi guys, how to get a local variable in a message Popup? I try "string text"+ Runstate.Caller.Locals.foo ... Coz runstate is while program is running, Caller is the calling step and then local variable. But this give an error. Where to access my loca

  • Pricing Condition Type Problem !!

    HI Pricing condition for CVD was maintained as fixed value(calculation Type) originally. Client wanted it to be percentage basis. I changed it to % basis. It was wrking fine. But today again when a PO was made for same material .... the CVD was comin

  • Conversion of character field to currency format

    Hi All I am reading an excel file witch has a netwr amount fiels as character type ,  but when I try to update the field table netwr which is CURR data type the program dumps sayin it can not do that becuase of the format . is there any way of conver