由于getJaloResult()错误,使用flexiblesearch服务连接Hybris数据库的空指针异常

问题描述 投票:0回答:2

似乎是由于null方法,当尝试使用hybris灵活搜索服务连接到hybris数据库时发生[getJaloResult()指针异常。

我需要从hybris商业数据库中检索某些数据。我尝试通过hybris方法使用defaultFlexibleSearchService.search()灵活服务来执行此操作,但出现了null指针异常。似乎在search()方法尝试调用getJaloResult()方法时发生了异常。我对解决方案一无所知-感谢您提供任何提示。

我的班级定义代码在这里

package de.hybris.platform.integrationservices.audit;
import java.util.stream.Stream;
import com.sun.tools.javac.util.List;
import de.hybris.platform.audit.TypeAuditReportConfig;
import de.hybris.platform.audit.view.AuditViewService;
import de.hybris.platform.audit.view.impl.ReportView;
import de.hybris.platform.servicelayer.search.FlexibleSearchQuery;
import de.hybris.platform.servicelayer.search.FlexibleSearchService;
import de.hybris.platform.servicelayer.search.RelationQuery;
import de.hybris.platform.servicelayer.search.SearchResult;
import de.hybris.platform.servicelayer.search.impl.DefaultFlexibleSearchService;
import de.hybris.platform.integrationservices.model.IntegrationObjectModel;  

public class IntegrationObjectAudit implements AuditViewService
{
    private DefaultFlexibleSearchService defaultFlexibleSearchService;

    public IntegrationObjectAudit() {
        defaultFlexibleSearchService = new DefaultFlexibleSearchService();
    }

    public List<IntegrationObjectModel> searchModel(){
        String query = "SELECT {PK} FROM {IntegrationObject}";
        FlexibleSearchQuery flexibleSearchQuery = new FlexibleSearchQuery(query);
        flexibleSearchQuery.setCount(1);

        de.hybris.platform.servicelayer.search.SearchResult<IntegrationObjectModel> resListIntegrationModel = this.defaultFlexibleSearchService.search(query);
        List<IntegrationObjectModel> resList = (List<IntegrationObjectModel>) resListIntegrationModel.getResult();
        return resList;
    }
}
java database hybris
2个回答
0
投票
  1. 我的驱动程序类在这里:软件包de.hybris.platform.integrationservices.audit;

    import org.springframework.context.ApplicationContext;导入org.springframework.context.support.ClassPathXmlApplicationContext;

    import com.sun.tools.javac.util.List;导入de.hybris.platform.integrationservices.model.IntegrationObjectModel;

    公共类IntegrationObjectAuditTest{

    public static void main(String[] args)
    {
        // XXX Auto-generated method stub
    
        //ApplicationContext applicationContext = new ClassPathXmlApplicationContext("../resources/integrationobjectaudit-sprint.xml");
        //IntegrationObjectAudit integrationObjectAudit = (IntegrationObjectAudit) applicationContext.getBean("integrationObjectAudit");
    
        IntegrationObjectAudit integrationObjectAudit = new IntegrationObjectAudit();
    
        integrationObjectAudit.searchModel();
    
    }
    

    }

    3。错误信息在这里:线程“主”中的异常java.lang.NullPointerException在de.hybris.platform.servicelayer.search.impl.DefaultFlexibleSearchService.getJaloResult(DefaultFlexibleSearchService.java:511)在de.hybris.platform.servicelayer.search.impl.DefaultFlexibleSearchService.search(DefaultFlexibleSearchService.java:184)在de.hybris.platform.servicelayer.search.impl.DefaultFlexibleSearchService.search(DefaultFlexibleSearchService.java:328)在de.hybris.platform.servicelayer.search.impl.DefaultFlexibleSearchService.search(DefaultFlexibleSearchService.java:314)在de.hybris.platform.integrationservices.audit.IntegrationObjectAudit.searchModel(IntegrationObjectAudit.java:46)在de.hybris.platform.integrationservices.audit.IntegrationObjectAuditTest.main(IntegrationObjectAuditTest.java:22)


0
投票

有太多因素,例如会话,租户,限制等,可能会导致您尝试以外部方式访问外部应用程序的数据失败。我建议您使用从Hybris存储库访问数据的标准方法,而这种标准方法是Web服务。 Hybris提供扩展(请检查https://help.sap.com/viewer/9d346683b0084da2938be8a285c0c27a/1905/en-US/eb5f0e9c20464a488466790333e0e6e2.html)以创建基于REST的Web服务。您可以使用Web服务公开项目类型,并从任何类型的应用程序(Java或非Java)访问它们。


推荐问答