10 Replies Latest reply on May 24, 2010 8:27 PM by Lelo Pieri

    Newbie - injection problem (getting null)

    Ricardo Araujo Newbie

      Hi all.
      Im new in SEAM and Im trying to inject a seam component (anoted with @Name), but all my tries fall into a null pointer...


      In a few lines, UploadServiceHome recives a upload request, store the uploaded files and delegate the business to UploadService (talking about modeling, is that a good way?) - processMap(..) method. But the UploadService needs to retrieve database information, stored into FarmStructureDescription (a @Entity). So, im trying to inject FarmStructureDescriptionHome into UploadService, but im getting null....


      The relevant codes:


      @Name("uploadServiceHome")
      @Scope(ScopeType.PAGE)
      public class UploadServiceHome extends EntityHome<UploadService> {
           
           private static final long serialVersionUID = 6478064206304267363L;
           
           @In(create = true)
           CompanyHome companyHome;
           
           private Map<String, String> filesPaths = new HashMap<String, String>();
           
           public void upload(UploadEvent event) {
                
                ......
      
                filesPaths.put(fileExtension, pathname);
                try {
                        getInstance().processMap(filesPaths);
                } 
                catch (IOException e) {
                     e.printStackTrace();
                }
           }
      }
      




      public class UploadService implements Serializable{
           ....
           
              @In(create = true)
              FarmStructureDescriptionHome farmStructureDescriptionHome;
           
           
              public String processMap(Map<String, String> filesPaths) throws IOException {
               
                    List<?> descriptions = farmStructureDescriptionHome.getDescriptions(company);
                    descriptions.size();
                return "OK";
              }
      }
      



      some problem to inject into a Serializable object?



      Someone please...
      Modeling tips and comments are welcome too!


      Thxx,


      Carvo