- 我从 http://dev.day.com/docs/en/crx/current/getting_started/first_steps_with_crx.html#Step%20Two:%20Check%20out%20CRX%20Bookstore%20Example 查看了源代码
当我尝试调用 http://:4502/products.html
实际结果应列出书店应用程序中的产品页面
- 我收到“无法在 /apps/bookstore/components/ranking/ranking.jsp 中向 /products.html 提供请求:您使用的是什么版本的产品?在什么操作系统上?我正在使用 CQ5.5 (CRX 2.3) Windows 7 http://code.google.com/p/crxzon/issues/detail?id=4&thanks=4&ts=1362987616
问问题
243 次
2 回答
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;
于 2013-12-20T05:33:00.993 回答
0
从我所见,你得到 NullPointerException in RankingServiceImpl:277
,因为该repository
字段为空。我可以解释的唯一方法是在构建过程中没有触发 SCR 注释。
话虽如此,我实际上很惊讶您的捆绑包从 CQ 5.5 开始,因为依赖项似乎是早期版本(我猜是 5.4)——我建议在/system/console/bundles
(搜索CRX - Sample Bookstore Demo)下仔细检查。如果您在那里缺少导入,请尝试/src/impl/com.day.crx.sample.bookshop.bnd
像在 CQ 5.5 中那样更新版本,或者在 CQ 5.4 上运行它。
于 2013-03-11T08:18:18.270 回答