如何在OSGI包中调用datasource?

时间:2012-01-23 14:03:35

标签: java netbeans jsf-2 glassfish osgi

是否可以调用@Datasource洞察OSGI捆绑包?我在Glassfish 3.1.1服务器中配置了连接池。我可以从简单的JSF应用程序进行查询。   这是包的源代码: http://www.2shared.com/file/H8kNkMrI/SH_27.html

这是我要写的源代码:

package org.DX_57.osgi.SH_27.impl;

import javax.activation.DataSource;
import javax.annotation.Resource;
import org.DX_57.osgi.SH_27.api.SessionHandle;

public class SessionHandleImpl implements SessionHandle {

        public String error_Message = null;
        public String error_Database = null;

        /** Call the Oracle JDBC Connection driver */
        @Resource(name="jdbc/Oracle")
        public DataSource ds;

    public String sayHello(String name) {
        return "Howdy " + name;
    }                      
}

当我尝试使用Netbeans编译代码时,会出现以下错误:

[bundle:bundle]
Bundle org.DX_57.osgi.SH_27:SH_27-impl:bundle:1.0-SNAPSHOT : Unresolved references to [javax.activation, javax.annotation] by class(es) on the Bundle-Classpath[Jar:dot]: [org/DX_57/osgi/SH_27/impl/SessionHandleImpl.class]
Error(s) found in bundle configuration
------------------------------------------------------------------------
Reactor Summary:

SH_27 ............................................. SUCCESS [0.639s]
SH_27-api ......................................... SUCCESS [5.162s]
SH_27-impl ........................................ FAILURE [1.930s]
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 8.950s
Finished at: Mon Jan 23 15:59:42 EET 2012
Final Memory: 18M/47M
------------------------------------------------------------------------
Failed to execute goal org.apache.felix:maven-bundle-plugin:2.3.6:bundle (default-bundle) on project SH_27-impl: Error(s) found in bundle configuration -> [Help 1]

你知道我缺少什么吗?


更新:在尝试计算我的bundle的OSGi清单时,Bundle插件无法看到javax.annotation和javax.activation类,并决定在jar中打包什么。我必须修复pom.xml。 这是OSGI包的源代码。

我必须如何修复POM文件?


更新2 :这是来自Netbeans的完整错误堆栈:

http://pastebin.com/R2hnRHVW

这是POM文件:

http://pastebin.com/Tc1gJiwU

您能帮我修复POM文件吗?

1 个答案:

答案 0 :(得分:0)

不确定如何运行框架,对于felix,如果在bootdelegation包中指定javax.activation(以及其他所需的包),它可能会有所帮助;在framework.properties中使用org.osgi.framework.bootdelegation。