我正在尝试从 servlet 访问 IBM FileNet P8 V5 数据存储,需要帮助来正确配置 WebSphere。
我在装有 IBM WebSphere 的 RedHat 7 服务器上全新安装了 FN P8。
我尝试了 https://www.ibm.com/support/knowledgecenter/en/SSNW2F_5.0.0/com.ibm.p8.ce.dev.ce.doc/ss_ecl_cews.htm 上给出的示例代码
它在纯 Java 类中工作正常;连接到服务器并检索数据存储名称。
我将代码复制到servlet,但收到错误: " com.filenet.api.exception.EngineRuntimeException: FNRCS0005E: SECURITY_INVALID_CREDENTIALS: 不允许访问内容引擎,因为内容引擎 API 库或 Web 服务接口 (WSI) 侦听器找不到所需的安全上下文信息。在安全上下文中找不到预期的凭据">
根据教程,我需要设置运行时环境。这就是我被困住的地方。我尝试通过 JVM 设置中的 WebSphere 控制台添加 jaas.conf.WebSphere,但显然没有正确操作。
package server;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Iterator;
import javax.security.auth.Subject;
import com.filenet.api.collection.ObjectStoreSet;
import com.filenet.api.core.Connection;
import com.filenet.api.core.Domain;
import com.filenet.api.core.Factory;
import com.filenet.api.core.ObjectStore;
import com.filenet.api.util.UserContext;
/**
* Servlet implementation class FNTest
* Ref: https://www.ibm.com/support/knowledgecenter/en/SSNW2F_5.0.0/com.ibm.p8.ce.dev.ce.doc/ss_ecl_cews.htm
*/
//@WebServlet(description = "Test for connection to Filenet", urlPatterns = { "/FNTest" })
@WebServlet("/FNTest")
public class FNTest extends HttpServlet {
private static final long serialVersionUID = 2L;
/**
* @see HttpServlet#HttpServlet()
*/
public FNTest() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>Filenet Function Test</title></head>");
out.println("<body>");
out.println("<h1>Filenet Function Test</h1>");
out.println("<p>Request server at " + request.getServletPath() + ".</p><hr>");
out.println("<p>Connecting to Filenet...</p>");
// Connect to Filenet
// Set connection parameters; substitute for the placeholders.
String uri = "http://filenet.myserver.com:9080/wsi/FNCEWS40MTOM/";
String username = "P8Admin";
String password = "P8Password";
// Make connection.
Connection conn = Factory.Connection.getConnection(uri);
Subject subject = UserContext.createSubject(conn, username, password, null);
UserContext.get().pushSubject(subject);
try
{
// Get default domain.
Domain domain = Factory.Domain.fetchInstance(conn, null, null);
System.out.println("Domain: " + domain.get_Name());
// Get object stores for domain.
ObjectStoreSet osSet = domain.get_ObjectStores();
ObjectStore store;
Iterator osIter = osSet.iterator();
while (osIter.hasNext())
{
store = (ObjectStore) osIter.next();
System.out.println("Object store: " + store.get_Name());
}
System.out.println("Connection to Content Engine successful");
}
finally
{
UserContext.get().popSubject();
}
out.println("<p>Completed</p>");
out.println("</body></html>");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
带有 servlet 的应用程序安装在同一台服务器上。
我看到你的 jaas 节为 null,这意味着它将采用 FileNetP8 作为默认节。代替空,请尝试FileNetP8WSI,因为您正在使用WSI端点进行连接。
Subject subject = UserContext.createSubject(conn, username, password, "FileNetP8WSI");
如果您提供空,它将使用"FileNetP8",这是用于IIOP连接的jaas节