Hi,
I get the same problem when I try to run the testCase EmbeddedEjb3TestCase.java 
 comes with the Embedded-EJB3-ALPHA_5 examples.


  | public class EmbeddedEjb3TestCase extends TestCase
  | {
  |    public EmbeddedEjb3TestCase()
  |    {
  |       super("EmbeddedEjb3TestCase");
  |    }
  | 
  | 
  |    public static Test suite() throws Exception
  |    {
  |       TestSuite suite = new TestSuite();
  |       suite.addTestSuite(EmbeddedEjb3TestCase.class);
  | 
  | 
  |       // setup test so that embedded JBoss is started/stopped once for all 
tests here.
  |       TestSetup wrapper = new TestSetup(suite)
  |       {
  |          protected void setUp()
  |          {
  |             startupEmbeddedJboss();
  |          }
  | 
  |          protected void tearDown()
  |          {
  |             shutdownEmbeddedJboss();
  |          }
  |       };
  | 
  |       return wrapper;
  |    }
  | 
  |    public static void startupEmbeddedJboss()
  |    {
  |          EJB3StandaloneBootstrap.boot(null);
  |          EJB3StandaloneBootstrap.scanClasspath();
  |    }
  | 
  |    public static void shutdownEmbeddedJboss()
  |    {
  |       EJB3StandaloneBootstrap.shutdown();
  |    }
  | 
  |    public void testEntityManager() throws Exception
  |    {
  |       // This is a transactionally aware EntityManager and must be accessed 
within a JTA transaction
  |       // Why aren't we using javax.persistence.Persistence?  Well, our 
persistence.xml file uses
  |       // jta-datasource which means that it is created by the EJB 
container/embedded JBoss.
  |       // using javax.persistence.Persistence will just cause us an error
  |       EntityManager em = (EntityManager) 
getInitialContext().lookup("java:/custdb");
  | 
  |       // Obtain JBoss transaction
  |       UserTransaction tm = (UserTransaction) 
getInitialContext().lookup("UserTransaction");
  | 
  |       tm.begin();
  | 
  |       Customer cust = new Customer();
  |       cust.setName("Bill");
  |       em.persist(cust);
  | 
  |       assertTrue(cust.getId() > 0);
  | 
  |       int id = cust.getId();
  | 
  |       System.out.println("created bill in DB with id: " + id);
  | 
  |       tm.commit();
  | 
  |       tm.begin();
  |       cust = em.find(Customer.class, id);
  |       assertNotNull(cust);
  |       tm.commit();
  |    }
  | 
  |    public static InitialContext getInitialContext() throws Exception
  |    {
  |       Hashtable props = getInitialContextProperties();
  |       return new InitialContext(props);
  |    }
  | 
  |    private static Hashtable getInitialContextProperties()
  |    {
  |       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");
  |       return props;
  |    }
  | }

Tell me do you have a solution for this problem or how I have to inject 
EntityManages in the embedded-jboss-*.xml file ?

Thanks ...



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

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


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to