2 Replies Latest reply on Jan 13, 2013 11:21 PM by Yadav Brijesh

    Bundle Not Exporting Package

    h455491j4z Level 1

      I have made a bundle in Crxde lite called MyRepositoryManager

       

      package com.support.jcr;
      
      import javax.jcr.Repository;
      import javax.jcr.SimpleCredentials;
      
      import org.apache.felix.scr.annotations.Component;
      import org.apache.felix.scr.annotations.Property;
      import org.apache.felix.scr.annotations.Service;
      import org.apache.sling.api.resource.Resource;
      
      import org.apache.jackrabbit.commons.JcrUtils; 
      
      @Component
      @Service(value=MyRepositoryManager.class)
      public class MyRepositoryManager{
      
          public Repository getRepository(String repositoryUrl){
               Repository repository = null;
              try{
                  repository = JcrUtils.getRepository(repositoryUrl);
              } catch(Exception e){
                  e.printStackTrace();
              }
               return repository;
          }
      
          public javax.jcr.Session startSession(Repository repository,String admin,String pass){
              javax.jcr.Session session = null;
              try{    
                  session = repository.login( new SimpleCredentials(admin,pass.toCharArray()));
              } catch(Exception e){
                  e.printStackTrace();
              }
              return session;
          }
      
          public void endSession(javax.jcr.Session session){
              try{
                  session.save();
                  session.logout();
              } catch(Exception e){
                  e.printStackTrace();
              }            
          }
      
      
      }
      

       

      And here is the bnd file for this bundle

      Export-Package: com.support.jcr 
      Import-Package: *
      #Private-Package:   
      # Include-Resource: 
      Bundle-Name: MyRepositoryManager
      Bundle-Description: Handles repository management
      Bundle-SymbolicName: MyRepositoryManager
      Bundle-Version: 1.0.0-SNAPSHOT
      Bundle-Activator: com.support.jcr.Activator
      

       

       

      Problem is that when I build this bundle and look at it in OSGi console, the exported packages show nothing (Exported Packages ---)

       

       

      How can I make this class available to code in my other packages. and why is it not exporting?

        • 1. Re: Bundle Not Exporting Package
          Yogesh Upadhyay Level 4

          I guess this class is missing interface definition ? Also I guess CRXDE build does not support non SCR annotation. Are you sure you don't see any error when you build this bundle ?

           

          Yogesh

          www.wemblog.com

          • 2. Re: Bundle Not Exporting Package
            Yadav Brijesh Level 1

            Hi All,

            Before answering your question I have few queries:-

            1. Please share screen shot where you see export package show nothing.

            2. What is your approach to access this class ?

            3. You have created this class as a services and any service can be access in other class using

                 @Reference MyRepositoryManager myRepositoryManager;

               OR in Jsp

                sling.getService("MyRepositoryManager");

             

            Regards

            Brijesh Yadav