ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <ste...@apache.org>
Subject Re: No class Def Error
Date Tue, 02 Oct 2007 09:26:02 GMT
Ramu Sethu wrote:
> Hi all
> 
> 'Tried my best to solve this problem on my own, but i couldn't solve it. so
> asking the experts
> I will summarize again my problem. We have a class path ref which refers to
> jboss-all-client jar and other dependent jars. I am using this class path
> ref in two places
> In junit task and in my custom task definition
> The process(lookup) what i do with the classes in jboss-all-client.jar is
> same in both the places.
> Junit task works perfectly as i expected.
> But my custom task throws the below exception
> 
> MyTask] javax.naming.NoInitialContextException: Cannot instantiate
> class: org.jnp.interfaces.NamingContextFactory
> Root exception is java.lang.ClassNotFoundException:
> org.jnp.interfaces.NamingContextFactory
> 
> (Full trace below)
> 
> I solved this problem temporarily by adding the jboss-all-client.jar in
> system classpath variable.
> 
> Why do i face this problem? whats worng here? when it is working in junit
> task why not in custom task?
> Any thing i can do in the custom task do avoid this problem?

that sounds like the perennial classloader hierarchy problem. The JNDI 
libs are looking for some class in the system classpath, not lower down. 
So when you call some JNDI method, it goes 
Class.forName("org.jnp.interfaces.NamingContextFactory"). For it, there 
is no class.

I'm not sure there is an easy fix here. Its a weakness of a lot of the 
central java apis that have the 'factory' pattern: xml parsers,  URL 
handlers, java.util.logging, etc.

Could your custom code run in a separate process, rather than just a 
custom task? your custom task would create a Java class instance and 
configure it to run the program; results can be passed back via some 
file (property files the easiest, XML files the most complex).

-steve
-- 
Steve Loughran                  http://www.1060.org/blogxter/publish/5
Author: Ant in Action           http://antbook.org/

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


Mime
View raw message