有人在 ServiceMix4 中成功通过 Spring OSGi Web 运行 Tomcat 吗?

发布于 2024-09-24 23:51:34 字数 9432 浏览 10 评论 0原文

我们已经在标准 OSGi 应用程序中使用 Fuse 的 Apache ServiceMix 版本 4.2.0-fuse-02-00 一段时间了,并且取得了相当成功。我们还一直在利用 CXF 来提供 Web 服务。

现在,我们希望将 Web 应用程序部署到 servicemix4 并利用 OSGi 层来实现依赖项和服务。然而,PAX Web 中的打包似乎不支持我们经常使用的标签库:Richfaces、facelets 等。 似乎允许工作标签库的 springDM 解决方案概述如下: http://static.springsource.org/osgi/docs/current/reference/html/web.html 应该可以,但是我很难启动网络服务器,我目前收到此错误。

Exception in thread "WebExtender-Init" java.lang.NoClassDefFoundError: org/apache/catalina/Loader
 at org.springframework.osgi.web.extender.internal.activator.WarListenerConfiguration.createDefaultWarDeployer(WarListenerConfiguration.java:194)
 at org.springframework.osgi.web.extender.internal.activator.WarListenerConfiguration.<init>(WarListenerConfiguration.java:105)
 at org.springframework.osgi.web.extender.internal.activator.WarLoaderListener$1.run(WarLoaderListener.java:366)
 at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: org.apache.catalina.Loader
 at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:494)
 at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
 at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)
 at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
 ... 4 more

我已经按照 Spring 文档的建议创建了 2 个片段。但它们不会解析,它们仍保持为已安装

1) 网络服务器配置片段 定义了以下片段主机:

<Fragment-Host>org.springframework.osgi.web.extender</Fragment-Host>

并且有一个文件 META-INF/spring/extender/tomcat-deployer.xml 包含

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.springframework.org/schema/beans   
       http://www.springframework.org/schema/beans/spring-beans.xsd">
 <bean id="warDeployer"
        class="org.springframework.osgi.web.deployer.tomcat.TomcatWarDeployer" />

</beans>

2) 和一个 Catalina Config 片段 具有以下主机:

<Fragment-Host>org.springframework.osgi.catalina.start.osgi</Fragment-Host>

并定义了conf/server.xml,它主要是tomcat 6 server.xml文件的通用Windows安装的副本。

这几天我也一直在搞乱依赖关系,这很困难。但为了达到这个目的,我一直在搞乱以下功能。我还安装了fuse-servicemix 默认的“jpa-hibernate”功能。

<feature name="spring-dependencies" version="1.0.0">
    <bundle>mvn:org.osgi/org.osgi.compendium/4.1.0</bundle>
    <bundle>mvn:javax.el/com.springsource.javax.el/1.0.0</bundle>
    <bundle>mvn:javax.xml.ws/com.springsource.javax.xml.ws/2.1.1</bundle>
    <bundle>mvn:javax.xml.stream/com.springsource.javax.xml.stream/1.0.1</bundle>
    <bundle>mvn:javax.xml.rpc/com.springsource.javax.xml.rpc/1.1.0</bundle>
    <bundle>mvn:javax.xml.soap/com.springsource.javax.xml.soap/1.3.0</bundle>
    <bundle>mvn:javax.persistence/com.springsource.javax.persistence/1.99.0</bundle>
    <bundle>mvn:org.aspectj/com.springsource.org.aspectj.tools/1.6.8.RELEASE</bundle>
    <bundle>mvn:org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1</bundle>
    <bundle>mvn:org.apache.commons/com.springsource.org.apache.commons.lang/2.4.0</bundle>
    <bundle>mvn:org.apache.xmlcommons/com.springsource.org.apache.xmlcommons/1.3.4</bundle>
    <bundle>mvn:org.jboss.el/com.springsource.org.jboss.el/2.0.0.GA</bundle>
    <bundle>mvn:org.jboss.javassist/com.springsource.javassist/3.9.0.GA</bundle>
    <bundle>mvn:org.aopalliance/com.springsource.org.aopalliance/1.0.0</bundle>
</feature>
<feature name="spring" version="1.0.0">
    <!--feature version="1.0.0">spring-dependencies</feature-->
    <!--bundle>mvn:org.springframework.osgi/org.springframework.osgi.core/1.2.1</bundle--> <!-- there is 1.2.1, but servicemix plays the 1.2.0 game -->
    <!--bundle>mvn:org.springframework.osgi/org.springframework.osgi.io/1.2.1</bundle--> <!-- there is 1.2.1, but servicemix plays the 1.2.0 game -->
    <!--bundle>mvn:org.springframework.osgi/org.springframework.osgi.extender/1.2.1</bundle--> <!-- there is 1.2.1, but servicemix plays the 1.2.0 game -->
    <!--bundle>mvn:org.springframework.osgi/org.springframework.osgi.extensions.annotation/1.2.1</bundle--> <!-- there is 1.2.1, but servicemix plays the 1.2.0 game -->
    <!-- commenting the 3.0.4 release to see if i can get by with the prepacked version in servicmeix bundle>mvn:org.springframework/org.springframework.aop/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.asm/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.aspects/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.beans/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.context/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.context.support/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.core/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.expression/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.jms/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.jdbc/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.transaction/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.orm/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework.security/org.springframework.security.core/3.0.3.RELEASE</bundle-->
    <bundle>mvn:org.springframework.osgi/org.springframework.osgi.web/1.2.0</bundle> <!-- there is 1.2.1, but servicemix plays the 1.2.0 game -->
    <bundle>mvn:org.springframework.osgi/org.springframework.osgi.web.extender/1.2.0</bundle>  <!-- there is 1.2.1, but servicemix plays the 1.2.0 game -->
</feature>
<feature name="tomcat" version="1.0.0">
    <!--feature version="1.0.0">spring</feature-->
    <bundle>mvn:javax.ejb/com.springsource.javax.ejb/3.0.0</bundle>
    <bundle>mvn:javax.activation/com.springsource.javax.activation/1.1.1</bundle>
    <bundle>mvn:javax.mail/com.springsource.javax.mail/1.4.1</bundle>
    <bundle>mvn:org.apache.coyote/com.springsource.org.apache.coyote/6.0.18</bundle>
    <bundle>mvn:org.apache.juli/com.springsource.org.apache.juli.extras/6.0.18</bundle>
    <bundle>mvn:org.apache.catalina/com.springsource.org.apache.catalina/6.0.18</bundle>
    <bundle>mvn:org.springframework/org.springframework.instrument.tomcat/3.0.4.RELEASE</bundle>
</feature>
<feature name="web-dependencies" version="1.0.0">
    <!--feature version="1.0.0">spring-dependencies</feature-->
    <!--feature version="1.0.0">tomcat-dependencies</feature-->
    <bundle>mvn:javax.servlet/com.springsource.javax.servlet/2.5.0</bundle>
    <!--bundle>mvn:javax.servlet/com.springsource.javax.servlet.jsp/2.1.0</bundle--> <!--we want this but PAX Web -JSP Support claims tooffer the same thing -->
    <!--bundle>mvn:javax.servlet/com.springsource.javax.servlet.jsp.jstl/1.2.0</bundle--> <!--bundle is causing conflict issues on javax.servlet.jsp 2.1.0 in fuse, omitting for now -->

    <!-- I have been having problems getting the following to work because of conflicts with the javax.servlet.jsp package 1.2.0 presented by Pax Web seems to not be able to be found -->
    <bundle>mvn:javax.faces/com.springsource.javax.faces/1.2.0.09</bundle>
    <bundle>mvn:javax.portlet/com.springsource.javax.portlet/2.0.0</bundle>>
    <bundle>mvn:org.springframework/org.springframework.web/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.web.servlet/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.web.portlet/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework.webflow/org.springframework.binding/2.0.9.RELEASE</bundle>
    <bundle>mvn:org.springframework.webflow/org.springframework.js/2.0.9.RELEASE</bundle>
    <bundle>mvn:org.springframework.webflow/org.springframework.webflow/2.0.9.RELEASE</bundle>
    <bundle>mvn:org.springframework.webflow/org.springframework.faces/2.0.9.RELEASE</bundle>  <!--2.1.0 and up rely on Java Server Faces API 2.0 Pre-Release right now, so we must stop at 2.0.9 -->
    <bundle>mvn:com.sun.facelets/com.springsource.com.sun.facelets/1.1.14</bundle>
</feature>

我考虑过切换到 SpringDM,但该项目似乎已转移到 Virgo,目前仅处于孵化器中。另外,我们对 Sericemix 非常满意,包括它的 Maven 安装功能。

任何见解或资源将不胜感激, 谢谢, 杰里米

We've been using Fuse's Apache ServiceMix version 4.2.0-fuse-02-00 for a while now for standard OSGi applications and have been fairly successful. We've also been leveraging CXF for making web services available.

Now we'd like to deploy our webapps to servicemix4 and leverage the OSGi layer for dependencies and services. However it seems that the packed in PAX Web does not support taglibs, which we've used heavily: Richfaces, facelets, etc.
It seems that the springDM solution which allows for working taglibs outlined here: http://static.springsource.org/osgi/docs/current/reference/html/web.html
should work, however I've had a hard time starting up the webserver, i currently get this error.

Exception in thread "WebExtender-Init" java.lang.NoClassDefFoundError: org/apache/catalina/Loader
 at org.springframework.osgi.web.extender.internal.activator.WarListenerConfiguration.createDefaultWarDeployer(WarListenerConfiguration.java:194)
 at org.springframework.osgi.web.extender.internal.activator.WarListenerConfiguration.<init>(WarListenerConfiguration.java:105)
 at org.springframework.osgi.web.extender.internal.activator.WarLoaderListener$1.run(WarLoaderListener.java:366)
 at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: org.apache.catalina.Loader
 at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:494)
 at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
 at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)
 at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
 ... 4 more

I've created 2 Fragments as the Spring documentation suggests. but they will not resolve, they remain as Installed

1) the webserver config fragment
has the following fragment host defined:

<Fragment-Host>org.springframework.osgi.web.extender</Fragment-Host>

and has a file META-INF/spring/extender/tomcat-deployer.xml containing

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.springframework.org/schema/beans   
       http://www.springframework.org/schema/beans/spring-beans.xsd">
 <bean id="warDeployer"
        class="org.springframework.osgi.web.deployer.tomcat.TomcatWarDeployer" />

</beans>

2) and a Catalina Config fragment
with the following host:

<Fragment-Host>org.springframework.osgi.catalina.start.osgi</Fragment-Host>

and a conf/server.xml defined which is mostly a copy of a generic windows install of tomcat 6 server.xml file.

I've also been messing with the dependencies for a few days now, it has been difficult. but here are the features I've been messing with to get this far. I've also been installing the fuse-servicemix default "jpa-hibernate" feature.

<feature name="spring-dependencies" version="1.0.0">
    <bundle>mvn:org.osgi/org.osgi.compendium/4.1.0</bundle>
    <bundle>mvn:javax.el/com.springsource.javax.el/1.0.0</bundle>
    <bundle>mvn:javax.xml.ws/com.springsource.javax.xml.ws/2.1.1</bundle>
    <bundle>mvn:javax.xml.stream/com.springsource.javax.xml.stream/1.0.1</bundle>
    <bundle>mvn:javax.xml.rpc/com.springsource.javax.xml.rpc/1.1.0</bundle>
    <bundle>mvn:javax.xml.soap/com.springsource.javax.xml.soap/1.3.0</bundle>
    <bundle>mvn:javax.persistence/com.springsource.javax.persistence/1.99.0</bundle>
    <bundle>mvn:org.aspectj/com.springsource.org.aspectj.tools/1.6.8.RELEASE</bundle>
    <bundle>mvn:org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1</bundle>
    <bundle>mvn:org.apache.commons/com.springsource.org.apache.commons.lang/2.4.0</bundle>
    <bundle>mvn:org.apache.xmlcommons/com.springsource.org.apache.xmlcommons/1.3.4</bundle>
    <bundle>mvn:org.jboss.el/com.springsource.org.jboss.el/2.0.0.GA</bundle>
    <bundle>mvn:org.jboss.javassist/com.springsource.javassist/3.9.0.GA</bundle>
    <bundle>mvn:org.aopalliance/com.springsource.org.aopalliance/1.0.0</bundle>
</feature>
<feature name="spring" version="1.0.0">
    <!--feature version="1.0.0">spring-dependencies</feature-->
    <!--bundle>mvn:org.springframework.osgi/org.springframework.osgi.core/1.2.1</bundle--> <!-- there is 1.2.1, but servicemix plays the 1.2.0 game -->
    <!--bundle>mvn:org.springframework.osgi/org.springframework.osgi.io/1.2.1</bundle--> <!-- there is 1.2.1, but servicemix plays the 1.2.0 game -->
    <!--bundle>mvn:org.springframework.osgi/org.springframework.osgi.extender/1.2.1</bundle--> <!-- there is 1.2.1, but servicemix plays the 1.2.0 game -->
    <!--bundle>mvn:org.springframework.osgi/org.springframework.osgi.extensions.annotation/1.2.1</bundle--> <!-- there is 1.2.1, but servicemix plays the 1.2.0 game -->
    <!-- commenting the 3.0.4 release to see if i can get by with the prepacked version in servicmeix bundle>mvn:org.springframework/org.springframework.aop/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.asm/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.aspects/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.beans/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.context/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.context.support/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.core/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.expression/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.jms/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.jdbc/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.transaction/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.orm/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework.security/org.springframework.security.core/3.0.3.RELEASE</bundle-->
    <bundle>mvn:org.springframework.osgi/org.springframework.osgi.web/1.2.0</bundle> <!-- there is 1.2.1, but servicemix plays the 1.2.0 game -->
    <bundle>mvn:org.springframework.osgi/org.springframework.osgi.web.extender/1.2.0</bundle>  <!-- there is 1.2.1, but servicemix plays the 1.2.0 game -->
</feature>
<feature name="tomcat" version="1.0.0">
    <!--feature version="1.0.0">spring</feature-->
    <bundle>mvn:javax.ejb/com.springsource.javax.ejb/3.0.0</bundle>
    <bundle>mvn:javax.activation/com.springsource.javax.activation/1.1.1</bundle>
    <bundle>mvn:javax.mail/com.springsource.javax.mail/1.4.1</bundle>
    <bundle>mvn:org.apache.coyote/com.springsource.org.apache.coyote/6.0.18</bundle>
    <bundle>mvn:org.apache.juli/com.springsource.org.apache.juli.extras/6.0.18</bundle>
    <bundle>mvn:org.apache.catalina/com.springsource.org.apache.catalina/6.0.18</bundle>
    <bundle>mvn:org.springframework/org.springframework.instrument.tomcat/3.0.4.RELEASE</bundle>
</feature>
<feature name="web-dependencies" version="1.0.0">
    <!--feature version="1.0.0">spring-dependencies</feature-->
    <!--feature version="1.0.0">tomcat-dependencies</feature-->
    <bundle>mvn:javax.servlet/com.springsource.javax.servlet/2.5.0</bundle>
    <!--bundle>mvn:javax.servlet/com.springsource.javax.servlet.jsp/2.1.0</bundle--> <!--we want this but PAX Web -JSP Support claims tooffer the same thing -->
    <!--bundle>mvn:javax.servlet/com.springsource.javax.servlet.jsp.jstl/1.2.0</bundle--> <!--bundle is causing conflict issues on javax.servlet.jsp 2.1.0 in fuse, omitting for now -->

    <!-- I have been having problems getting the following to work because of conflicts with the javax.servlet.jsp package 1.2.0 presented by Pax Web seems to not be able to be found -->
    <bundle>mvn:javax.faces/com.springsource.javax.faces/1.2.0.09</bundle>
    <bundle>mvn:javax.portlet/com.springsource.javax.portlet/2.0.0</bundle>>
    <bundle>mvn:org.springframework/org.springframework.web/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.web.servlet/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework/org.springframework.web.portlet/3.0.4.RELEASE</bundle>
    <bundle>mvn:org.springframework.webflow/org.springframework.binding/2.0.9.RELEASE</bundle>
    <bundle>mvn:org.springframework.webflow/org.springframework.js/2.0.9.RELEASE</bundle>
    <bundle>mvn:org.springframework.webflow/org.springframework.webflow/2.0.9.RELEASE</bundle>
    <bundle>mvn:org.springframework.webflow/org.springframework.faces/2.0.9.RELEASE</bundle>  <!--2.1.0 and up rely on Java Server Faces API 2.0 Pre-Release right now, so we must stop at 2.0.9 -->
    <bundle>mvn:com.sun.facelets/com.springsource.com.sun.facelets/1.1.14</bundle>
</feature>

I've considered switching to SpringDM but it seems like the project has been moved to Virgo which is only in incubator right now. Plus we've been mostly happy with Sericemix, including it's maven install feature.

Any insight or resources would be appreciated,
thanks,
Jeremy

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心病无药医 2024-10-01 23:51:34

因此,在休息一段时间后,我回来与团队中的更多成员一起解决这个问题。
简而言之,我们使用 SpringDM 成功在 ServiceMix 中获取了 Tomcat。
我将列出我在尝试进行此设置时所犯的一些错误。

1)ServiceMix的刷新功能会重新分析POM,因此只有刷新其主机后,片段才会被解析。这就是为什么我的仍然处于安装状态

2) 我实际上不需要这两个片段中的任何一个,这两个片段都有适合在 tomcat 中启动的默认值。

3) 我缺少 catalalina.start.osgi 包,它是向 osgi 层提供 tomcat 服务所必需的,更具体地说是 Spring DM 的 Web 扩展器。然而,我错过了它,因为我错过了 3 个关键存储库。以下是我们关于这些存储库的 Nexus 信息:

Repository ID: springframework.osgi
Repository Name: Springframework OSGI
Repository Type: proxy
Repository Policy: Release
Repository Format: maven2
Contained in groups: 
   Public Repositories
Remote URL: http://maven.springframework.org/osgi/

Repository ID: com.springsource.repository.bundles.release
Repository Name: SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases
Repository Type: proxy
Repository Policy: Release
Repository Format: maven2
Contained in groups: 
   Public Repositories
Remote URL: http://repository.springsource.com/maven/bundles/release/

Repository ID: com.springsource.repository.bundles.milestones
Repository Name: SpringSource Enterprise Bundle Repository - SpringSource Bundle Milestones
Repository Type: proxy
Repository Policy: Release
Repository Format: maven2
Contained in groups: 
   Public Repositories
Remote URL: http://repository.springsource.com/maven/bundles/milestone/

我们还有 4 个其他 SpringSource Enterprise Repos(以防万一)

Repository ID: com.springsource.repository.bundles.external
Repository Name: SpringSource Enterprise Bundle Repository - External Bundle Releases
Repository Type: proxy
Repository Policy: Release
Repository Format: maven2
Contained in groups: 
   Public Repositories
Remote URL: http://repository.springsource.com/maven/bundles/external/

Repository ID: com.springsource.repository.libraries.external
Repository Name: SpringSource Enterprise Bundle Repository - External Library Releases
Repository Type: proxy
Repository Policy: Release
Repository Format: maven2
Contained in groups: 
   Public Repositories
Remote URL: http://repository.springsource.com/maven/libraries/external/

Repository ID: com.springsource.snapshot
Repository Name: SpringSource Enterprise Bundle Repository - SpringSource Bundle Snapshots
Repository Type: proxy
Repository Policy: Snapshot
Repository Format: maven2
Contained in groups: 
   Public Repositories
Remote URL: http://repository.springsource.com/maven/bundles/snapshot/

Repository ID: com.springsource.repository.libraries.release
Repository Name: SpringSource Enterprise Bundle Repository - SpringSource Library Releases
Repository Type: proxy
Repository Policy: Release
Repository Format: maven2
Contained in groups: 
   Public Repositories
Remote URL: http://repository.springsource.com/maven/libraries/release/

因此,除了 servicemix 上的 coyote 之外,我们还将这两个片段添加到了 catalina 捆绑包中:

<bundle>mvn:org.springframework.osgi/catalina.start.osgi/1.0.0</bundle>
<bundle>mvn:org.apache.jasper/com.springsource.org.apache.jasper/6.0.24</bundle>

jsp 需要 jasper 捆绑包。4

)添加后捆绑包,刷新并重新启动适当的捆绑包,Tomcat 启动并运行良好。我们可以点击 localhost:8080 并点击空白页。我们决定尝试部署 Spring-DM 下载中提供的 simple-web-app:

http://www.springsource.org/osgi

解决了一些依赖问题后,我们能够清理和构建这个 Web 应用程序并部署它。在我们的 Ubuntu 环境中,您可以看到它将战争爆发到 /tmp/ 目录,它将从该目录为 Web 应用程序提供服务。不幸的是,当我们尝试访问 http://localhost:8080/simple-web-app/< 时,我们得到了 404 错误/a> 经过一些 Tomcat 调试后,我们意识到 Tomcat 的安装不知何故没有看到通常的默认 web.xml servlet 信息。因此,与此同时,我们必须在 Web 应用程序的 web.xml 中包含默认 servlet:

    <servlet>
        <servlet-name>default</servlet-name>
        <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>0</param-value>
        </init-param>
        <init-param>
            <param-name>listings</param-name>
            <param-value>false</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

<servlet>
    <servlet-name>jsp</servlet-name>
    <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
    <init-param>
        <param-name>fork</param-name>
        <param-value>false</param-value>
    </init-param>
    <init-param>
        <param-name>xpoweredBy</param-name>
        <param-value>false</param-value>
    </init-param>
    <load-on-startup>3</load-on-startup>
</servlet>

    <!-- The mapping for the default servlet -->
    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <!-- The mapping for the JSP servlet -->
    <servlet-mapping>
        <servlet-name>jsp</servlet-name>
        <url-pattern>*.jsp</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>jsp</servlet-name>
        <url-pattern>*.jspx</url-pattern>
    </servlet-mapping>

进一步调查为什么我们的示例应用程序无法找到默认 servlet 如下:

http://forum.springsource.org/showthread.php?p=328657#post328657

所以此时我们似乎已经掌握了一切根据这个 spring 示例,根据需要启动并运行工作标签库。尽管我们仍然需要尝试使用 OSGi 类路径从 Web 应用程序加载资源,或使用 OSGi 服务,但我们至少迈出了第一步。

请注意,即使我们没有使用 Wicket,此链接对于验证我所做的事情非常有帮助。

http://kevinwebber.ca/blog/2009/11/11/wicket-osgi-and-spring-dm.html#references

抱歉这些链接,stackoverflow 不会让我拥有超过 1 个..

So after a break from this I came back and tackled this with some more members of my team.
In short we successfully got Tomcat in ServiceMix using SpringDM.
I'll list some of the mistakes I made while trying to get this set up.

1) ServiceMix's Refresh function reanalyzes the POM, so fragments will become resolved only after you refresh their host. That's why mine were still in installed

2) I actually didn't need either of the two fragments, there are defaults for both fragments which are suitable for starting up in tomcat.

3) I was missing the catalalina.start.osgi bundle which was required to offer the tomcat services to the osgi layer and more specificly the Spring DM's web extender. However, I missed it because I had missed 3 key repositories. Here are our Nexus info on these repos:

Repository ID: springframework.osgi
Repository Name: Springframework OSGI
Repository Type: proxy
Repository Policy: Release
Repository Format: maven2
Contained in groups: 
   Public Repositories
Remote URL: http://maven.springframework.org/osgi/

Repository ID: com.springsource.repository.bundles.release
Repository Name: SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases
Repository Type: proxy
Repository Policy: Release
Repository Format: maven2
Contained in groups: 
   Public Repositories
Remote URL: http://repository.springsource.com/maven/bundles/release/

Repository ID: com.springsource.repository.bundles.milestones
Repository Name: SpringSource Enterprise Bundle Repository - SpringSource Bundle Milestones
Repository Type: proxy
Repository Policy: Release
Repository Format: maven2
Contained in groups: 
   Public Repositories
Remote URL: http://repository.springsource.com/maven/bundles/milestone/

we also have 4 other SpringSource Enterprise Repos (just in case0

Repository ID: com.springsource.repository.bundles.external
Repository Name: SpringSource Enterprise Bundle Repository - External Bundle Releases
Repository Type: proxy
Repository Policy: Release
Repository Format: maven2
Contained in groups: 
   Public Repositories
Remote URL: http://repository.springsource.com/maven/bundles/external/

Repository ID: com.springsource.repository.libraries.external
Repository Name: SpringSource Enterprise Bundle Repository - External Library Releases
Repository Type: proxy
Repository Policy: Release
Repository Format: maven2
Contained in groups: 
   Public Repositories
Remote URL: http://repository.springsource.com/maven/libraries/external/

Repository ID: com.springsource.snapshot
Repository Name: SpringSource Enterprise Bundle Repository - SpringSource Bundle Snapshots
Repository Type: proxy
Repository Policy: Snapshot
Repository Format: maven2
Contained in groups: 
   Public Repositories
Remote URL: http://repository.springsource.com/maven/bundles/snapshot/

Repository ID: com.springsource.repository.libraries.release
Repository Name: SpringSource Enterprise Bundle Repository - SpringSource Library Releases
Repository Type: proxy
Repository Policy: Release
Repository Format: maven2
Contained in groups: 
   Public Repositories
Remote URL: http://repository.springsource.com/maven/libraries/release/

So we added these two fragments to the catalina bundle in addition to coyote on servicemix:

<bundle>mvn:org.springframework.osgi/catalina.start.osgi/1.0.0</bundle>
<bundle>mvn:org.apache.jasper/com.springsource.org.apache.jasper/6.0.24</bundle>

the jasper bundle is required for jsp.

4) After adding the bundles, refreshing and restarting appropriate bundles, Tomcat got up and running fine. we could hit localhost:8080 and hit a blank page. We decided to try and deploy the simple-web-app that comes in the Spring-DM download here:

http://www.springsource.org/osgi

After resolving some dependency issues, we were able to clean and build this web-app and get it deployed. In our Ubuntu environment you could see it explode the war to the /tmp/ directory from which it will serve the web app. Unfortunately we got 404s when trying to hit the http://localhost:8080/simple-web-app/ after some Tomcat debugging we realized that this installation of tomcat was somehow not seeing the usual default web.xml servlet information. So for the mean time we've had to include the default servlet in our web-app's web.xml:

    <servlet>
        <servlet-name>default</servlet-name>
        <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>0</param-value>
        </init-param>
        <init-param>
            <param-name>listings</param-name>
            <param-value>false</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

<servlet>
    <servlet-name>jsp</servlet-name>
    <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
    <init-param>
        <param-name>fork</param-name>
        <param-value>false</param-value>
    </init-param>
    <init-param>
        <param-name>xpoweredBy</param-name>
        <param-value>false</param-value>
    </init-param>
    <load-on-startup>3</load-on-startup>
</servlet>

    <!-- The mapping for the default servlet -->
    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <!-- The mapping for the JSP servlet -->
    <servlet-mapping>
        <servlet-name>jsp</servlet-name>
        <url-pattern>*.jsp</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>jsp</servlet-name>
        <url-pattern>*.jspx</url-pattern>
    </servlet-mapping>

Further investigation of why our sample app could not find the default servlets is here:

http://forum.springsource.org/showthread.php?p=328657#post328657

So at this time we seemed to have got it all up and running with working tag-libs as required, given this spring example. Although we have still to attempt using the OSGi classpath to load resources from, or using OSGi services from a web app, we at least have the first step down.

Please note this link was very helpful for verifying what I'd done even though we're not using Wicket.

http://kevinwebber.ca/blog/2009/11/11/wicket-osgi-and-spring-dm.html#references

sorry about the links, stackoverflow wont let me have more than 1..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文