I've run into the following problem running the JUnit task in Ant:

Cannot instantiate class: org.jnp.interfaces.NamingContextFactory
javax.naming.NoInitialContextException: Cannot instantiate class: 
org.jnp.interfaces.NamingContextFactory.  Root exception is java
.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
         at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

[ I've clipped the rest of the backtrace. ]

The class: "org.jnp.interfaces.NamingContextFactory" DOES exist in the 
"/usr/local/jboss/2.4.4b/jboss/client/jnp-client.jar" JAR file included 
in the classpath below.

I've run Ant in verbose mode and in fact the classpath is correct at 
runtime.

I have the following task definition:

        <target name="run_tests" depends="jar,jar_tests,jar_cuilla">
                <junit printsummary="on">
                        <sysproperty key="java.naming.provider.url" value="localhost"/>
                        <sysproperty key="java.naming.factory.initial" 
value="org.jnp.interfaces.NamingContextFactory"/>

                        <classpath>
                                <!-- Xerces/Xalan (XML parser/XSLT transformer) -->
                                <pathelement 
path="/Users/ccuilla/Developer/SDK/XML/Xerces/1.4.4/xerces.jar"/>
                                <pathelement 
path="/Users/ccuilla/Developer/SDK/XML/Xalan/2.0.1/bin/xalan.jar"/>

                                <!-- XBeans -->
                                <pathelement 
path="/Users/ccuilla/Developer/SDK/XML/XBeans/2.0.0b/lib/xbeans.jar"/>

                                <!-- JMS -->
                                <pathelement 
path="/Users/ccuilla/Developer/SDK/JMS/1.0.2b/lib/jms.jar"/>

                                <!-- JNDI -->
                                <pathelement 
path="/Users/ccuilla/Developer/SDK/JNDI/1.2.0/lib/jndi.jar"/>
                                <!-- <pathelement 
path="/Users/ccuilla/Developer/SDK/JNDI/1.2.0/lib/providerutil.jar"/> -->

                                <!-- JavaMail -->
                                <pathelement 
path="/Users/ccuilla/Developer/SDK/JavaMail/activation.jar"/>
                                <pathelement 
path="/Users/ccuilla/Developer/SDK/JavaMail/1.2.0/lib/mail.jar"/>

                                <!-- JUnit -->
                                <pathelement 
path="/Users/ccuilla/Developer/Tools/JUnit/3.7/junit.jar"/>

                                <!-- JBoss (required to run the JMS tests) -->
                                <pathelement 
path="/usr/local/jboss/2.4.4b/jboss/client/jnp-client.jar"/>
                                <pathelement 
path="/usr/local/jboss/2.4.4b/jboss/client/jbossmq-client.jar"/>
                                <pathelement 
path="/usr/local/jboss/2.4.4b/jboss/client/jbosssx-client.jar"/>
                                <pathelement 
path="/usr/local/jboss/2.4.4b/jboss/client/jaas.jar"/>
                                <pathelement 
path="/usr/local/jboss/2.4.4b/jboss/client/jboss-j2ee.jar"/>
                                <pathelement 
path="/usr/local/jboss/2.4.4b/jboss/client/jboss-client.jar"/>
                                <pathelement 
path="/usr/local/jboss/2.4.4b/jboss/client/log4j.jar"/>

                                <!-- our stuff -->
                                <pathelement path="${directory.lib}/cuilla.jar"/>
                                <pathelement path="${directory.lib}/tests.jar"/>
                                <pathelement path="${directory.lib}/${name}.jar"/>
                        </classpath>

                        <test name="com.client.notification.tests.ALL">
                                <formatter type="plain"/>
                        </test>
                </junit>
        </target>

Some other details:

        OS: MacOS X 10.1.2
        JDK:    1.3.1
        Ant: 1.4.1
        JUnit: 3.7

The funny thing is that I have a couple of test shell scripts that do a 
JMS send and receive (that's what I'm trying to test here) and they use 
the exact same classpath and they work just fine.

I am baffled here. Why does JUnit/Ant NOT find the class?

Any clues would be great.

Chris


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to