发布于 2013-03-11 08:18:18
据我所见,您可以在NullPointerException中获得RankingServiceImpl:277,因为repository字段为null。我唯一能解释的方法是SCR注释在构建过程中没有触发。
说到这一点,我很惊讶您的包是从CQ5.5开始的,因为依赖项似乎是早期版本(我猜是5.4) --我建议在/system/console/bundles (搜索CRX示例书店演示)下对此进行反复检查。如果缺少导入,请尝试使用/src/impl/com.day.crx.sample.bookshop.bnd更新版本,如CQ5.5,或在CQ5.4上运行。
发布于 2013-12-20 05:33:00
RankingServiceImpl中的注释似乎适用于早期版本的CQ和CRX。以下是我为使其发挥作用所做的修改:
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
/**
* Default implementation of the ranking service.
* The ranking is updated through observation (based on OSGi events).
* The service can be used by clients to get the highest ranked products.
*/
@Component(immediate = true)
@Service(value = RankingService.class)
@Property(name = org.osgi.service.event.EventConstants.EVENT_TOPIC, value = SlingConstants.TOPIC_RESOURCE_ADDED)
public class RankingServiceImpl
implements RankingService, EventHandler, Runnable {
private Logger logger = LoggerFactory.getLogger(this.getClass());
// private Logger logger = LoggerFactory.getLogger("RankingServiceImpl");
private static final String PROPERTY_PREV_RANKING = "lowerRankingRef";
private static final String PROPERTY_NEXT_RANKING = "higherRankingRef";
private static final int SHOW_HIGHEST_RANKING = 3;
/** Flag for stopping the background service. */
private volatile boolean running = false;
/** A local queue for handling new orders. */
protected final BlockingQueue<String> orders = new LinkedBlockingQueue<String>();
@Reference
private SlingRepository repository;
@Reference
private ResourceResolverFactory resourceResolverFactory;https://stackoverflow.com/questions/15333547
复制相似问题