将akka依赖项添加到osgi容器

时间:2013-05-22 14:44:38

标签: java osgi akka eclipse-virgo

我使用osgi容器(virgo)[我不是很好]。

我在pom.xml

中添加了依赖项
<dependency>
    <groupId>com.typesafe.akka</groupId>
    <artifactId>akka-osgi_2.10</artifactId>
    <version>2.2-M3</version>
</dependency>

我将akka-osgi_2.10-2.2-M3.jar放到我的lib / deploy文件夹到OSGI服务器(到myserver/repository/usr)。

我在我的代码库中添加了虚拟actor:

import akka.actor.UntypedActor;

public class ManagerActor extends UntypedActor {
    @Override
    public void onReceive(Object o) throws Exception {
        // ...
    }
}

我构建并启动我的应用程序。

结果我的日志中有以下例外(它向version="0.0.0"投诉):

.. failed. org.eclipse.virgo.kernel.osgi.framework.UnableToSatisfyBundleDependenciesException: Unable to satisfy dependencies of bundle 'com.
com.mycompnay.mything-security' at version '1.0.1.BUILD-SNAPSHOT': Cannot resolve: com.mycompany.mything-security
    Resolver report:
        An Import-Package could not be resolved. Resolver error data <Import-Package: akka.actor; version="0.0.0">. Caused by missing constrai
nt in bundle <com.mycompany.mything-security_1.0.1.BUILD-SNAPSHOT>
             constraint: <Import-Package: akka.actor; version="0.0.0">

我转到我的template.mf文件,该文件用于生成最终的MANIFEST.MF文件。要指定我使用的AKKA lib的版本范围。放在那里:

Import-Template: 
 akka.actor.*;version="[2.2.0.M3, 2.3)"

Import-Package: 
 akka.actor;version="[2.2.0.M3, 2.3)"

然后重建并启动应用程序。

但是在控制台中它向akka版本抱怨(现在向version="[2.2.0.M3,2.3.0)"抱怨):

        An Import-Package could not be resolved. Resolver error data <Import-Package: akka.actor; version="[2.2.0.M3,2.3.0)">. Caused by missi
ng constraint in bundle <com.mycompany.mything-security_1.0.1.BUILD-SNAPSHOT>
             constraint: <Import-Package: akka.actor; version="[2.2.0.M3,2.3.0)">

问:出了什么问题?


此外,我尝试添加此行:Import-Bundle

Import-Bundle: 
 ...
 com.typesafe.akka.osgi;version="[2.2.0.M3, 2.3)"

然后我把它放在日志中(现在它向com.typesafe.akka.osgi版本抱怨):

.. failed. org.eclipse.virgo.kernel.deployer.core.DeploymentException: Unable to satisfy dependencies of bundle 'com.mycompany.mything-security
' at version '1.0.1.BUILD-SNAPSHOT': Import-Bundle with symbolic name 'com.typesafe.akka.osgi' in version range '[2.2.0.M3, oo)' could not be
satisfied

1 个答案:

答案 0 :(得分:0)

原因是:

我需要将akka-actor_2.10-2.2-M3.jar(以及akka-osgi_2.10-2.2-M3.jar)放到我的osgi(处女座)部署文件夹中。

所以,我们不应该手动操作,而是在maven的帮助下(为了不错过一些预期的jar)。