2 Replies Latest reply on Jul 3, 2017 9:03 AM by jakusb

    Issue with injection on JBoss 6.4EAP

    jakusb

      <p></p>I am migrating a project from Jboss 5.1 to 6.4 and having some trouble with EJB injection..

       

      This class is being instantiated after the dependent EJB is loaded, but for some reason the injection attribute is null.

      What and how exactly should ConnectionServiceMBean<IDfSession> service get instantiated?

       

       

      package nl.xxx.service.ejb.dctm;
      import java.util.HashMap;
      import java.util.LinkedList;
      import java.util.List;
      import java.util.Map;
      import javax.naming.Binding;
      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.naming.NameClassPair;
      import javax.naming.NamingEnumeration;
      import javax.naming.NamingException;
      import javax.naming.event.EventContext;
      import org.apache.commons.lang.exception.ExceptionUtils;
      import org.apache.log4j.Logger;
      import org.jboss.ejb3.annotation.Depends;
      import org.jboss.naming.NamingContextFactory;
      import com.documentum.fc.client.IDfSession;
      import nl.xxx.service.ejb.AbstractConnectionEJB;
      import nl.xxx.service.mbean.ConnectionServiceMBean;
      import nl.xxx.service.mbean.dctm.DctmConnectionServiceMBean;
      import nl.xxx.service.mbean.jms.JmsConnectionServiceMBean;
      import nl.xxx.service.mbean.jms.JmsMDBConnection;
      /**
       * Abstract connection EJB class that extends the AbstractConnectionEJB. 
       * This class depends on the DCTM service and the JMS service. 
       *
       * @param <R>
       * @param <C>
       * @param <JMS>
       */
      public abstract class AbstractDctmConnectionEJB<R extends Object, C extends IDfSession, JMS extends JmsMDBConnection>
       extends AbstractConnectionEJB<R, IDfSession, JMS>{
       private static final Logger logger = Logger.getLogger(AbstractDctmConnectionEJB.class.getName());
       @Depends({DctmConnectionServiceMBean.SERVICE_NAME})
       private ConnectionServiceMBean<IDfSession> service;
       
       @Depends({JmsConnectionServiceMBean.SERVICE_NAME})
       private ConnectionServiceMBean<JMS> JMSService;
       
       @Override
       public ConnectionServiceMBean<IDfSession> getService(){
        logger.error("getService() for "+this.getClass()+" --> ");  
        if (service==null) {
         logger.error("no service to return! "+ExceptionUtils.getFullStackTrace(new IllegalArgumentException("No service to return! "+getClass())));
         throw new IllegalArgumentException("No service to return!");
        }
        return service;
       }
       
       @Override
       public ConnectionServiceMBean<JMS> getJMSService(){
        return JMSService;
       }
      }
      
      

       

      This is the mbean config in jboss-service.xml:

       

       

      
      
       <mbean code="nl.xxx.service.mbean.dctm.DctmConnectionService"
        name="xxx.connection.service:service=DctmConnectionServiceMBean">
        <attribute name="DestinationJndiMappings">
         XXX_TST=xxx.connection.dctm:service=XXX_TST
         YYY_TST=xxx.connection.dctm:service=YYY_TST
              </attribute>
        <attribute name="DefaultConnectionName">YYY_TST</attribute>
        <!-- <depends>jboss:service=Naming</depends> -->
       </mbean>
      
      

       

      For some reason the attribute service is not linked to an instance of this mbean

      any help in understanding what I am doing wrong is greatly impreciated

      regards,

       

      Jacob

        • 1. Re: Issue with injection on JBoss 6.4EAP
          getgolfedkid

          Hello,

           

          The ejb3-ioc library is not supported by JBoss EAP 7 (so I assume you may have the same problem with JBoss EAP 6.4), that's why the attribute is null.

           

          I don't have any solution for EAP 6.4 though. (maybe use CDI instead if you can)

           

          Regards.

          • 2. Re: Issue with injection on JBoss 6.4EAP
            jakusb

            That does not sound correct...

            I think problem is more related to abstraction level in super classes..

            I remember to have read somewhere that such inheritance might break starting the EJB... However I cannot find that explanation anywhere now..

            Really need some expert that can help me understand and fix this issue...