aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Problem in building project using Ant build tool 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 "Problem in building project using Ant build tool" Watch "Problem in building project using Ant build tool" New topic
Author

Problem in building project using Ant build tool

Santosh Ganapa
Greenhorn

Joined: Mar 27, 2011
Posts: 22

Hello guys,

I am developing a web application using struts framework.I have all the java source files and resource files.I am trying to use Ant build tool ,but its reporting me errors about compilation like cannot find symbol ActionErrors, Action etc..I think the problem is in build.xml which is unable to include .jar files.

So please help me to solve these problems.

Thanks in advance.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29287
    
140

Do you have the struts jar in the classpath? Maybe you could show some code?


[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
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5779
    
    7

And show the output from the ant build...


JBoss In Action
Santosh Ganapa
Greenhorn

Joined: Mar 27, 2011
Posts: 22

Here is an output error i am getting:-
C:\tomcat6\webapps\blank\WEB-INF\src>ant
Buildfile: build.xml

clean:
[delete] Deleting directory C:\tomcat6\webapps\blank\WEB-INF\classes
[mkdir] Created dir: C:\tomcat6\webapps\blank\WEB-INF\classes

prepare:

resources:
[copy] Copying 1 file to C:\tomcat6\webapps\blank\WEB-INF\classes

compile:
[javac] Compiling 2 source files to C:\tomcat6\webapps\blank\WEB-INF\classes
[javac] C:\tomcat6\webapps\blank\WEB-INF\src\java\mybank\app1\CustomerAction.java:3: cannot find symbol
[javac] symbol: class Action
[javac] public class CustomerAction extends Action {
[javac] ^
[javac] C:\tomcat6\webapps\blank\WEB-INF\src\java\mybank\app1\CustomerAction.java:5: cannot find symbol
[javac] symbol : class ActionMapping
[javac] location: class CustomerAction
[javac] public ActionForward execute(ActionMapping mapping,
[javac] ^
[javac] C:\tomcat6\webapps\blank\WEB-INF\src\java\mybank\app1\CustomerAction.java:6: cannot find symbol
[javac] symbol : class ActionForm
[javac] location: class CustomerAction
[javac] ActionForm form, HttpServletRequest request,
[javac] ^
[javac] C:\tomcat6\webapps\blank\WEB-INF\src\java\mybank\app1\CustomerAction.java:6: cannot find symbol
[javac] symbol : class HttpServletRequest
[javac] location: class CustomerAction
[javac] ActionForm form, HttpServletRequest request,
[javac] ^
[javac] C:\tomcat6\webapps\blank\WEB-INF\src\java\mybank\app1\CustomerAction.java:7: cannot find symbol
[javac] symbol : class HttpServletResponse
[javac] location: class CustomerAction
[javac] HttpServletResponse response) throws Exception
[javac] ^
[javac] C:\tomcat6\webapps\blank\WEB-INF\src\java\mybank\app1\CustomerAction.java:5: cannot find symbol
[javac] symbol : class ActionForward
[javac] location: class CustomerAction
[javac] public ActionForward execute(ActionMapping mapping,
[javac] ^
[javac] C:\tomcat6\webapps\blank\WEB-INF\src\java\mybank\app1\CustomerForm.java:3: cannot find symbol
[javac] symbol: class ActionForm
[javac] public class CustomerForm extends ActionForm {
[javac] ^
[javac] C:\tomcat6\webapps\blank\WEB-INF\src\java\mybank\app1\CustomerAction.java:18: cannot find symbol
[javac] symbol : class ActionForward
[javac] location: class CustomerAction
[javac] ActionForward forward = mapping.findForward("success");
[javac] ^
[javac] 8 errors

BUILD FAILED
C:\tomcat6\webapps\blank\WEB-INF\src\build.xml:55: Compile failed; see the compiler error output for details.

Total time: 6 seconds



I have already set the cclasspath for jar files....
Please provide help..
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
How are you setting the classpath in your build.xml? Post the file contents here.


Ping & DNS - updated with new look and Ping home screen widget
Santosh Ganapa
Greenhorn

Joined: Mar 27, 2011
Posts: 22

Here is my build.xml file contents...Please suggest me about what is the actual problem here with possible solution.



Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5779
    
    7

I am guessing that the issue is not with the build.xml file but rather with CustomerAction.java. I suspect that you do not have an import statement for the Action class. Could you post the beginning of the CustomerAction.java file, up to the class declaration (which according to the error message is on line 3).

Based on the other error messages, you are missing a number of import statements.
Santosh Ganapa
Greenhorn

Joined: Mar 27, 2011
Posts: 22

First of all thanks Mr.Peter for your prompt reply...

I added necessary import statements in the CustomerAction.java file as you suggested, it worked fine.But I am still getting errors as:-



Please provide solution...

Code snippet for CustomerAction.java is as follow:-

Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5779
    
    7

You buildscript does not include the servlet JAR in the classpath. The JAR is declared at line 05, but is not included anywhere in lines 24-30, which define the compile.classpath.

Or wait a second, lines 05 and 06 are mixed up - the servlet line (05) references the jdbc jar, while the jdbc line (06) references servlet jar. You should clean that up also.
Santosh Ganapa
Greenhorn

Joined: Mar 27, 2011
Posts: 22

Hurray I got success.......

Thanks a lot Mr. Peter for your valuable time and guidance.

Final build file with suggested changes is:-


And output is:-



I am very Happy....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in building project using Ant build tool
 
Similar Threads
stream corrupted exception weblogic 6.1
HOW TO SET PATH IN TOMCAT OF ANT BUILDER
Problem using ant to build Tapestry
new to ANT
Popular IDE for Struts