2

我创建了一个动态 Web 项目。我安装了 Tomcat 6.0 来运行它。我正在尝试使用 DFC 创建 Web 界面,它将连接到文档库并运行一些查询。当我尝试运行此代码时,我收到了下面提到的错误。由于我对 DFC 编程非常陌生,因此感谢您提供任何帮助。谢谢。

欢迎.jsp

<div class="w3ls_order w3ls_order1">
                    <Form method="post" action="Model">
                    <a class="popup-with-zoom-anim"><button class="button" type="submit">Generate</button></a>
                    </Form>

模型.java (Servlet)

package com;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.xml.sax.SAXException;

import com.documentum.fc.common.DfException;

/**
 * Servlet implementation class Model
 */
public class Model extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * Default constructor. 
     */
    public Model() {
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub


    }


    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */


    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        System.out.println("All Good!");
    }

    public void docbase() throws SAXException, IOException
    {
        System.out.println("All good");
        Connection con = new Connection();

        try {
            con.docBasecon();
        } catch (DfException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}

连接.java

package com;

import java.io.File;
import java.io.IOException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;

import com.documentum.fc.common.DfException;

public class Connection {



    public static void docBasecon() throws SAXException, IOException, DfException
    {
        File fXmlFile = new File("C:/Users/SAHAROM/workspace/License Utility/config.xml");
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        try {
            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
            Document doc = dBuilder.parse(fXmlFile);

            doc.getDocumentElement().normalize();
            System.out.println("Root element :" + doc.getDocumentElement().getNodeName());

            NodeList nList = doc.getElementsByTagName("docbase");

            DocbaseConnection dbcon = new DocbaseConnection();

            for (int temp = 0; temp < nList.getLength(); temp++) 
            {
                Node nNode = nList.item(temp);
                //System.out.println("\nCurrent Element :" + nNode.getNodeName());

                if (nNode.getNodeType() == Node.ELEMENT_NODE) 
                {

                    Element eElement = (Element) nNode;

                    String docbaseName = eElement.getElementsByTagName("name").item(0).getTextContent();
                    String docbaseUname = eElement.getElementsByTagName("username").item(0).getTextContent();
                    String docbasePass = eElement.getElementsByTagName("password").item(0).getTextContent();

                    dbcon.DfcCon(docbaseName,docbaseUname,docbasePass);
                }




            }



        } catch (ParserConfigurationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }


}

DocbaseConnection.java

package com;

import com.documentum.fc.client.DfClient;
import com.documentum.fc.client.IDfClient;
import com.documentum.fc.client.IDfQuery;
import com.documentum.fc.client.IDfSession;
import com.documentum.fc.client.IDfSessionManager;
import com.documentum.fc.client.IDfSysObject;
import com.documentum.fc.common.DfException;
import com.documentum.fc.common.DfLoginInfo;
import com.documentum.fc.common.IDfLoginInfo;
import com.documentum.xml.xdql.DfXmlQuery;
import com.documentum.xml.xdql.IDfXmlQuery;


public class DocbaseConnection {


IDfSessionManager sessionMrg = null;
IDfSession session = null;

    public void DfcCon(String docbaseName, String username,
            String password) throws DfException {


        System.out.println("\nResult" +docbaseName +username +password);



            String Docbase = docbaseName;



            IDfLoginInfo loginInfo = new DfLoginInfo();
            loginInfo.setUser(username);
            loginInfo.setPassword(password);
            System.out.println("all good");
            sessionMrg = DfClient.getLocalClient().newSessionManager();
            System.out.println("all gooD");
            sessionMrg.setIdentity(Docbase, loginInfo);
            System.out.println("all gooD");
            session = sessionMrg.getSession(Docbase);
            System.out.println("All good");

            String query = Getquery();

            System.out.println("Query :" +query);


            if(sessionMrg != null && session != null) {
                sessionMrg.release(session);
            }









    }


        public String Getquery()
        {

            String query = "select count(*) from dm_user";
            return query;

        }




}

Tomcat 日志

INFO: Marking servlet Model as unavailable
Sep 25, 2016 12:13:02 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet Model
java.lang.ClassNotFoundException: com.documentum.fc.common.DfException
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
    at java.lang.Class.getConstructor0(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1149)
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:827)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:612)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:503)
    at java.lang.Thread.run(Unknown Source)

罐子

罐子清单

4

2 回答 2

1

在 Connection.java 中,您有以下方法:

public static void docBasecon() throws SAXException, IOException, DfException

DfException 尚未导入,因此出现错误。因此在 Connection.java 中添加以下 import 语句:

import com.documentum.fc.common.DfException;
于 2016-09-25T07:01:21.647 回答
0

我的应用程序现在运行良好。我不得不将 dfc.jar 和 dctm.jar 放在 tomcat 的 lib 文件夹中。

于 2016-09-27T12:10:36.213 回答