我有点想开发OSGi捆绑软件和OSGi WAB。我正在使用Jboss AS 7.1服务器,在其中我应该同时使用OSGi捆绑包和WAB。我对WAB的依赖很少是OSGi捆绑软件,捆绑软件和WAB都在服务器的“ deployments”文件夹中。当我部署WAB时,它将在'WEB-INF / lib'中查找依赖项。如何在WAB文件之外包括依赖项的捆绑包而不在“ WEB-INF / lib”中添加这些捆绑包?

提前致谢。

编辑:
我遵循了此链接中提供的步骤:
http://www.rpgnextgen.com/wiki/doku.php?id=vaadin_7.4_osgi_web_application

我成功创建了WAB文件。我将所有必要的Vaadin依赖项作为OSGi捆绑软件部署在服务器的“ deployments”文件夹下。部署WAB文件时,不包含“ deployments”文件夹下的Vaadin依赖关系,但WAB文件正在“ WEB-INF / lib”路径中查找Vaadin依赖关系。
以下是我正在使用的pom.xml。

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.stpl.product.test</groupId>
<artifactId>VaadinWab</artifactId>
<version>1.0</version>
<packaging>war</packaging>

<name>VaadinWab OSGi Bundle</name>

<properties>
    <vaadin.version>7.5.7</vaadin.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.core</artifactId>
        <version>4.2.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-push</artifactId>
        <version>${vaadin.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-server</artifactId>
        <version>${vaadin.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-client</artifactId>
        <version>${vaadin.version}</version>
        <scope>provided</scope>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-themes</artifactId>
        <version>${vaadin.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.compendium</artifactId>
        <version>4.2.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <plugins>

        <plugin>
            <!-- Need to use this plugin to build war files -->
            <artifactId>maven-war-plugin</artifactId>
            <groupId>org.apache.maven.plugins</groupId>
            <version>2.3</version>
            <configuration>
                <archive>
                    <!-- add bundle plugin generated manifest to the war -->
                    <manifestFile>
                        ${project.build.outputDirectory}/META-INF/MANIFEST.MF
                    </manifestFile>
                    <!-- Adding Bundle-ClassPath in maven-bundle-plugin confuses that plugin
                    and it generates wrong Import-Package, etc. So, we generate it here. -->
                    <manifestEntries>
                        <Bundle-ClassPath>WEB-INF/classes/</Bundle-ClassPath>
                    </manifestEntries>
                </archive>
                <!-- We don't always have a web.xml -->
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>

        <plugin>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <archive>
                    <!-- add bundle plugin generated manifest to the jar -->
                    <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                </archive>
            </configuration>
        </plugin>


        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.3.7</version>
            <extensions>true</extensions>
            <executions>
                <execution>
                    <id>bundle-manifest</id>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>manifest</goal>
                    </goals>
                </execution>
                <execution>
                    <id>bundle-install</id>
                    <phase>install</phase>
                    <goals>
                        <goal>install</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <supportedProjectTypes>
                    <supportedProjectType>ejb</supportedProjectType>
                    <supportedProjectType>war</supportedProjectType>
                    <supportedProjectType>bundle</supportedProjectType>
                    <supportedProjectType>jar</supportedProjectType>
                </supportedProjectTypes>
                <instructions>
                    <_include>osgi.properties</_include>
                    <Bundle-PresentationName>${project.artifactId}</Bundle-PresentationName>
                    <Embed-Dependency>*;scope=compile</Embed-Dependency>
                    <Embed-Transitive>true</Embed-Transitive>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>

<profiles>
    <profile>
        <id>build-for-felix</id>
        <dependencies>
            <dependency>
                <groupId>org.apache.felix</groupId>
                <artifactId>org.apache.felix.main</artifactId>
                <version>4.0.3</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>1.7</version>
                    <executions>
                        <execution>
                            <id>compile</id>
                            <phase>package</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                            <configuration>
                                <target>
                                    <pathconvert property="plugins.jars" pathsep="${path.separator}">
                                        <path refid="maven.runtime.classpath"/>
                                        <map from="${project.build.directory}${file.separator}classes" to=""/>
                                    </pathconvert>
                                    <pathconvert pathsep=" " property="bundles">
                                        <path path="${plugins.jars}"/>
                                        <mapper>
                                            <chainedmapper>
                                                <flattenmapper/>
                                                <globmapper from="*" to="file:modules/*" casesensitive="no"/>
                                            </chainedmapper>
                                        </mapper>
                                    </pathconvert>
                                    <propertyfile file="${project.build.directory}/config.properties">
                                        <entry key="felix.auto.start" value="${bundles} file:modules/${project.build.finalName}.jar"/>
                                        <entry key="org.osgi.framework.bootdelegation" value="*"/>
                                    </propertyfile>
                                    <copy file="${maven.dependency.org.apache.felix.org.apache.felix.main.jar.path}" tofile="${project.build.directory}/felix.jar"/>
                                </target>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>2.3</version>
                    <executions>
                        <execution>
                            <id>create-executable-jar</id>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                            <configuration>
                                <descriptors>
                                    <descriptor>${basedir}/src/main/assembly/felix.xml</descriptor>
                                </descriptors>
                                <finalName>${project.build.finalName}</finalName>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
    <profile>
        <id>run-on-felix</id>
        <dependencies>
            <dependency>
                <groupId>org.apache.felix</groupId>
                <artifactId>org.apache.felix.main</artifactId>
                <version>4.0.3</version>
                <scope>provided</scope>
            </dependency>
            <!-- org.apache.felix:org.apache.felix.gogo.shell:0.6.1 useless from Maven since stdin is swallowed -->
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>1.7</version>
                    <configuration>
                        <target>
                            <property name="vm.args" value=""/>
                            <pathconvert property="plugins.jars" pathsep="${path.separator}">
                                <path refid="maven.runtime.classpath"/>
                                <map from="${project.build.directory}${file.separator}classes" to=""/>
                            </pathconvert>
                            <makeurl property="urls" separator=" ">
                                <path path="${plugins.jars}"/>
                                <path location="${project.build.directory}/${project.build.finalName}.jar"/>
                            </makeurl>
                            <propertyfile file="${project.build.directory}/run.properties">
                                <entry key="felix.auto.start" value="${urls}"/>
                                <entry key="felix.auto.deploy.action" value="uninstall,install,update,start"/>
                                <entry key="org.osgi.framework.storage" value="${project.build.directory}${file.separator}felix-cache"/>
                                <entry key="org.osgi.framework.bootdelegation" value="*"/>
                            </propertyfile>
                            <makeurl property="run.properties.url" file="${project.build.directory}/run.properties"/>
                            <java fork="true" jar="${maven.dependency.org.apache.felix.org.apache.felix.main.jar.path}">
                                <sysproperty key="felix.config.properties" value="${run.properties.url}"/>
                                <jvmarg line="${vm.args}"/>
                            </java>
                        </target>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>




基本上,我想做的是创建一个WAB项目,该项目将其他捆绑软件用作依赖项,而不是在.war文件中使用“ WEB-INF / lib”。

将war文件部署到服务器时,最终出现以下异常:

10:52:07,718 WARN  [org.ops4j.pax.web.jsp.internal.JasperClassLoader] (Executor: 2) Exception while calculating location of imported bundles: java.net.MalformedURLException: no protocol: vaadin-server-7.5.7.jar
    at java.net.URL.<init>(URL.java:585) [rt.jar:1.7.0_65]
    at java.net.URL.<init>(URL.java:482) [rt.jar:1.7.0_65]
    at java.net.URL.<init>(URL.java:431) [rt.jar:1.7.0_65]
    at org.ops4j.pax.web.jsp.internal.JasperClassLoader.getLocationsOfBundlesInClassSpace(JasperClassLoader.java:177)
    at org.ops4j.pax.web.jsp.internal.JasperClassLoader.getClassPathJars(JasperClassLoader.java:157)
    at org.ops4j.pax.web.jsp.internal.JasperClassLoader.<init>(JasperClassLoader.java:73)
    at org.ops4j.pax.web.jsp.JspServletWrapper.<init>(JspServletWrapper.java:59)
    at org.ops4j.pax.web.service.internal.HttpServiceStarted.registerJsps(HttpServiceStarted.java:490)
    at org.ops4j.pax.web.service.internal.HttpServiceProxy.registerJsps(HttpServiceProxy.java:194)
    at org.ops4j.pax.web.extender.war.internal.RegisterWebAppVisitorWC.visit(RegisterWebAppVisitorWC.java:169)
    at org.ops4j.pax.web.extender.war.internal.model.WebApp.accept(WebApp.java:590)
    at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$HttpServiceListener.register(WebAppPublisher.java:170)
    at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$HttpServiceListener.serviceChanged(WebAppPublisher.java:155)
    at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$HttpServiceListener.serviceChanged(WebAppPublisher.java:119)
    at org.ops4j.pax.swissbox.tracker.ReplaceableService.setService(ReplaceableService.java:114)
    at org.ops4j.pax.swissbox.tracker.ReplaceableService.access$100(ReplaceableService.java:28)
    at org.ops4j.pax.swissbox.tracker.ReplaceableService$CollectionListener.serviceAdded(ReplaceableService.java:183)
    at org.ops4j.pax.swissbox.tracker.ServiceCollection$Tracker.addingService(ServiceCollection.java:181)
    at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:896) [ServiceTracker$Tracked.class:]
    at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:261)
    at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:184)
    at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:339) [ServiceTracker.class:]
    at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:273) [ServiceTracker.class:]
    at org.ops4j.pax.swissbox.tracker.ServiceCollection.onStart(ServiceCollection.java:139)
    at org.ops4j.pax.swissbox.lifecycle.AbstractLifecycle$Stopped.start(AbstractLifecycle.java:121)
    at org.ops4j.pax.swissbox.lifecycle.AbstractLifecycle.start(AbstractLifecycle.java:49)
    at org.ops4j.pax.swissbox.tracker.ReplaceableService.onStart(ReplaceableService.java:146)
    at org.ops4j.pax.swissbox.lifecycle.AbstractLifecycle$Stopped.start(AbstractLifecycle.java:121)
    at org.ops4j.pax.swissbox.lifecycle.AbstractLifecycle.start(AbstractLifecycle.java:49)
    at org.ops4j.pax.web.extender.war.internal.WebAppPublisher.publish(WebAppPublisher.java:81)
    at org.ops4j.pax.web.extender.war.internal.WebXmlObserver.deploy(WebXmlObserver.java:200)
    at org.ops4j.pax.web.extender.war.internal.WebXmlObserver.addingEntries(WebXmlObserver.java:159)
    at org.ops4j.pax.swissbox.extender.BundleWatcher$3.run(BundleWatcher.java:224)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_65]
    at java.util.concurrent.FutureTask.run(FutureTask.java:262) [rt.jar:1.7.0_65]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178) [rt.jar:1.7.0_65]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292) [rt.jar:1.7.0_65]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_65]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_65]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_65]

最佳答案

好的,这是Pax-Web的真正旧版本(当前版本为4)。
此行为的原因是,还要对@NeilBartlett进行解释,以便能够保留所有可能的标记库。
Pax-Web容器遍历导入的捆绑软件,并在该捆绑软件中查找标签库,以使其可用于JSP JasperCompiler。
这是随着时间的推移而得到改进的部分之一。在Pax-Web 1.x中完成此操作的方式有点“蛮力”,但需要容器返回有效的“捆绑” URI。与std相比,它看起来像JBoss容器。 Felix和Equinox的工作原理有所不同。

08-04 21:52