Deploying OSGi Servlet to Domino (IBM presentation) - 404 error

浪尽此生 提交于 2019-12-11 18:28:52

问题


I´m trying to deploy an OSGi container in Domino using PDE tool with Equinox. I´m following the instruction in this IBM slideshow: http://www.slideshare.net/fiorep/domino-osgi-development?next_slideshow=1

However (as per slide #52) when I browse to http://localhost/simpledemo (after clicking Debug from Debug Configuration), I get a "404 file not found" error.

"simpledemo" is the alias mapped in the puligin.xml file (slide 44). The servlet name is however SimpleServlet.

Any ideas what is going on?? Any help is much appreciated.

My environment: Windows 2012 Server (on VM),Eclipse 3.6.2, Equinox, PDE tool and Domino Server 6.01 server.

reference: Deploying OSGi Servlet to Domino

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:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/33808182/deploying-osgi-servlet-to-domino-ibm-presentation-404-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!