Vaadin使用错误的资源路径作为OSGi servlet

问题描述

我已经按照here的描述将一个简单的Vaadin应用程序部署到Apache Karaf中。现在,在检查http:list时,资源servlet和我自己的servlet可用:

ID  | Servlet               | Servlet-Name                              | State       | Alias                                            | Url
----+-----------------------+-------------------------------------------+-------------+--------------------------------------------------+---------------------------------------------------
52  | ResourceServlet       | /VAADIN/themes/valo/*:/VAADIN/themes/valo | Deployed    | /VAADIN/themes/valo/*                            | [/VAADIN/themes/valo/*]
52  | ResourceServlet       | gz                                        | Deployed    | /VAADIN/vaadinBootstrap.js.gz                    | [/VAADIN/vaadinBootstrap.js.gz/*]
52  | ResourceServlet       | js                                        | Deployed    | /VAADIN/vaadinBootstrap.js                       | [/VAADIN/vaadinBootstrap.js/*]
52  | ResourceServlet       | DefaultWidgetSet                          | Deployed    | /VAADIN/widgetsets/com.vaadin.DefaultWidgetSet/* | [/VAADIN/widgetsets/com.vaadin.DefaultWidgetSet/*]
115 | MyVaadinServlet       | ServletModel-8                            | Deployed    |                                                  | [/*]

http://localhost:8181/下访问我的应用程序时,出现以下消息:

Failed to load the bootstrap javascript: /vaadin-8.11.2/VAADIN/vaadinBootstrap.js?v=8.11.2

此资源确实不可访问,但是资源http://localhost:8181/VAADIN/vaadinBootstrap.js?v=8.11.2可用。因此,似乎已部署的服务中缺少版本前缀/vaadin-8.11.2,还是servlet错误地尝试访问它们?

MyVaadinServlet就像文档页面上所述。我在pom.xml中使用的是maven-bundle-plugin而不是bnd,它看起来像这样:

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>de.myapplication</groupId>
        <artifactId>myapplication-parent</artifactId>
        <version>1.0.0</version>
    </parent>

    <artifactId>myapplication-frontend</artifactId>
    <packaging>bundle</packaging>

    <properties>
        <vaadin.version>8.11.2</vaadin.version>
    </properties>

    <repositories>
        <repository>
            <id>vaadin-addons</id>
            <url>http://maven.vaadin.com/vaadin-addons</url>
        </repository>
    </repositories>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-bom</artifactId>
                <version>${vaadin.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-server</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-push</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-client-compiled</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-themes</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-osgi-integration</artifactId>
            <version>${vaadin.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.cmpn</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.annotation</artifactId>
            <version>${osgi.version}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- Specify compiler settings -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <maxmem>256M</maxmem>
                </configuration>
            </plugin>

            <!-- Generate bundle manifest -->
            <plugin>
                <groupId>org.apache.Felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>${maven-bundle-plugin.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                        <Bundle-Version>${project.version}</Bundle-Version>
                        <Export-Package>
                            de.myapplication.frontend*;version=${project.version}
                        </Export-Package>
                        <Import-Package>
                            *
                        </Import-Package>
                    </instructions>
                </configuration>
            </plugin>

            <!-- Include bundle manifest in JAR -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <archive>
                        <manifestFile>${project.build.outputDirectory}/meta-inf/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <!-- Vaadin pre-release repositories -->
            <id>vaadin-prerelease</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>

            <repositories>
                <repository>
                    <id>vaadin-prereleases</id>
                    <url>http://maven.vaadin.com/vaadin-prereleases</url>
                </repository>
                <repository>
                    <id>vaadin-snapshots</id>
                    <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>vaadin-prereleases</id>
                    <url>http://maven.vaadin.com/vaadin-prereleases</url>
                </pluginRepository>
                <pluginRepository>
                    <id>vaadin-snapshots</id>
                    <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>

</project>

我还需要配置其他东西才能使其正常工作吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)