[jboss-user] [EJB 3.0] - Can't make SEAM unit test work

tuxzilla do-not-reply at jboss.com
Tue May 15 18:48:58 EDT 2007


I followed the example at http://docs.jboss.com/seam/1.2.1.GA/reference/en/html/testing.html#d0e15875 to unit test my own bean but I get:

SEVERE: Could not find datasource: java:/n2TestDatasource
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial

Here is my persisten.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Persistence deployment descriptor for tests -->
<persistence xmlns="http://java.sun.com/xml/ns/persistence" 
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
             version="1.0">
             
   <persistence-unit name="n2">
      org.hibernate.ejb.HibernatePersistence
      <jta-data-source>java:/n2TestDatasource</jta-data-source>
      
         
         
         
         
         
         
         
         
      
   </persistence-unit>    


Here is my code to get EntityManagerFactory in the test:

    @BeforeClass
    public void init()
    {
        emf = Persistence.createEntityManagerFactory("n2");
    }

I thought it would be a POJO test like the example said, why was I getting an initial context exception?  Thanks.

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

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



More information about the jboss-user mailing list