为什么我得到以下例外

时间:2011-04-29 06:48:35

标签: java alfresco

这是我的nodefinder.java文件

package com.acme.web.action.executer;

import java.sql.ResultSet;
import java.util.Map;

import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.component.UIActionLink;

import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.SearchParameters;
import org.alfresco.service.cmr.search.SearchService;

public class NodeFinder {

    // private static final String = null;
    SearchParameters sp = new SearchParameters();
    private NodeService nodeService;
    private FileFolderService fileFolderService;
    //geting the filefolder service                     
    public FileFolderService getFileFolderService() {
        return fileFolderService;
    }
    // setting the file folder service 
    public void setFileFolderService(FileFolderService fileFolderService) {
        this.fileFolderService = fileFolderService;
    }
// getting the node servise 
    public NodeService getNodeService() {
        return nodeService;
    }
    // setting the node server 

    public void setNodeService(NodeService nodeService) {
        this.nodeService = nodeService;
    }

    public void execute(ActionEvent event) {
        ResultSet resultSet_s = null;
        UIActionLink comp = (UIActionLink) event.getComponent();
        Map<String, String> params = comp.getParameterMap();
        String id = params.get("id1");
        System.out.println("1");

        NodeRef actionedUponNodeRef = new NodeRef(Repository.getStoreRef(), id);
        String qry_s = "@cm\\:name:train";
        System.out.println("2");

        SearchParameters sp_s = new SearchParameters();
        System.out.println("3");

        sp_s.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
        sp_s.setLanguage(SearchService.LANGUAGE_LUCENE);

        sp_s.setQuery(qry_s);
        System.out.println( "4" );

        Node node = new Node(actionedUponNodeRef);
        System.out.println("5");
        resultSet_s = (ResultSet) Repository.getServiceRegistry(
                FacesContext.getCurrentInstance()).getSearchService().query(
                sp_s);
        System.out.println("5.1");

        if (resultSet_s != null) {
            System.out.println("6");

            System.out.println("Node value is::::" + node.getName());

        }
    }
}

2 个答案:

答案 0 :(得分:5)

因为您导入了java.sql.ResultSet而不是与org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet兼容的露天类/接口

答案 1 :(得分:1)

查看该行...(ResultSet) Repository.getServiceRegistry(...,然后查看您的异常,最后查看您的导入。在那里,您将看到ResultSet实际上是java.sql.ResultSet(由您的ClassCastException消息指示)。

如果您再查看org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet的超类或接口,我会说您找不到任何java.sql.ResultSet。这就是你得到这个例外的原因。