0 Replies Latest reply on May 25, 2007 8:08 PM by Jamie Cruise

    Testing without EJB

    Jamie Cruise Newbie


      Does anybody know how to bootstrap the microcontainer in a test class or console app? I am using pojo/hibernate/tomcat so I don't want to use the embedded ejb-3. I tried simply extending SeamTest, using code a bit like this:

      public class Administration extends SeamTest {
       EntityManager em() {
       EntityManagerFactory emf = Persistence
       EntityManager em = emf.createEntityManager();
       return em;
       public static void main(String[] args) throws Exception {
       Administration app = new Administration();
       private void execute() throws Exception {
       EntityManager em = em();
       Log log = (Log) getInstance("log");
       log.info("Starting Administration Console");
      ... stuff with my components ...

      but I get the following error:

      15:55:15,967 ERROR [NamingHelper] Could not obtain initial context
      javax.naming.NamingException: Local server is not initialized
       at org.jnp.interfaces.LocalOnlyContextFactory.getInitialContext(LocalOnlyContextFactory.java:30)
       at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
       at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
       at javax.naming.InitialContext.init(Unknown Source)
       at javax.naming.InitialContext.<init>(Unknown Source)
       at org.hibernate.util.NamingHelper.getInitialContext(NamingHelper.java:28)

      Any ideas?