1 Reply Latest reply on May 16, 2011 1:24 AM by dzakharov

    Resource loading problem

    dzakharov

      Hello,


      I try code:


      @Named("beanList")
      public class beanList {
              @Inject
              @org.jboss.seam.solder.resourceLoader.Resource("WEB-INF/web.xml")
              InputStream webXml;
      
              @javax.annotation.Resource(mappedName = "jndi_name")
              private DataSource datasource;
      
      ....
      
              public void executeQuery() {
                      EntityManager em = new EntityManager();
                      if(em.getDataSource() != null){
                              log.debug("List datasource isn't null.");
                      } else {
                              log.debug("List datasource is null.");
                      }
                      if(em.getWebXml() != null)
                              log.debug("List wevXml is not null");
                      else
                              log.debug("List webXml is null");
                      if(webXml != null)
                              log.debug("local: wevXml is not null");
                      else
                              log.debug("local: webXml is null");
                      
                      if(datasource != null)
                              log.debug("local: datasource is not null");
                      else
                              log.debug("local: datasource is null");
              }
      
      public class EntityManager {
              private static final Logger log = Logger.getLogger(EntityManager.class);
      
              @Inject
              @org.jboss.seam.solder.resourceLoader.Resource("WEB-INF/web.xml")
              InputStream webXml;
      
              @javax.annotation.Resource(mappedName="jndi_name")
              DataSource datasource;
              
              public EntityManager() {
                      log.trace("*** Creating EntityManager.");
                      if (log.isDebugEnabled()) {
                              if (webXml != null)
                                      log.debug("Injected webXml is not null");
                              else
                                      log.debug("Injected webXml is null");
                              if (datasource != null)
                                      log.debug("Injected datasource isn't null.");
                              else
                                      log.debug("Injected datasource is null.");
                      }
              }
              
              public DataSource getDataSource(){
                      return datasource;
              }
              
              public InputStream getWebXml(){
                      return webXml;
              }
      }
      
      09:12:09,211 TRACE [EntityManager] *** Creating EntityManager.
      09:12:09,211 DEBUG [EntityManager] Injected webXml is null
      09:12:09,211 DEBUG [EntityManager] Injected datasource is null.
      09:12:09,211 DEBUG [BeanList] List datasource is null.
      09:12:09,211 DEBUG [BeanList] List webXml is null
      09:12:09,211 DEBUG [BeanList] local: wevXml is not null
      09:12:09,212 DEBUG [BeanList] local: datasource is not null
      


      What's wrong? Why resource loading not work in EntityBean?
      Thanks for your help.