aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes unable to create War using Ant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "unable to create War using Ant" Watch "unable to create War using Ant" New topic
Author

unable to create War using Ant

Mark Kafe
Ranch Hand

Joined: Jun 23, 2008
Posts: 60

hi
i m new to ant, i create build file for creating war file but i have not make it proper.


please any body can give me sample build.xml file for war files
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5779
    
    7

We are not a code mill. Please post your build.xml and we will help you fix it. Make sure you embed the build.xml within 'code' tags (select the text and click the Code button above the editor window,)


JBoss In Action
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29275
    
140

Also please share the error message you got when running it.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Mark Kafe
Ranch Hand

Joined: Jun 23, 2008
Posts: 60

thanks for your reply

I do it....................

Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5779
    
    7

I do it....................


Do what? Post the information we asked for? Fix the problem? If you fixed the problem, it would be nice if you posted the solution so that when other ranchers come across your post they can also see the solution.
Mark Kafe
Ranch Hand

Joined: Jun 23, 2008
Posts: 60

Hi Peter Johnson,
i fix the problem, first time i make ant file.

here the Build.xml file


Mark Kafe
Ranch Hand

Joined: Jun 23, 2008
Posts: 60

But know i have three projects i want to compile all projects in one Build.xml
file throguh Ant if any one have any idea about this please tell me...............
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5779
    
    7

One possibility: add a target that does an antcall for each project. Something like this:



A few caveats:
I haven't run the above code, it could have syntax errors.
You have to supply the app name and base directories.
You might have to set inheritaAll to false (see the Ant docs for the antcall task).

The general idea here is that your build.xml file should be written so that is is generic and can build an web app (in this case) with the only thing you need to supply if the location of the files and name for the WAR.
Mark Kafe
Ranch Hand

Joined: Jun 23, 2008
Posts: 60

hey i want to create Jar file from a Data services Projects.i means hibernate project that have HBM.XML files but i have no idea how i add hbm.xml files in jar file..........please any body help me

i try this way



but its not working..........
because i have hbml.xml files in src folder but how it adds in jar file i have no idea.........................
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5779
    
    7

What you posted is the javac which is used to compile java source files - it doesn't do anything with hbm files. Since you are gathering all of the JAR file contents into a jar directory, I suggest copying the hmb file there before the jar task (on line 41 of the build.xml you posted). Something like this:


Also, you should change the destdir for the javac task to be "${basedir}/jar/" otherwise your classes will be in the wrong location in the JAR file.
Mark Kafe
Ranch Hand

Joined: Jun 23, 2008
Posts: 60

thnx Peter Johnson now its working fine........all hbm file add in packages.........

i also make war files frm ant build but some jar missing errors when i deploy it on tomcat..........please can you check it, where mistake in code...............

Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

You are not using the war task here? And what is the error ?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Mark Kafe
Ranch Hand

Joined: Jun 23, 2008
Posts: 60

thnx all for yours reply.............

this error when i deploy war file in tomcat........

SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory;" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, com/sun/faces/config/ConfigureListener, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ExpressionFactory used in the signature
at com.sun.faces.config.ConfigureListener.registerELResolverAndListenerWithJsp(ConfigureListener.java:1628)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:453)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:850)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:724)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:493)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Jul 27, 2009 1:43:25 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

It sounds like you might be deploying with a conflicting library to that on Tomcat, what Jars are bundled up in your WAR?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Mark Kafe
Ranch Hand

Joined: Jun 23, 2008
Posts: 60

yaa its jar problems i add el-api.jar files when i create WAR file and this jar file also in tomcat lib folder............now i remove it from war files and now its working fine...............
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Great to hear!
Mark Kafe
Ranch Hand

Joined: Jun 23, 2008
Posts: 60

i make jar file wirh ANT Build..........here the code that i use for this build





but i want to debug classes that have in jar files...........Now its only .classes files ............
can any way that i also add . java files also and when i want to debug class its working fine???
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Your debugger should be able o step through .class files. What debugger are you using?
Mark Kafe
Ranch Hand

Joined: Jun 23, 2008
Posts: 60

i use MyEclipse 7.1 IDE and also use MyEclipse debugger.......................
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

In that case you should be able to attach the debugger to the debug potr of your server/application and debug normally. You just need to make sure that in Eclipse you have the source code for the 3rd party lib referenced in your libraries section (in short, check the libs you have in the classpath of your project in eclipse, for each lib you can right click and attach the source code zip - which you will have downloaded)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: unable to create War using Ant
 
Similar Threads
.war
Building a .WAR file
Eclipse - exporting files in WAR file
Running JSP in Tomcat 5.5
How to make a jar file of web application