2 Replies Latest reply on Jun 12, 2010 8:46 PM by alartin

    JNDI problem with SeamTest/JBoss Embedded

      Hi,

       

      I read numerous articles about using JBoss Embedded with SeamTest but could not find the solution to my problem:

       

      [testng] Caused by: java.lang.IllegalArgumentException: EntityManagerFactory not found in JNDI : java:/rampEntityManagerFactory                                            
         [testng]     at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:231)                     
         [testng]     at org.jboss.seam.persistence.ManagedPersistenceContext.initEntityManager(ManagedPersistenceContext.java:78)                                                  
         [testng]     at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManager(ManagedPersistenceContext.java:107)                                                  
         [testng]     at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)                                                                                                
         [testng]     at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:138)                                                                                        
         [testng]     at org.jboss.seam.Component.callComponentMethod(Component.java:2201)                                                                                          
         [testng]     at org.jboss.seam.Component.unwrap(Component.java:2227)                                                                                                       
         [testng]     at org.jboss.seam.Component.getInstance(Component.java:1994)                                                                                                  
         [testng]     at org.jboss.seam.Component.getInstance(Component.java:1940)                                                                                                  
         [testng]     at org.jboss.seam.Component.getInstance(Component.java:1934)                                                                                                  
         [testng]     at org.jboss.seam.Component.getInstanceInAllNamespaces(Component.java:2301)                                                                                   
         [testng]     at org.jboss.seam.Component.getValueToInject(Component.java:2253)                                                                                             
         [testng]     at org.jboss.seam.Component.injectAttributes(Component.java:1693)                                                                                             
         [testng]     at org.jboss.seam.Component.inject(Component.java:1511)                                                                                                       
         [testng]     at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:61)                                                                        
         [testng]     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)                                                                      
         [testng]     at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)                                                                
         [testng]     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)                                                                      
         [testng]     at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)                                                            
         [testng]     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)                                                                      
         [testng]     at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)                                                                                  
         [testng]     at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)                                                             
         [testng]     at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)                                                                          
         [testng]     at com.paddypower.ramp.common.util.seam.authenticator.AuthenticatorAction_$$_javassist_1.authenticate(AuthenticatorAction_$$_javassist_1.java)                
         [testng]     at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:329)                                                                                     
         [testng]     ... 48 more

       

      I have the bootstrap directory on my classpath where I have persistence.xml in META-INF with the following content:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <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="ramp">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>java:/rampDatasource</jta-data-source>
            <properties>
              <property name="hibernate.dialect" value="com.paddypower.ramp.common.core.persistence.hibernate.InformixDialect"/>
              <property name="hibernate.hbm2ddl.auto" value="none"/>
              <property name="hibernate.show_sql" value="false"/>
              <property name="hibernate.use_sql_comments" value="false"/>
              <property name="hibernate.format_sql" value="false"/>
              <property name="jboss.entity.manager.factory.jndi.name" value="java:/rampEntityManagerFactory"/>
              <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>
              <property name="hibernate.default_batch_fetch_size" value="100"/>
              <property name="hibernate.jdbc.batch_size" value="50"/>
              <property name="cache.provider_class" value="org.hibernate.cache.EhCacheProvider"/>
              <property name="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.EhCacheProvider"/>
              <property name="hibernate.cache.use_second_level_cache" value="true"/>
              <property name="hibernate.cache.region_prefix" value=""/>
              <property name="hibernate.cache.use_query_cache" value="true"/>
              <property name="hibernate.ejb.interceptor"  value="com.paddypower.ramp.common.core.phase.intercept.RampInterceptor"/>
              <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
            </properties>
         </persistence-unit>
      </persistence>

       

      I have components.xml in test-build/WEB_INF with the following (jndi pattern is "jndiPattern \#{ejbName}/local"):

       

      <core:init transaction-management-enabled="false" debug="@debug@" jndi-pattern="@jndiPattern@" />
      <tx:no-transaction />


      <core:manager concurrent-request-timeout="15000" conversation-timeout="3600000" conversation-id-parameter="cid"
              parent-conversation-id-parameter="pid" />


      <persistence:managed-persistence-context name="entityManager" auto-create="true"
              persistence-unit-jndi-name="java:/rampEntityManagerFactory" scope="conversation"/>


      <persistence:managed-persistence-context name="entityManagerOpenbet" auto-create="true"
              persistence-unit-jndi-name="java:/openbetEntityManagerFactory" scope="conversation"/>


      <persistence:managed-persistence-context name="manualEntityManager" auto-create="true"
              persistence-unit-jndi-name="java:/rampEntityManagerFactory" scope="conversation"/>


      <tx:entity-transaction entity-manager="#{entityManager}" name="entityManagerTransaction"/>
      <tx:entity-transaction entity-manager="#{entityManagerOpenbet}" name="entityManagerOpenbetTransaction"/>
      <tx:entity-transaction entity-manager="#{manualEntityManager}" name="manualEntityManagerTransaction"/>

       

      And, a datasource file in bootstrap/deploy with:

       

      <datasources>

              <xa-datasource>
                  <jndi-name>rampDatasource</jndi-name>
                  <xa-datasource-class>com.informix.jdbcx.IfxXADataSource</xa-datasource-class>
                  <xa-datasource-property name="Description">Something Descriptive</xa-datasource-property>
                  <xa-datasource-property name="IfxIFXHOST">rampdb1dev</xa-datasource-property>
                  <xa-datasource-property name="PortNumber">3001</xa-datasource-property>
                  <xa-datasource-property name="DatabaseName">ramp_dev</xa-datasource-property>
                  <xa-datasource-property name="ServerName">rampdb1dev</xa-datasource-property>
                  <xa-datasource-property name="User"></xa-datasource-property>
                  <xa-datasource-property name="Password"></xa-datasource-property>
                  <xa-datasource-property name="IfxIFX_LOCK_MODE_WAIT">180</xa-datasource-property>
                  <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
                  <check-valid-connection-sql>select * from systables where tabid=1</check-valid-connection-sql>
                  <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.InformixExceptionSorter</exception-sorter-class-name>
                  <metadata>
                     <type-mapping>InformixDB</type-mapping>
                  </metadata>
              </xa-datasource>

      </datasources>

       

      I suspect my components.xml is not parsed, I wonder what the correct location is for this file. In general I'm not sure what is the correct directory/deployment structure is for a test of this kind.

       

      Any help would be greatly appreciated.

       

      Thanks,

      Peter