gotch4
gotch4

Reputation: 13259

Problems compiling Eclipse project with Ant

I created a reasonably big web project on Eclipse (8 months of work). I've been using Eclipse build system until now. Now I'd like to go to Ant for a number of reasons (among them, be able to add certain pre WAR tasks, like js compression and other...). I discovered that Eclipse creates a build.xml file automatically, with all dependencies set up. The problem is that if I try to run it, it fails and gives this error:

type parameters of <TypeName>TypeName cannot be determined; no unique maximal instance exists for type variable TypeName with upper bounds TypeName,java.lang.Object
    [javac]         return dao.getItemByProperty(propertyName, val, objectClass);

it besically dies beacause of an error with generics.... usually it compiles fine on Eclipse (I know it is a different compiler...). How can I have javac work with this??

The method is:

@Override
    @Transactional
    public <TypeName> TypeName getItemByProperty(String propertyName,
            Object val, Class objectClass) {
        return dao.getItemByProperty(propertyName, val, objectClass);
    }

and dao.getItem... is

@Override
    public <TypeName> TypeName getItemByProperty(String propertyName,
            Object val, Class objectClass) {

        Session sess = sessionFactory.getCurrentSession();
        Criteria criteria = sess.createCriteria(objectClass);
        criteria.add(Expression.eq(propertyName, val));
        @SuppressWarnings("unchecked")
        List<TypeName> results = criteria.list();

        if (results != null && results.size() != 0) {
            TypeName res = results.get(0);
            return res;
        }

        return null;
    }

they are in two classes that respectively implement two interface, the first for a service, the second for a dao and they are used in Spring.

Why is this happening? Is Eclipse compiler so different from javac?

Upvotes: 1

Views: 180

Answers (1)

bakoyaro
bakoyaro

Reputation: 2558

What version of Ant is actually being used, and which version of the compiler is being used? For a sanity check, try this at the command line where you are trying to run ant:

ant -v.

javac -v.

I ran into a similar situation once, where everything should work but didn't. Here Weblogic had an older version of both ant and javac than what I was trying to use, and these older version were being used instead of the ones I wanted. I ended up writing a script that explicitly set these variables in my PATH, and running the script before running the ant task.

Upvotes: 1

Related Questions