This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in building project using Ant build tool

 
Santosh Ganapa
Ranch Hand
Posts: 32
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34371
345
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have the struts jar in the classpath? Maybe you could show some code?
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And show the output from the ant build...
 
Santosh Ganapa
Ranch Hand
Posts: 32
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you setting the classpath in your build.xml? Post the file contents here.
 
Santosh Ganapa
Ranch Hand
Posts: 32
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my build.xml file contents...Please suggest me about what is the actual problem here with possible solution.



 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 32
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 32
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic