[jboss-user] [EJB 3.0] - Problem with testing EJB3-rc9

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


hi all,
 i am trying to test my ejb3 ejbs by starting the jboss microcontainer
i am using release rc9, and its related microcontainer..
here's my persistence.xml


  | <!-- Persistence file for EJB3 application -->
  | <persistence>
  |   <persistence-unit name="j2me">
  |      <jta-data-source>java:/DefaultDS</jta-data-source>
  |      <properties>
  |        <property name="hibernate.hbm2ddl.auto"
  |   </persistence-unit>
  | </persistence>
  | 

i have this base test class which starts up jboss microcontainer (only relevant code

  |         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.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);
  |         }
  |     }
  | 

i have following session ejb

  | @Stateless(name="facade")
  | @Local ( {FacadeIF.class})
  | 
  | public class TestFacade implements FacadeIF {
  | 
  | 	@PersistenceContext
  | 	EntityManager em;
  | 	
  | 	public void deleteAgency(Agency agency) {
  | 		// TODO Auto-generated method stub
  | 		Query query = getQuery("findAgencyById");
  | 		query.setParameter("id", agency.getId());
  | 		Agency agencyToDelete = (Agency)query.getSingleResult();
  | 		em.remove(agencyToDelete);
  | 	}
  | 
  | 	public void deleteJobApplication(JobApplication app) {
  | 		Query query = getQuery("findJAById");
  | 		query.setParameter("id", app.getId());
  | 		JobApplication jaToDelete = (JobApplication)query.getSingleResult();
  | 		em.remove(jaToDelete);
  | 
  | 	}
  | ....
  | 

In one of my tests i am trying to lookup the ejb

  | public void testInsertAgency() throws Exception  {
  | 		System.err.println("Testing insertion of  an Agency..");
  | 	    try {
  | 	
  | 	      TestFacade sessionFacade = (TestFacade) EJB3Container.lookup("facade/local");
  | 		
  | 
  | 	    } catch(Exception e) {
  | 
  | 	    	System.err.println("an exception occurred...");
  | 	    	e.printStackTrace();
  | 	    }
  | 	   
  | 		
  | 	}
  | 

but htis result sin following excepiton

  | java.lang.RuntimeException: Couldn't lookup: facade/local
  |         at example1.EJB3Container.lookup(EJB3Container.java:101)
  |         at example1.AgencyTest.testInsertAgency(AgencyTest.java:33)
  |         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  |         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  |         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  |         at java.lang.reflect.Method.invoke(Unknown Source)
  |         at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:552)
  |         at org.testng.internal.Invoker.invokeMethod(Invoker.java:411)
  |         at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:785)
  |         at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:114)
  |         at org.testng.TestRunner.privateRun(TestRunner.java:693)
  |         at org.testng.TestRunner.run(TestRunner.java:574)
  |         at org.testng.SuiteRunner.privateRun(SuiteRunner.java:241)
  |         at org.testng.SuiteRunner.run(SuiteRunner.java:145)
  |         at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:901)
  |         at org.testng.TestNG.runSuitesLocally(TestNG.java:863)
  |         at org.apache.maven.surefire.testng.TestNGExecutor.executeTestNG(TestNGE
  | xecutor.java:78)
  |         at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXml
  | TestSuite.java:76)
  |         at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
  |         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  |         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  |         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  |         at java.lang.reflect.Method.invoke(Unknown Source)
  |         at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(Su
  | refireBooter.java:262)
  |         at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.j
  | ava:787)
  | Caused by: javax.naming.NameNotFoundException: facade not bound
  |         at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
  |         at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
  |         at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
  |         at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
  |         at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:626)
  |         at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:588)
  |         at javax.naming.InitialContext.lookup(Unknown Source)
  | 

could anyone tell me what's the problem?
it looks like my session ejb is not being deployed..... any reasons why?
am i using the wrong jndi name to lookup the ejb?

thanks ina dvance and r egards
 marco






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

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



More information about the jboss-user mailing list