2 Replies Latest reply on Sep 30, 2010 6:27 PM by logan

    jboss-embedded with testNG injection problem

    alex_ro_bv

      Hi guys,I'm developing an application with seam 2.2.1.CR1, jboss-embedded beta3.SP4, testNG and maven 2.0.2.
      After adding the necessary jar files, and all the bootstrap configuration files, jboss embedded starts, but I'm facing an injection problem. It always says: @In attribute requires non-null value. I don't use ejb, just seam components and also I don't use hibernate, just custom jdbc implementations.


      My components.properties is the following:



      jndiPattern=#{ejbName}/local
      debug=true
      seamBootstrapsPu=true
      seamEmfRef=#{entityManagerFactory}
      puJndiName=#{null}



      components.xml:



      <?xml version="1.0" encoding="UTF-8"?>
      <components xmlns="http://jboss.com/products/seam/components"
                  xmlns:core="http://jboss.com/products/seam/core"
                  xmlns:persistence="http://jboss.com/products/seam/persistence"
                  xmlns:security="http://jboss.com/products/seam/security"
                  xmlns:transaction="http://jboss.com/products/seam/transaction"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation=
                      "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd
                       http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.0.xsd
                       http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
                       http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd
                       http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd">
      
          <core:init jndi-pattern="@jndiPattern@" debug="true"/>
      
          <core:manager conversation-timeout="120000"
                        concurrent-request-timeout="500"
                        conversation-id-parameter="cid"/>
      
          <transaction:ejb-transaction/>
      
          <security:identity authenticate-method="#{authenticator.authenticate}"/>
      </components>



      bootstrap/META-INF/ejb-jar.xml:



      <?xml version="1.0" encoding="UTF-8"?>
      <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
               version="3.0">
               
         <interceptors>
            <interceptor>
               <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
            </interceptor>
         </interceptors>
         
         <assembly-descriptor>
            <interceptor-binding>
               <ejb-name>*</ejb-name>
               <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
            </interceptor-binding>
         </assembly-descriptor>
         
      </ejb-jar>



      and the code that fails :



      @Name("userHome")
      @Scope(ScopeType.SESSION)
      public class UserHomeImpl extends AbstractEntityHome<User> implements UserHome,Serializable {
           
           private static final long serialVersionUID = -6114303258863985024L;
      
           @In(create=true)
           private UserDao dao;



      where userDao:



      @Name("userDao")
      public class UserDaoImpl extends AbstractJdbcDaoImpl<User> implements UserDao {






      The exception that always is raised :@In attribute requires non-null value: userHome.dao


      Can you please help me on this injection issue?
      Thanks.








        • 1. Re: jboss-embedded with testNG injection problem
          alex_ro_bv

          Investigating furthermore with debug enabled, I've found out that all the components are in the context:



           Component: textMessageDao, scope: EVENT, type: JAVA_BEAN, class: com.iquest.emeetingnotes.backend.database.jdbc.impl.TextMessageDaoImpl
          DEBUG [org.jboss.seam.Component] interceptor stack: [Interceptor(org.jboss.seam.core.MethodContextInterceptor), Interceptor(org.jboss.seam.core.BijectionInterceptor), Interceptor(org.jboss.seam.transaction.RollbackInterceptor)]
          INFO  [org.jboss.seam.Component] Component: userDao, scope: EVENT, type: JAVA_BEAN, class: com.iquest.emeetingnotes.backend.database.jdbc.impl.UserDaoImpl
          DEBUG [org.jboss.seam.Component] interceptor stack: [Interceptor(org.jboss.seam.core.MethodContextInterceptor), Interceptor(org.jboss.seam.core.BijectionInterceptor), Interceptor(org.jboss.seam.transaction.RollbackInterceptor)]
          INFO  [org.jboss.seam.Component] Component: userHome, scope: SESSION, type: JAVA_BEAN, class: com.iquest.emeetingnotes.backend.home.impl.UserHomeImpl
          DEBUG [org.jboss.seam.Component] interceptor stack: [Interceptor(org.jboss.seam.core.MethodContextInterceptor), Interceptor(org.jboss.seam.core.BijectionInterceptor), Interceptor(org.jboss.seam.transaction.RollbackInterceptor)]



          and if I put

          @In(required=false,create=true)

          , just for debug, I've discovered that from two attributes annotated with
          @In(create=true)

          ,
          one works while the other one does not. Both classes are basically identical and the usages are the same:




          @Name("userDao")
          public class UserDaoImpl extends AbstractJdbcDaoImpl<User> implements UserDao {




          @Name("textMessageDao")
          public class TextMessageDaoImpl extends AbstractJdbcDaoImpl<TextMessage> implements
                    TextMessagesDao {



          and the usages:



          @Name("userHome")
          @Scope(ScopeType.SESSION)
          public class UserHomeImpl extends AbstractEntityHome<User> implements UserHome,Serializable {
               
               private static final long serialVersionUID = -6114303258863985024L;
          
               @In(required=false,create=true)
               private UserDao dao;
               
          
               @In(create=true)
               private TextMessagesDao textMessageDao;



          In debug mode I can see that textMessageDao is instantiated while userDao does not. If I remove required attribute, it will throw me the non-null injection exception.










          • 2. Re: jboss-embedded with testNG injection problem
            logan

            Have you found the solution?