문제 설명
Domino에 OSGi 서블릿 배치(IBM 프리젠테이션) ‑ 404 오류 (Deploying OSGi Servlet to Domino (IBM presentation) ‑ 404 error)
Equinox와 함께 PDE 도구를 사용하여 Domino에 OSGi 컨테이너를 배포하려고 합니다. 저는 이 IBM 슬라이드쇼의 지침을 따릅니다. http://www .slideshare.net/fiorep/domino‑osgi‑development?next_slideshow=1
그러나 (슬라이드 #52에 따름) http://localhost/simpledemo(디버그 구성에서 디버그를 클릭한 후)에서 "404 파일을 찾을 수 없음" 오류가 발생합니다.
"simpledemo" puligin.xml 파일에 매핑된 별칭입니다(슬라이드 44). 그러나 서블릿 이름은 SimpleServlet입니다.
무슨 생각이야?? 도움을 주시면 감사하겠습니다.
내 환경: Windows 2012 Server(VM), Eclipse 3.6.2, Equinox, PDE 도구 및 Domino Server 6.01 서버.
SimpleServlet.Java
package com.ibm.ls2012;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.ServletException;
import java.io.IOException;
import java.io.PrintWriter;
public class SimpleServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public SimpleServlet() {
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
final PrintWriter pw = resp.getWriter();
resp.setContentType("text/html");
pw.println("<HTML");
pw.println("<HEAD><TITLE>SHOW112 ‑ Simple Servlet Demo</TITLE></HEAD>");
pw.println("<BODY>");
pw.println("<BR>");
pw.println("hello world. feeling cold yet?");
}}
참조 솔루션
방법 1:
I followed the similar demo and for some reason have something slightly different. I'm not sure if something's changed or if I took a slightly different approach based on experience of Vaadin web applications on Liberty.
My plugin.xml has:
<extension
point="com.ibm.pvc.webcontainer.application">
<contextRoot>
/helloWorldWC
</contextRoot>
<contentLocation>
WebContent
</contentLocation>
</extension>
So that's giving a root for the plugin application of "localhost/helloWorldWC/".
Then, in the WebContent\WEB‑INF there's a web.xml that is:
<?xml version="1.0" encoding="UTF‑8"?>
<!DOCTYPE web‑app PUBLIC "‑//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web‑app_2_3.dtd">
<web‑app>
<servlet>
<servlet‑name>HelloWorldServlet</servlet‑name>
<servlet‑class>com.paulwithers.helloWorld.HelloWorldServlet</servlet‑class>
</servlet>
<servlet‑mapping>
<servlet‑name>HelloWorldServlet</servlet‑name>
<url‑pattern>helloWorld</url‑pattern>
</servlet‑mapping>
</web‑app>
So this is saying anything with a subsequent URL pattern of "helloWorld", so "localhost/helloWorldWC/helloWorld" should use the HelloWorldServlet. That's defined in the preceding element as mapping to com.paulwithers.helloWorld.HelloWorldServlet
class. You can change the url‑pattern to "*" and then localhost/helloWorldWC will map to the HelloWorldServlet class.
To extend that, instead of pointing to an individual servlet class, you can point to a class that extends javax.ws.rs.core.Application
which can contain a getClasses() method that returns a Set of all servlets contributed. Each servlet can then have an @Path annotation to define what the path used should be (all this is standard JAX‑RS, I believe). It's a process I used in the attachment to this blog post. The attachment uses OpenNTF Domino API, but the core elements of interest to you ‑ plugin.xml, web.xml, Application class and annotations on Servlet class ‑ are standard.
방법 2:
First thing I would check is that the plugin is correctly loaded. From the server console type: tell http osgi ss {yourpluginname}. Make sure the plugin is loaded and has an active state. If state is installed, then you have a missing constraint issue, to diagnose, type tell http osgi diag {pluginid}. Note: you can get the pluginid from the first ss command.
If state is resolved, then you need to start it manually using the following command: tell http osgi start {pluginid}. Note: being in a resolved state is not expected, the Domino Server should automatically start all plugins.
(by mikki、Paul Stephen Withers、David Taieb)