You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Jochen Wiedmann <jo...@freenet.de> on 2004/07/02 11:25:55 UTC

Unresolved compilation problem - why?

Hi,

I have a custom Ant task, that works with reflection. The Ant task is loaded 
over a ClassLoader created with the "path" type. Now, my code looks like this:

     // The ClassLoader is the AntClassLoader used to load the custom Ant
     // task. It is also used to instantiate the class pClass.
     ClassLoader cl = pClass.getClassLoader();
     try {
         cl.loadClass("com.sag.justus.vo.Schema");
         System.err.println("Successful load of Schema class");
     } catch (Throwable t) {
         t.printStackTrace();
     }
     try {
         pClass.newInstance();
         System.err.println("Successful instantiation");
     } catch (Throwable t) {
         t.printStackTrace();
     }

The output looks as follows. Note, that the output claims, that the class 
com.sag.justus.vo.Schema cannot be imported into the constructor of pClass, 
although that classes ClassLoader can very well load that class.

Any ideas, what might be wrong? Or what I can do for further debugging the 
problem?


Jochen


     [jaxme] Successful load of Schema class
     [jaxme] java.lang.Error: Unresolved compilation problems:
     [jaxme]     The import com.sag.justus.vo.Schema cannot be resolved
     [jaxme]     Schema cannot be resolved
     [jaxme]     Schema cannot be resolved
     [jaxme]     Schema cannot be resolved
     [jaxme]     Schema cannot be resolved

     [jaxme]     at 
com.sag.justus.server.query.view.QueryOffeneStatistikFG.<init>(QueryOffeneStatistikFG.java:6)
     [jaxme]     at 
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     [jaxme]     at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
     [jaxme]     at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
     [jaxme]     at 
java.lang.reflect.Constructor.newInstance(Constructor.java:274)
     [jaxme]     at java.lang.Class.newInstance0(Class.java:308)
     [jaxme]     at java.lang.Class.newInstance(Class.java:261)
     [jaxme]     at 
com.sag.justus.generator.QuerySchemaReader.getElement(QuerySchemaReader.java:68)

Die unterste Zeile ist der obige Quelltext. Mit anderen Worten: Ich kann 
über den ClassLoader die Klasse Schema laden. Ich kann aber nicht beim 
Instanziieren der Klasse über den selben ClassLoader dieselbe Klasse 
importieren?


Gruß,

Jochen


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Unresolved compilation problem - why?

Posted by Stefan Bodewig <bo...@apache.org>.
On Fri, 02 Jul 2004, Jochen Wiedmann <jo...@freenet.de>
wrote:

> Any ideas, what might be wrong? Or what I can do for further
> debugging the problem?

Run "ant -debug" this will give you an idea of which class is being
loaded by which classloader.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org