1 Reply Latest reply on Jun 14, 2010 8:54 PM by IVAN BATISTA MORENO

    SeamTest java.lang.RuntimeException: exception invoking: getTransaction

    IVAN BATISTA MORENO Newbie

      How can I inject the transaction object in this test is with the following error:


      INFO: Not binding factory to JNDI, no JNDI name configured
      FAILED: testUsuario
      java.lang.RuntimeException: exception invoking: getTransaction
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:154)
           at org.jboss.seam.Component.callComponentMethod(Component.java:2249)
           at org.jboss.seam.Component.unwrap(Component.java:2275)
           at org.jboss.seam.Component.getInstance(Component.java:2041)
           at org.jboss.seam.Component.getInstance(Component.java:2000)
           at org.jboss.seam.Component.getInstance(Component.java:1994)
           at org.jboss.seam.Component.getInstance(Component.java:1967)
           at org.jboss.seam.Component.getInstance(Component.java:1962)
           at org.jboss.seam.transaction.Transaction.instance(Transaction.java:39)
           at org.jboss.seam.util.Work.workInTransaction(Work.java:32)
           at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:91)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
           at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
           at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
           at br.gov.sas.core.bo.UsuarioBO_$$_javassist_seam_1.findAll(UsuarioBO_$$_javassist_seam_1.java)
           at br.gov.sas.core.test.SampleTest$1.testComponents(SampleTest.java:27)
           at org.jboss.seam.mock.AbstractSeamTest$ComponentTest.run(AbstractSeamTest.java:162)
           at br.gov.sas.core.test.SampleTest.testUsuario(SampleTest.java:31)
      Caused by: 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
           at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
           at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
           at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
           at javax.naming.InitialContext.lookup(Unknown Source)
           at org.jboss.seam.transaction.Transaction.getUserTransaction(Transaction.java:82)
           at org.jboss.seam.transaction.Transaction.createUTTransaction(Transaction.java:74)
           at org.jboss.seam.transaction.Transaction.getTransaction(Transaction.java:47)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
           ... 42 more
      ... Removed 26 stack frames



      My test class:



      package br.gov.sas.core.test;
      
      import org.hibernate.Session;
      import org.hibernate.SessionFactory;
      import org.hibernate.cfg.AnnotationConfiguration;
      import org.jboss.seam.Component;
      import org.jboss.seam.mock.SeamTest;
      import org.testng.annotations.AfterClass;
      import org.testng.annotations.BeforeClass;
      import org.testng.annotations.Test;
      
      import br.gov.sas.core.bo.UsuarioBO;
      
      public class SampleTest extends SeamTest {
      
          private UsuarioBO usuarioBO;
      
          @Test
          public void testUsuario() throws Exception {
      
           new ComponentTest() {
      
               @Override
               protected void testComponents() throws Exception {
      
                usuarioBO = (UsuarioBO) Component.getInstance("usuarioBO");
                usuarioBO.findAll();
      
               }
      
           }.run();
      
          }
      
          @BeforeClass
          public void init() {
      
           super.initServletContext(null);
      
           SessionFactory sessionFactory = new AnnotationConfiguration().configure(
                "hibernate-test.cfg.xml").buildSessionFactory();
      
           Session session = sessionFactory.openSession();
           servletContext.setAttribute("hibernateSession", session);
      
          }
      
          @AfterClass
          public void destroy() {
          }
      }