Aem CQ5(CRX)书店应用程序错误 我签出了源代码fromhttp://dev.day.com/docs/en/crx/current/getting_started/first_steps_with_crx.html#Step%20Two:%20Check%20out%20CRX%20Bookstore%20Example

Aem CQ5(CRX)书店应用程序错误 我签出了源代码fromhttp://dev.day.com/docs/en/crx/current/getting_started/first_steps_with_crx.html#Step%20Two:%20Check%20out%20CRX%20Bookstore%20Example,aem,crx,Aem,Crx,当我试图调用http://:4502/products.html时 实际结果应列出书店应用程序中的产品页面 我在/apps/bookstore/components/ranking/ranking.jsp中得到了“无法向/products.html提供请求”:您使用的是什么版本的产品?在什么操作系统上? 我正在Windows7上使用CQ5.5(CRX2.3) 从我看到的情况来看,您在RankingServiceImpl:277中得到了NullPointerException,因为reposit

当我试图调用http://:4502/products.html时

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

  • 我在/apps/bookstore/components/ranking/ranking.jsp中得到了“无法向/products.html提供请求”:您使用的是什么版本的产品?在什么操作系统上? 我正在Windows7上使用CQ5.5(CRX2.3)

  • 从我看到的情况来看,您在
    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上运行它。

    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;
    
    import org.apache.felix.scr.annotations.Property;
    导入org.apache.felix.scr.annotations.Reference;
    /**
    *排名服务的默认实现。
    *通过观察更新排名(基于OSGi事件)。
    *客户可以使用该服务获得排名最高的产品。
    */
    @组件(立即=真)
    @服务(value=RankingService.class)
    @属性(name=org.osgi.service.event.EventConstants.event\u主题,value=SlingConstants.TOPIC\u添加的资源)
    公共类RankingServiceImpl
    实现RankingService、EventHandler、Runnable{
    私有记录器Logger=LoggerFactory.getLogger(this.getClass());
    //私有记录器Logger=LoggerFactory.getLogger(“RankingServiceImpl”);
    私有静态最终字符串属性\u PREV\u RANKING=“lowerRankingRef”;
    私有静态最终字符串属性\u NEXT\u RANKING=“higherRankingRef”;
    私人静态最终整数显示最高排名=3;
    /**停止后台服务的标志*/
    private volatile boolean running=false;
    /**用于处理新订单的本地队列*/
    受保护的最终封锁队列顺序=新的LinkedBlockingQueue();
    @参考文献
    私有SlingRepository存储库;
    @参考文献
    私有ResourceResolveFactory ResourceResolveFactory;
    
    error.log中是否有其他条目?另外,请尝试在/var/classes下清除CRX中缓存的Java文件。CQ5网站上有一个用于调用此书店的输入错误,它被列为http://:7402/products.html。它必须是http://:7402/products/english.html。在我调用正确的URL后,这可以正常工作,但它没有列出所有产品CT在某种程度上是在中间中断,下面的异常不能满足请求/产品/英语/ HTML在/Apps/书店/组件/排名/排名中。JSP

    异常:Or.ApACH.SLIN .API.SLIGNECTOR:在Or.ApAC.SLIG.Script脚本.jsp .JasPiel.Servel.JSPServelWrPAPP.