[jboss-user] [Microcontainer] - problem with microcontainer-alpha9 while testing ejb3s. cann

MmarcoM do-not-reply at jboss.com
Sun Sep 24 13:42:44 EDT 2006


hello all,
 i have just upgraded jboss ejb3 to rc9 release, so ihav updated also the embeddable alpha to rc9.
i am running junit test  by starting jboss microcontainer in my junit (testNG) test
i am currently using maven2... btw here' smy pom


  | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  | 	<modelVersion>4.0.0</modelVersion>
  | 	<groupId>ejbJ2ME</groupId>
  | 	<artifactId>ejbJ2ME</artifactId>
  | 	<packaging>jar</packaging>
  | 	<version>1.0-SNAPSHOT</version>
  | 	<name>ejbJ2ME</name>
  | 	<url>http://maven.apache.org</url>
  | 	<dependencies>
  | 		<dependency>
  | 			<groupId>junit</groupId>
  | 			<artifactId>junit</artifactId>
  | 			<version>3.8.1</version>
  | 			<scope>test</scope>
  | 		</dependency>
  | 		<dependency>
  | 			<groupId>org.testng</groupId>
  | 			<artifactId>testng</artifactId>
  | 			<version>5.1</version>
  | 			<scope>test</scope>
  | 			<classifier>jdk15</classifier>
  | 		</dependency>
  | 		<dependency>
  | 			<groupId>j2meCore</groupId>
  | 			<artifactId>J2MECore</artifactId>
  | 			<version>1.0-SNAPSHOT</version>
  | 		</dependency>
  | 		<dependency>
  | 			<groupId>microcontainer</groupId>
  | 			<artifactId>hibernate-all</artifactId>
  | 			<version>rc9</version>
  | 			<scope>system</scope>
  | 			<systemPath>${basedir}\lib\hibernate-all-rc9.jar</systemPath>
  | 		</dependency>
  | 		<dependency>
  | 			<groupId>microcontainer</groupId>
  | 			<artifactId>jboss-ejb3-all</artifactId>
  | 			<version>rc9</version>
  | 			<scope>system</scope>
  | 			<systemPath>${basedir}\lib\jboss-ejb3-all-rc9.jar</systemPath>
  | 		</dependency>
  | 		<dependency>
  | 			<groupId>microcontainer</groupId>
  | 			<artifactId>jcainflow</artifactId>
  | 			<version>rc9</version>
  | 			<scope>system</scope>
  | 			<systemPath>${basedir}\lib\jcainflow-rc9.jar</systemPath>
  | 		</dependency>
  | 		<dependency>
  | 			<groupId>microcontainer</groupId>
  | 			<artifactId>thirdparty-all</artifactId>
  | 			<version>rc9</version>
  | 			<scope>system</scope>
  | 			<systemPath>${basedir}\lib\thirdparty-all-rc9.jar</systemPath>
  | 		</dependency>
  | 		<dependency>
  | 			<groupId>microcontainer</groupId>
  | 			<artifactId>jms-ra</artifactId>
  | 			<version>rc9</version>
  | 			<scope>system</scope>
  | 			<systemPath>${basedir}\lib\jms-ra-rc9.jar</systemPath>
  | 		</dependency>
  | 		<dependency>
  |       	 		<groupId>microcontainer</groupId>
  |       	 		<artifactId>ehcache</artifactId>
  |       	 		<version>1.2</version>
  |       	 		<scope>system</scope> 
  |          		<systemPath>${basedir}\lib\ehcache-1.2.jar</systemPath>
  |       </dependency>
  |       
  | 		<dependency>
  | 			<groupId>dbunit</groupId>
  | 			<artifactId>dbunit</artifactId>
  | 			<version>2.1</version>
  | 			<scope>test</scope>
  | 		</dependency>
  | 	</dependencies>
  | 	<build>
  | 		<testSourceDirectory>src/test</testSourceDirectory>
  | 		<testResources>
  | 			<testResource>
  | 				<directory>src/test/resources</directory>
  | 				<includes>
  | 					<include>*.*</include>
  | 				</includes>
  | 			</testResource>
  | 		</testResources>
  | 		<pluginManagement>
  | 			<plugins>
  | 				<plugin>
  | 					<groupId>org.apache.maven.plugins</groupId>
  | 					<artifactId>maven-compiler-plugin</artifactId>
  | 					<configuration>
  | 						<source>1.5</source>
  | 						<target>1.5</target>
  | 					</configuration>
  | 				</plugin>
  | 				<plugin>
  | 					<groupId>org.apache.maven.plugins</groupId>
  | 					<artifactId>maven-surefire-plugin</artifactId>
  | 					<!--<version>2.8-SNAPSHOT</version>-->
  | 					<configuration>
  | 						<suiteXmlFiles>
  | 							<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
  | 						</suiteXmlFiles>
  | 					</configuration>
  | 				</plugin>
  | 	    			<plugin>
  |                				<groupId>org.apache.maven.plugins</groupId>
  |                				<artifactId>maven-surefire-report-plugin</artifactId>
  |             			</plugin>
  |          		</plugins>
  | 		</pluginManagement>
  | 	</build>
  | 	<pluginRepositories>
  | 		<pluginRepository>
  | 			<id>tapestry.javaforge</id>
  | 			<url>http://howardlewisship.com/repository</url>
  | 		</pluginRepository>
  | 	</pluginRepositories>
  | </project>
  | 

i have a base junit test which is supposed to statup EJB3 container
here's code

  | package example1;
  | 
  | 
  | 
  | 
  | import java.util.Hashtable;
  | 
  | import org.jboss.ejb3.embedded.*;
  | import org.testng.annotations.Configuration;
  | import org.testng.annotations.ExpectedExceptions;
  | import org.testng.annotations.Test;
  | import junit.framework.*;
  | import junit.extensions.*;
  | 
  | 
  | import javax.naming.*; 
  | 
  | /**
  |  * Boots the JBoss Microcontainer with an EJB3 configuration.
  |  * <p>
  |  * You can also use this class to lookup managed beans from JNDI.
  |  *
  |  * @author christian.bauer at jboss.com
  |  */
  | public class EJB3Container {
  | 
  |     private static InitialContext initialContext;
  |     private EJB3StandaloneDeployer deployer;
  | 
  | 
  |     @Configuration(groups = "integration.ejb3", beforeTest = true)
  |     public void startup() {
  |         try {
  | 
  | 	    System.err.println("---- bootstrapping EJB3 container....");
  | 
  |             // Boot the JBoss Microcontainer with EJB3 settings, loads ejb3-interceptors-aop.xml
  |         EJB3StandaloneBootstrap.boot(null);
  |         System.err.println("...... deploying embedded-jboss-beans....");
  | 	    EJB3StandaloneBootstrap.scanClasspath();
  | 
  | 	                // Deploy everything we got
  | 	     deployer = new EJB3StandaloneDeployer();
  |  deployer.setKernel(EJB3StandaloneBootstrap.getKernel());	
  |             deployer.create();
  | 	    System.err.println("...... deployer created....");
  | 
  |             deployer.start();
  | 	    System.err.println("...... deployer started....");
  | 
  | 	    
  | 	    Hashtable props = new Hashtable();
  | 	      props.put("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
  | 	      props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
  |             // Create InitialContext from jndi.properties
  |             initialContext = new InitialContext(props);
  |             System.err.println("---- end of bootstrapping EJB3 container....InitialContext is:");
  | 	    
  |         } catch (Exception ex) {
  | 			ex.printStackTrace();
  |             throw new RuntimeException(ex);
  |         }
  |     }
  | 
  | 
  | 
  | 
  |     @Configuration(groups = "integration.ejb3", afterTest = true)
  |     public void shutdown() {
  |         try {
  | 			System.err.println("---- Invoking EJB3.shutdown..");
  |             deployer.stop();
  |             deployer.destroy();
  |             EJB3StandaloneBootstrap.shutdown();
  |         } catch (Exception ex) {
  |             throw new RuntimeException(ex);
  |         }
  |     }
  | 
  | 
  |    
  | 
  | 
  |  
  | 
  | 
  |     public static Object lookup(String beanName) {
  |         try {
  | 	    
  |             return initialContext.lookup(beanName);
  |         } catch (NamingException ex) {
  |             throw new RuntimeException("Couldn't lookup: " + beanName, ex);
  |         }
  |     }
  | 
  | }
  | 


i have a stateless session bean, here's excerpt of class

  | import com.mm.j2me.core.Agency;
  | import com.mm.j2me.core.JobApplication;
  | import com.mm.j2me.core.Opportunity;
  | import javax.persistence.*;
  | import javax.ejb.*;
  | import javax.persistence.*;
  | import java.util.ArrayList;
  | import java.util.Collection;
  | import java.util.Iterator;
  | import java.util.List;
  | import java.util.Vector;
  | 
  | @Stateless
  | @Local ( {FacadeIF.class})
  | 
  | public class TestFacade implements FacadeIF {
  | 
  | 	@PersistenceContext
  | 	EntityManager em;
  | ..
  | 

i m trying to look it up in my tests usign following code:

  |   TestFacade sessionFacade = (TestFacade) EJB3Container.lookup("TestFacade/local");
  | 		
  | 

it results in a  NUllPointerException.........

can anyone help me out in trying to find why i cannot lookup my EJB?
am i starting EJB3 container in the wrong way?	

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973754#3973754

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973754



More information about the jboss-user mailing list