Junit Test failed: NamingContextFactory can't be instantiate
bertrand.njiipwo May 8, 2006 4:50 PMHello,
i a'm still trying to run the hello example in the JBPM-BPEL but still stucking.
All steps was successfull till the run-test with ant. Hier the Junit test can't run successfully because of the class NamingContextFactory that couldn't be found.
I become the following error when running "ant run-test" :
C:\OrdnerHyrarchie\MyCourses\Diplomarbeit\KOM\jBPM\Engine\jbpm-bpel-1.0-alpha4\doc\examples\hello>ant run-test Buildfile: build.xml compile-test: run-test: [junit] Testsuite: org.jbpm.bpel.tutorial.hello.HelloTest [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0,01 sec [junit] Testcase: testSayHello(org.jbpm.bpel.tutorial.hello.HelloTest):Caused an ERROR [junit] Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [junit] javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFound Exception: org.jnp.interfaces.NamingContextFactory] [junit] at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657) [junit] at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247) [junit] at javax.naming.InitialContext.init(InitialContext.java:223) [junit] at javax.naming.InitialContext.<init>(InitialContext.java:197) [junit] at org.jbpm.bpel.tutorial.hello.HelloTest.getInitialContext(HelloTest.java:43) [junit] at org.jbpm.bpel.tutorial.hello.HelloTest.setUp(HelloTest.java:21) [junit] Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory [junit] at java.net.URLClassLoader$1.run(URLClassLoader.java:200) [junit] at java.security.AccessController.doPrivileged(Native Method) [junit] at java.net.URLClassLoader.findClass(URLClassLoader.java:188) [junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:306) [junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:251) [junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:251) [junit] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) [junit] at java.lang.Class.forName0(Native Method) [junit] at java.lang.Class.forName(Class.java:242) [junit] at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42) [junit] at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654) [junit] ... 29 more [junit] Test org.jbpm.bpel.tutorial.hello.HelloTest FAILED BUILD SUCCESSFUL Total time: 1 second.
I have the following configurations:
MySQL Server.4.1.9,
jbpm-bpel-1.0-alpha4
JBoss AS 4.0.3SP1
jbpm-3.0.2
jwsdp-1.6
{JBPM.BPEL}/doc/examples/hello/jndi.properties:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.factory.url.pkgs=org.jboss.naming.client #java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces java.naming.provider.url=jnp://localhost:1099 #java.naming.provider.url=jnp://Bertrand:1099.
{JBPM.BPEL}/doc/examples/hello/build.xml :
<?xml version="1.0"?>
<project name="helloWorld" default="deploy-application" basedir=".">
<property file="build.properties"/>
<property name="build.dir" value="build"/>
<property name="definition.dir" value="definition"/>
<property name="web.dir" value="web"/>
<property name="client.dir" value="client"/>
<property name="application.dir" value="application"/>
<property name="test.dir" value="test"/>
<property name="jboss.server.dir" value="${jboss.home}/server/${jboss.server}"/>
<!-- ================= -->
<!-- === CLASSPATH === -->
<!-- ================= -->
<path id="webtask.classpath">
<pathelement location="${jbpm.bpel.home}/build/jbpm-bpel-${jbpm.bpel.version}.jar"/>
</path>
<path id="servicegen.classpath">
<pathelement path="${basedir}"/>
<pathelement location="${jbpm.bpel.home}/build/jbpm-bpel-${jbpm.bpel.version}.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/jbpm/jbpm-${jbpm.version}.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/wsdl4j/wsdl4j-1.4.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/commons/commons-collections-2.1.1.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/commons/commons-lang-2.1.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/commons/commons-logging-1.0.4.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/log4j/log4j-1.2.11.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/jaxen/jaxen-1.1-beta-7.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/hibernate/dom4j-1.6.1.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/j2ee/qname.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/j2ee/saaj.jar"/>
<!-- uncomment to replace the TrAX implementation in JSE 1.5.0
<pathelement location="${jbpm.bpel.home}/lib/xalan/xalan-2.6.0.jar"/>
-->
</path>
<path id="test.classpath">
<pathelement path="${basedir}"/>
<pathelement location="${jboss.home}/client/jboss-ws4ee-client.jar"/>
<pathelement location="${jboss.home}/client/axis-ws4ee.jar"/>
<pathelement location="${jboss.home}/client/commons-discovery.jar"/>
<pathelement location="${jboss.home}/client/activation.jar"/>
<pathelement location="${jboss.home}/client/wsdl4j.jar"/>
<pathelement location="${jboss.home}/client/log4j.jar"/>
<pathelement location="${jboss.home}/client/commons-logging.jar"/>
<pathelement location="${jboss.home}/client/jnp-client.jar"/>
<pathelement location="${jboss.home}/client/jboss-j2ee.jar"/>
<pathelement location="${jboss.home}/client/jbossall-client.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/JBossadditionLib/jbosscx-client.jar"/>
<pathelement location="${jboss.home}/client/jboss-client.jar"/>
<pathelement location="${jboss.home}/client/jbossmq-client.jar"/>
<pathelement location="${jboss.home}/client/jbosssx-client.jar"/>
<pathelement location="${jboss.home}/client/jboss-common-client.jar"/>
<pathelement location="${jboss.home}/client/jboss-system-client.jar"/>
<pathelement location="${jboss.home}/client/jboss-ws4ee-client.jar"/>
<pathelement location="${jboss.home}/client/jboss-system-client.jar"/>
<pathelement location="${jboss.home}/client/jbossjmx-ant.jar"/>
<pathelement location="${jboss.home}/client/jboss-iiop-client.jar"/>
<pathelement location="${jboss.home}/client/jbossha-client.jar"/>
<pathelement location="${jboss.home}/client/jboss-aop-jdk50-client.jar"/>
<!-- Added from Bertrand -->
<pathelement location="${jbpm.bpel.home}/lib/Lib4JWSDP/dom.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/Lib4JWSDP/jaxp-api.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/Lib4JWSDP/jax-qname.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/Lib4JWSDP/jaxrpc-api.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/Lib4JWSDP/jaxrpc-impl.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/Lib4JWSDP/jaxrpc-spi.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/Lib4JWSDP/mail.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/Lib4JWSDP/namespace.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/Lib4JWSDP/relaxngDatatype.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/Lib4JWSDP/saaj-api.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/Lib4JWSDP/saaj-impl.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/Lib4JWSDP/sax.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/Lib4JWSDP/xalan.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/Lib4JWSDP/xercesImpl.jar"/>
<pathelement location="${jbpm.bpel.home}/lib/Lib4JWSDP/xsdlib.jar"/>
<!-- Added from Bertrand -->
</path>
<!-- ================ -->
<!-- TASK DEFINITIONS -->
<!-- ================ -->
<taskdef name="webdbschema" classname="org.jbpm.bpel.ant.WebDBSchemaTask">
<classpath refid="webtask.classpath"/>
</taskdef>
<taskdef name="webdeploy" classname="org.jbpm.bpel.ant.WebDeployTask">
<classpath refid="webtask.classpath"/>
</taskdef>
<taskdef name="servicegen" classname="org.jbpm.bpel.ant.ServiceGeneratorTask">
<classpath refid="servicegen.classpath"/>
</taskdef>
<!-- ======================= -->
<!-- === DATABASE SCHEMA === -->
<!-- ======================= -->
<target name="create-schema" description="creates the jbpm tables">
<webdbschema operation="create"/>
</target>
<!-- ==================================== -->
<!-- === PROCESS DEFINITION PACKAGING === -->
<!-- ==================================== -->
<target name="pack-definition">
<mkdir dir="${build.dir}"/>
<jar destfile="${build.dir}/hello-definition.par">
<fileset dir="${definition.dir}">
<include name="hello.bpel"/>
<include name="hello.wsdl"/>
</fileset>
<zipfileset dir="${definition.dir}" prefix="META-INF">
<include name="bpel-definition.xml"/>
</zipfileset>
</jar>
</target>
<!-- ================================== -->
<!-- === PROCESS ARCHIVE DEPLOYMENT === -->
<!-- ================================== -->
<target name="deploy-definition" depends="pack-definition" description="deploys the process archive">
<webdeploy par="${basedir}/${build.dir}/hello-definition.par"/>
</target>
<!-- =============================== -->
<!-- === WSDL SERVICE GENERATION === -->
<!-- =============================== -->
<target name="generate-service" depends="pack-definition" description="generate wsdl service document">
<servicegen processfile="${basedir}/${build.dir}/hello-definition.par" outputdir="${basedir}/${web.dir}/wsdl"/>
</target>
<!-- =================================== -->
<!-- === SERVER ARTIFACTS GENERATION === -->
<!-- =================================== -->
<target name="wscompile" if="wsdp.home" description="generates ws4ee server artifacts">
<mkdir dir="${web.dir}/src"/>
<mkdir dir="${web.dir}/classes"/>
<java classname="LauncherBootstrap" dir="${web.dir}" fork="yes">
<classpath>
<pathelement path="${wsdp.home}/jwsdp-shared/bin"/>
</classpath>
<arg line="wscompile"/>
<arg line="-import"/>
<arg line="-keep"/>
<arg line="-d classes"/>
<arg line="-s src"/>
<arg line="-mapping jaxrpc-mapping.xml"/>
<arg line="-f:norpcstructures,wsi,strict"/>
<arg line="wscompile-cfg.xml"/>
</java>
<copy file="${web.dir}/jaxrpc-mapping.xml" todir="${client.dir}"/>
<copy todir="${test.dir}/src">
<fileset dir="${web.dir}/src" includes="**/*.java" excludes="**/*_Impl.java"/>
</copy>
</target>
<!-- ================================= -->
<!-- === WEB APPLICATION PACKAGING === -->
<!-- ================================= -->
<target name="pack-web">
<mkdir dir="${build.dir}"/>
<jar destfile="${build.dir}/hello-web.war">
<zipfileset dir="${web.dir}" prefix="WEB-INF">
<exclude name="src/**"/>
<exclude name="wscompile-cfg.xml"/>
</zipfileset>
<zipfileset dir="." prefix="WEB-INF/classes" includes="jbpm.properties"/>
</jar>
</target>
<!-- ==================================== -->
<!-- === APPLICATION CLIENT PACKAGING === -->
<!-- ==================================== -->
<target name="pack-client">
<mkdir dir="${build.dir}"/>
<jar destfile="${build.dir}/hello-client.jar">
<zipfileset dir="${client.dir}" prefix="META-INF"/>
</jar>
</target>
<!-- ============================= -->
<!-- === APPLICATION PACKAGING === -->
<!-- ============================= -->
<target name="pack-application" depends="pack-web, pack-client">
<jar destfile="${build.dir}/hello-application.ear">
<zipfileset dir="${application.dir}" prefix="META-INF"/>
<zipfileset dir="${build.dir}">
<include name="hello-web.war"/>
<include name="hello-client.jar"/>
</zipfileset>
</jar>
</target>
<!-- ====================================== -->
<!-- === APPLICATION DEPLOYMENT (JBOSS) === -->
<!-- ====================================== -->
<target name="deploy-application" depends="pack-application" description="deploys the bpel application">
<copy file="${build.dir}/hello-application.ear" todir="${jboss.server.dir}/deploy"/>
</target>
<target name="undeploy-application">
<delete file="${jboss.server.dir}/deploy/hello-application.ear"/>
</target>
<!-- ============================= -->
<!-- === TEST CLIENT EXECUTION === -->
<!-- ============================= -->
<target name="compile-test">
<mkdir dir="${test.dir}/classes"/>
<javac srcdir="${test.dir}/src" destdir="${test.dir}/classes" debug="on">
<classpath refid="test.classpath"/>
</javac>
</target>
<target name="run-test" depends="compile-test" description="executes the test client">
<junit>
<classpath>
<path refid="test.classpath"/>
<pathelement path="${test.dir}/classes"/>
</classpath>
<formatter type="brief" usefile="no"/>
<test name="org.jbpm.bpel.tutorial.hello.HelloTest"/>
</junit>
</target>
<!-- =============== -->
<!-- === CLEANUP === -->
<!-- =============== -->
<target name="clean" description="removes all generated files">
<delete failonerror="no" includeemptydirs="yes">
<fileset dir="${build.dir}"/>
<fileset dir="${web.dir}/classes"/>
<fileset dir="${web.dir}/src"/>
<fileset dir="${web.dir}/wsdl"/>
<fileset dir="${web.dir}" includes="jaxrpc-mapping.xml"/>
<fileset dir="${test.dir}/classes"/>
</delete>
</target>
</project>
. As you can see i have added the most JBoss clien libraries on the build-Path but the problem can't be solved. This seems to be a general problem deploying Services to JBoss and one than more user encounter this problem most of time related to the *.client.jar files and the JNDI-propertie file. Through google i can't lose the problem that's wy this new thread.
Is there some on who know why the org.jnp.interfaces.NamingContextFactory can't be found ? I'll be very greatfull for a solution approach.
Thanks in Advance
Njipwo Bertrand