1

When trying to build my Struts Application, I get the following error :

compile:
    [javac] /media/Data/Struts 2/2012-05-02/Struts/src/Build.xml:5: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 2 source files
    [javac] MyAction.java:5: package org.apache.struts2.interceptor does not exist
    [javac] import org.apache.struts2.interceptor.SessionAware;
    [javac]                                      ^
    [javac] MyAction.java:7: package com.opensymphony.xwork2 does not exist
    [javac] import com.opensymphony.xwork2.ActionSupport;
    [javac]                               ^
    [javac] MyAction.java:10: cannot find symbol
    [javac] symbol: class ActionSupport
    [javac] public class MyAction extends ActionSupport implements SessionAware {
    [javac]                               ^
    [javac] MyAction.java:10: cannot find symbol
    [javac] symbol: class SessionAware
    [javac] public class MyAction extends ActionSupport implements SessionAware {
    [javac]                                                        ^
    [javac] MyAction.java:22: cannot find symbol
    [javac] symbol  : method addActionError(java.lang.String)
    [javac] location: class com.sp.action.MyAction
    [javac]         addActionError("invalid");
    [javac]         ^
    [javac] MyAction.java:47: cannot find symbol
    [javac] symbol  : method addActionError(java.lang.String)
    [javac] location: class com.sp.action.MyAction
    [javac]             addActionError("User Name ,pass cannot be error");
    [javac]             ^
    [javac] MyAction.java:43: method does not override or implement a method from a supertype
    [javac]     @Override
    [javac]     ^
    [javac] 7 errors

BUILD FAILED

My package hierarchy is src/com/sp/action/*.java and src/com/sp/domain/*.java

My build file is as follows :

<?xml version="1.0" encoding="UTF-8"?>
<project name="strutsComple" default="compile">
    <target name="compile">
        <fileset dir="/media/Data/Works/struts-2.3.1.2/lib/" includes="*.jar"/>
        <javac srcdir="./com/sp/"/>
    </target>
</project>

I have already added the two required jars to my Eclipse folder.

Can someone please point me towards what I am missing ?

Ashutosh Jindal
  • 18,501
  • 4
  • 62
  • 91
Razor
  • 23
  • 7

1 Answers1

1

Your ant build file is too simple. Importing the struts jars into eclipse does nothing for your ant build. You need to configure a classpath for javac in build.xml.

<fileset dir="/media/Data/Works/struts-2.3.1.2/lib/" includes="*.jar"/>
<javac srcdir="./com/sp/"/>

should become

<javac srcdir="./com/sp/">
    <classpath>
        <fileset dir="/media/Data/Works/struts-2.3.1.2/lib/" includes="*.jar"/>
    </classpath>
</javac>

See this answer for another example Getting Ant <javac> to recognise a classpath

See also the doc for the javac task.

Community
  • 1
  • 1
John Watts
  • 8,717
  • 1
  • 31
  • 35
  • dyac! I often write answers on my mobile phone. Apparently, javac auto-corrected to JavaScript (not that anyone would capitalize the 'S'). – John Watts Aug 17 '12 at 14:01
  • Thank you very much and I really appreciated the help you gave thanks a lot mate.. :D and even you use mobile it clear no need to bother at all friend – Razor Aug 17 '12 at 14:11
  • @JohnWatts Haha, I know all to well the powers of auto-correct. – Steven Benitez Aug 17 '12 at 14:57