【发布时间】:2013-08-26 06:53:32
【问题描述】:
我的 Tapestry Web 应用程序为某些数据集提供了完整的 CRUD 功能。 到目前为止,我一直在使用模拟来开发和测试它。
但是,我现在需要用 OSGi 服务(使用 Felix 运行)替换该模拟。
我的主要问题/问题是:
- 我是否需要将 OSGi 服务注入到我的 Tapestry 应用程序中,如果需要,该怎么做?
- 假设它是注入的,有没有关于如何使用它的实践?我应该调用这些方法或类似的任何特殊方式吗?
- 在调用我需要的方法后,我是否需要对它做一些事情,还是自动完成?
- 我需要担心
HttpService吗(我看了一些关于它的抱怨,但不太明白)
为了给你提供一些背景信息,这就是我现在的做法
public class MyPage {
...
@Inject
private MyDao dao;
...
@Property
private List<Entry> entries;
...
void onPrepareForRender() {
...
this.entries = this.dao.getAll()
...
}
...
}
我想要将MyDao dao 替换为提供相同功能的OSGi 服务,这样我就可以在onPrepareForRender 方法中使用它。
我可以放心地假设与服务关联的 OSGi 包已经在运行。
应用程序的其余部分作为 OSGi 应用程序制作。 我在 pom.xml 中添加/更改了一些东西(maven-bundle-plugin,按照http://www.javabeat.net/2011/11/writing-an-osgi-web-application/ 中的说明添加了一些清单条目)。
但是还是不行。
顺便说一句,我正在尝试将我的 WAR 转换为 WAB。
提前谢谢你:)
编辑:从 WAR 转换和部署到 WAB 时出现问题
当我将我的网络应用程序打包为 war 时,一切正常。但是,当我将其打包为 bundle 并尝试将其部署到 GlassFish 中时,我收到以下错误消息:
部署时出错:没有安装容器 能够处理这个应用程序管理战争。请参阅 server.log 了解更多详情。
当我转到 server.log 时,它是这样写的:
[#|2013-08-27T17:11:57.600+0200|INFO|glassfish3.1.2|org.glassfish.admingui|_ThreadID=28;_ThreadName=Thread-2;|uploadFileName=admin-war-2.01-SNAPSHOT.jar|#]
[#|2013-08-27T17:11:57.920+0200|WARNING|glassfish3.1.2|javax.enterprise.system.tools.deployment.com.sun.enterprise.deploy.shared|_ThreadID=29;_ThreadName=Thread-2;|DPL8031: Ignoring WEB-INF/ because the containing archive C:\glassfish3\glassfish\domains\domain1\applications\admin-war recorded it as a pre-existing stale file|#]
[#|2013-08-27T17:11:57.939+0200|WARNING|glassfish3.1.2|javax.enterprise.system.tools.deployment.com.sun.enterprise.deploy.shared|_ThreadID=33;_ThreadName=Thread-2;|DPL8031: Ignoring WEB-INF/ because the containing archive C:\glassfish3\glassfish\domains\domain1\applications\admin-war recorded it as a pre-existing stale file|#]
[#|2013-08-27T17:11:57.972+0200|WARNING|glassfish3.1.2|javax.enterprise.system.tools.deployment.com.sun.enterprise.deploy.shared|_ThreadID=29;_ThreadName=Thread-2;|DPL8031: Ignoring WEB-INF/ because the containing archive C:\glassfish3\glassfish\domains\domain1\applications\admin-war recorded it as a pre-existing stale file|#]
[#|2013-08-27T17:11:57.973+0200|WARNING|glassfish3.1.2|javax.enterprise.system.tools.deployment.com.sun.enterprise.deploy.shared|_ThreadID=29;_ThreadName=Thread-2;|DPL8031: Ignoring WEB-INF/ because the containing archive C:\glassfish3\glassfish\domains\domain1\applications\admin-war recorded it as a pre-existing stale file|#]
[#|2013-08-27T17:11:57.974+0200|WARNING|glassfish3.1.2|javax.enterprise.system.tools.deployment.com.sun.enterprise.deploy.shared|_ThreadID=29;_ThreadName=Thread-2;|DPL8031: Ignoring WEB-INF/ because the containing archive C:\glassfish3\glassfish\domains\domain1\applications\admin-war recorded it as a pre-existing stale file|#]
[#|2013-08-27T17:11:57.990+0200|WARNING|glassfish3.1.2|javax.enterprise.system.tools.deployment.com.sun.enterprise.deploy.shared|_ThreadID=29;_ThreadName=Thread-2;|DPL8031: Ignoring WEB-INF/ because the containing archive C:\glassfish3\glassfish\domains\domain1\applications\admin-war recorded it as a pre-existing stale file|#]
[#|2013-08-27T17:11:57.991+0200|WARNING|glassfish3.1.2|javax.enterprise.system.tools.deployment.com.sun.enterprise.deploy.shared|_ThreadID=29;_ThreadName=Thread-2;|DPL8031: Ignoring WEB-INF/ because the containing archive C:\glassfish3\glassfish\domains\domain1\applications\admin-war recorded it as a pre-existing stale file|#]
[#|2013-08-27T17:11:58.006+0200|WARNING|glassfish3.1.2|javax.enterprise.system.tools.deployment.com.sun.enterprise.deploy.shared|_ThreadID=29;_ThreadName=Thread-2;|DPL8031: Ignoring WEB-INF/ because the containing archive C:\glassfish3\glassfish\domains\domain1\applications\admin-war recorded it as a pre-existing stale file|#]
[#|2013-08-27T17:11:58.008+0200|WARNING|glassfish3.1.2|javax.enterprise.system.tools.deployment.com.sun.enterprise.deploy.shared|_ThreadID=29;_ThreadName=Thread-2;|DPL8031: Ignoring WEB-INF/ because the containing archive C:\glassfish3\glassfish\domains\domain1\applications\admin-war recorded it as a pre-existing stale file|#]
[#|2013-08-27T17:11:58.008+0200|WARNING|glassfish3.1.2|javax.enterprise.system.tools.deployment.com.sun.enterprise.deploy.shared|_ThreadID=29;_ThreadName=Thread-2;|DPL8031: Ignoring WEB-INF/ because the containing archive C:\glassfish3\glassfish\domains\domain1\applications\admin-war recorded it as a pre-existing stale file|#]
[#|2013-08-27T17:11:58.024+0200|WARNING|glassfish3.1.2|javax.enterprise.system.tools.deployment.com.sun.enterprise.deploy.shared|_ThreadID=29;_ThreadName=Thread-2;|DPL8031: Ignoring WEB-INF/ because the containing archive C:\glassfish3\glassfish\domains\domain1\applications\admin-war recorded it as a pre-existing stale file|#]
[#|2013-08-27T17:11:58.025+0200|WARNING|glassfish3.1.2|javax.enterprise.system.tools.deployment.com.sun.enterprise.deploy.shared|_ThreadID=29;_ThreadName=Thread-2;|DPL8031: Ignoring WEB-INF/ because the containing archive C:\glassfish3\glassfish\domains\domain1\applications\admin-war recorded it as a pre-existing stale file|#]
[#|2013-08-27T17:11:58.026+0200|SEVERE|glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=29;_ThreadName=Thread-2;|Module type not recognized for module C:\glassfish3\glassfish\domains\domain1\applications\admin-war|#]
[#|2013-08-27T17:11:58.026+0200|SEVERE|glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=29;_ThreadName=Thread-2;|There is no installed container capable of handling this application admin-war|#]
[#|2013-08-27T17:11:58.087+0200|INFO|glassfish3.1.2|org.glassfish.admingui|_ThreadID=28;_ThreadName=Thread-2;|Exception Occurred :Error occurred during deployment: There is no installed container capable of handling this application admin-war. Please see server.log for more details.|#]
【问题讨论】:
-
我可以放心地假设与该服务关联的 OSGi 包已经在运行了。 哇!魔法!完成了不可能! :-)
-
嗯,这就是他们向我保证的:P
-
啊,那我在纽约有一座不错的桥出售,不错的房产。真的很便宜。 :-)
-
你可以:编写一个 hello world Tapestry 应用程序,它作为基于 OSGi 的 web 应用程序工作,检查 Spring Tapestry 过滤器是如何工作的(仅限 2-3 个类),编写一个使用 OSGi 服务而不是 Spring 应用程序上下文的过滤器豆子。最后在 GitHub 上分享你的过滤器代码 :)。
标签: web-applications osgi tapestry osgi-bundle wab