开发者

Vaadin-based web app is not accessible (404) in Apache Felix

开发者 https://www.devze.com 2023-04-04 04:40 出处:网络
UPDATE: SOLVED. I had to use a utility bundle to auto-load Vaadin apps in OSGI. See http://dev.vaadin.com/wiki/Arvue/OSGi

UPDATE: SOLVED. I had to use a utility bundle to auto-load Vaadin apps in OSGI. See http://dev.vaadin.com/wiki/Arvue/OSGi The bundles I used: org.vaadin.osgi, org.vaadin.osgi.staticres

===

I created a sample Vaadin project, built it with Maven + BND to as an OSGI bundle.

started Apache Felix with my "webui-1.0.jar" bundle along with its dependent "vaadin-6.6.6.jar". I can access localhost:8080, but localhost:8080/webui shows "Problem accessing /webui. Reason: NOT_FOUND".

"webui-1.0.jar" contains:

com   -- java classes
META-INF/MANIFEST.MF
VAADIN  -- empty now, but will contain Vaadin widgetsets and other resources
WEB-INF/web.xml

my web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>webui</display-name>
    <context-param>
        <description>
        Vaadin production mode</description>
        <param-name>productionMode</param-name>
        <param-value>false</param-value>
    </context-param>
    <servlet>
        <servlet-name>Vaadin1 Application</servlet-name>
        <servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
        <init-param>
            <description>
            Vaadin application class to start</description>
            <param-name>application</param-name>
            <param-value>com.mywebtest.MyVaadinApplication</param-value>
        </init-param>
        <init-param>
            <description>
            Application widgetset</description>
            <param-name>widgetset</param-name>
            <param-value>com.mywebtest.widgetset.Vaadin1Widgetset</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>Vaadin1 Application</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
</web-app>

my MANIFEST.MF file generated by Maven + BND:

Manifest-Version: 1
Bnd-LastModified: 1315684875698
Build-Jdk: 1.6.0_26
Built-By: ask
Bundle-ManifestVersion: 2
Bundle-Name: webui
Bundle-SymbolicName: webui
Bundle-Version: 1.0.0
Class-Path: 
Created-By: Apache Maven Bundle Plugin
Export-Package: com.mywebtest;uses:="com.vaadin,com.vaadin.ui";version="
 1.0.0"
Import-Packag开发者_Go百科e: com.vaadin,com.vaadin.ui
Tool: Bnd-1.43.0

Running bundles:

g! lb
START LEVEL 1
   ID|State      |Level|Name
    0|Active     |    0|System Bundle (3.2.2)
    1|Active     |    1|Apache Felix Bundle Repository (1.6.6)
    2|Active     |    1|Apache Felix Configuration Admin Service (1.2.8)
    3|Active     |    1|Apache Felix Dependency Manager (3.0.0)
    4|Active     |    1|Apache Felix Gogo Command (0.8.0)
    5|Active     |    1|Apache Felix Gogo Runtime (0.8.0)
    6|Active     |    1|Apache Felix Gogo Shell (0.8.0)
    7|Active     |    1|Apache Felix Http Api (2.2.0)
    8|Active     |    1|Apache Felix Http Jetty (2.2.0)
    9|Active     |    1|Apache Felix Metatype Service (1.0.4)
   10|Active     |    1|Apache Felix Declarative Services (1.6.0)
   11|Active     |    1|Apache Felix Web Management Console (3.1.8)
   12|Active     |    1|Vaadin (6.6.6)
   13|Active     |    1|webui (1.0.0)


None of the bundles you have in your runtime are going to automatically register a web endpoint for you, just because you wrote a file inside your bundle called web.xml.

You have two main options for publishing web applications in OSGi. The first is to obtain an instance of the HttpService service, which you should find is published by the "Felix Http Jetty" bundle.

The second, which is closer to "traditional" Java web app development, is to build a "Web Application Bundle" or WAB. This is basically a bundle like yours with a WEB-INF/web.xml. You will need to do 2 extra things for it to work though:

  • Declare the web application in your MANIFEST.MF like this: Web-ContextPath: /webui
  • Install a bundle that provides WAB support, such as the one provided by PAX Web.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号