HTTP 状态 500 - 实例化 servlet 时出错 class com.Model

HTTP Status 500 - Error instantiating servlet class com.Model

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

Welcome.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>

Model.java(小服务程序)

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();
        }
    }

}

Connection.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();
        }

    }


}

文档库Connection.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)

罐子

Jars List

在Connection.java中你有以下方法:

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

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

import com.documentum.fc.common.DfException;

我的申请现在 运行 没问题。我不得不将 dfc.jar 和 dctm.jar 放在 tomcat 的 lib 文件夹中。