CQ5(CRX)书店应用程序错误

时间:2013-03-11 07:48:44

标签: cq5 crx

  1. 我查了源代码来自:http://dev.day.com/docs/en/crx/current/getting_started/first_steps_with_crx.html#Step%20Two:%20Check%20out%20CRX%20Bookstore%20Example
  2. 当我尝试调用http://:4502 / products.html

  3. 实际结果应列出书店应用程序的产品页面

  4. 我收到了“无法向/apps/bookstore/components/ranking/ranking.jsp中的/products.html发送请求:您使用的是哪个版本的产品?在什么操作系统上? 我在Windows 7上使用CQ5.5(CRX 2.3) http://code.google.com/p/crxzon/issues/detail?id=4&thanks=4&ts=1362987616

2 个答案:

答案 0 :(得分:0)

从我看到的,你在RankingServiceImpl:277中得到NullPointerException,因为repository字段为空。我能解释的唯一方法就是SCR注释在构建期间不会触发。

说,我真的很惊讶你的捆绑开始于CQ 5.5,因为依赖似乎是早期版本(5.4我想) - 我建议在/system/console/bundles下仔细检查(搜索 CRX - 示例书店演示)。如果您缺少那里的导入,请尝试使用/src/impl/com.day.crx.sample.bookshop.bnd来更新CQ 5.5中的版本,或者在CQ 5.4上运行。

答案 1 :(得分:0)

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;