Hi,
I am trying to run a
test class for a session bean from
ant. It contains the following code for embedding the
jboss.
EJBContainer ejbC = EJBContainer.createEJBContainer();
Context ctx = ejbC.getContext();
AcmeFinance testObject;
public AcmeFinanceTest()
{
try{
testObject = (AcmeFinance) ctx.lookup("java:global//AcmeFinance");
}catch(Exception e){}
}
It shows the following exception on the red line above:
java.lang.reflect.InvocationTargetException
javax.ejb.EJBException: java.lang.reflect.InvocationTargetException
at org.jboss.ejb3.embedded.impl.standalone.JBossStandaloneEJBContainerProvider.createEJBContainer(JBossStandaloneEJBContainerProvider.java:153)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:93)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:75)
at com.acme.test.AcmeFinanceTest.<init>(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at org.jboss.ejb3.embedded.impl.standalone.JBossStandaloneEJBContainerProvider.createEJBContainer(JBossStandaloneEJBContainerProvider.java:141)
Caused by: java.lang.RuntimeException: Found .class on ClassPath which could not be found by the TCCL
at org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner.containsEjbComponentClass(ClassPathEjbJarScanner.java:371)
at org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner.containsEjbComponentClass(ClassPathEjbJarScanner.java:349)
at org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner.containsEjbComponentClass(ClassPathEjbJarScanner.java:349)
at org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner.containsEjbComponentClass(ClassPathEjbJarScanner.java:349)
at org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner.containsEjbComponentClass(ClassPathEjbJarScanner.java:349)
at org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner.containsEjbComponentClass(ClassPathEjbJarScanner.java:324)
at org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner.isEjbJar(ClassPathEjbJarScanner.java:285)
at org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner.getEjbJars(ClassPathEjbJarScanner.java:174)
at org.jboss.ejb3.embedded.sub.JBossSubmersibleEJBContainer.createEJBContainer(JBossSubmersibleEJBContainer.java:117)
Caused by: java.lang.ClassNotFoundException: 1.0.com.sun.codemodel.JConditional
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner.containsEjbComponentClass(ClassPathEjbJarScanner.java:367)
and Here is my build.xml:
<project name="Acme" default="help" basedir=".">
<target name="help">
<echo>
EJB3.1 (JBoss 6.0) persistence (JPA) example
--------------------------------------------
This example builds upon the concepts of the messaging (MDB) example by
adding a basic storage backend for messages.
You should note the separation
of functionality for adding and querying. This separation allows for design
and deployment (number of, TX-tuning, interceptors, etc) adjustments for
recording and retrieval of data.
To deploy (JBoss 6.x):
1) create message queue logging/record (default/deploy/hornetq/hornetq-jms.xml)
<!--queue name="demo">
<entry name="queue/MyQueue" />
</queue> -->
2) run the deploy ant target
</echo>
</target>
<target name="init">
<property name="src.dir" value="${basedir}/ejbModule" />
<property name="test.dir" value="${basedir}/test" />
<property name="classes.dir" value="${basedir}/classes" />
<property name="out.dir" value="${basedir}/build" />
<property name="jboss.home" value="C:/jboss-6.0.0.Final" />
<property name="junit.home" value="${basedir}/junit/org.junit_4.8.1.v4_8_1_v20100427-1100" />
<property name="jboss.deploy" value="${jboss.home}/server/default/deploy" />
<property name="jboss.deploy2" value="${jboss.home}/server/all/deploy" />
</target>
<target name="build" depends="clean">
<mkdir dir="${classes.dir}" />
<mkdir dir="${out.dir}" />
<javac srcdir="${src.dir}" destdir="${classes.dir}">
<classpath>
<fileset dir="${jboss.home}/client">
<include name="**/*.jar" />
</fileset>
<pathelement location="${classes.dir}" />
<pathelement location="${basedir}\junit\org.junit_4.8.1.v4_8_1_v20100427-1100\junit.jar"/>
</classpath>
</javac>
<javac srcdir="${test.dir}" destdir="${classes.dir}/com/acme/test">
<classpath>
<fileset dir="${jboss.home}/client">
<include name="**/*.jar" />
</fileset>
<pathelement location="${classes.dir}/com/acme/test" />
<pathelement location="${basedir}\junit\org.junit_4.8.1.v4_8_1_v20100427-1100\junit.jar"/>
</classpath>
</javac>
</target>
<target name="clean" depends="init">
<delete dir="${classes.dir}" quiet="true" />
<delete dir="${out.dir}" quiet="true" />
</target>
<target name="deploy" depends="jar">
<copy file="${out.dir}/AcmeAnt.jar" toDir="${jboss.deploy}" />
</target>
<target name="jar" depends="build">
<mkdir dir="${out.dir}/ejb-jar/META-INF" />
<mkdir dir="${out.dir}/ejb-jar/lib" />
<!-- for jboss 6.0 we do not deploy the log-queue-service.xml -->
<!-- copy file="${basedir}/conf/log-queue-service.xml" toDir="${out.dir}/ejb-jar" / -->
<copy file="${basedir}/conf/persistence.xml" toDir="${out.dir}/ejb-jar/META-INF" />
<copy toDir="${out.dir}/ejb-jar">
<fileset dir="${classes.dir}">
<include name="**/acme/beans/**" />
<include name="**/acme/entities/**" />
<include name="**/acme/test/**"/>
</fileset>
</copy>
<jar destfile="${out.dir}/AcmeAnt.jar">
<fileset dir="${out.dir}/ejb-jar">
<include name="**/*" />
</fileset>
</jar>
</target>
<target name="test" depends="deploy">
<
junit printsummary="yes" fork="yes" haltonfailure="yes">
<classpath>
<pathelement location="${classes.dir}" />
<pathelement location="${junit.home}/junit.jar" />
<pathelement location = "${basedir}\junit\org.hamcrest.core_1.1.0.v20090501071000.jar"/>
<pathelement location="${jboss.home}/lib/jboss-logmanager.jar"/>
<fileset dir="${jboss.home}/client">
<include name="*.jar"/>
</fileset>
<fileset dir="${jboss.home}/lib/endorsed">
<include name="*.jar" />
</fileset>
<fileset dir="${jboss.home}/lib">
<include name="*.jar" />
</fileset>
</classpath>
<formatter type="plain" />
<test name="com.acme.test.AcmeFinanceTest" />
</junit>
</target>
</project>
Am i missing something here?Please let me know.