简体   繁体   English

如何在OSGI包中调用数据源?

[英]How to call datasource in OSGI bundle?

Is it possible to call @Datasource insight OSGI bundle? 是否可以调用@Datasource OSGI捆绑包? I configured Connection pool in the Glassfish 3.1.1 Server. 我在Glassfish 3.1.1服务器中配置了连接池。 I can make queries from simple JSF application. 我可以从简单的JSF应用程序进行查询。 This is the source code of the bundles: http://www.2shared.com/file/H8kNkMrI/SH_27.html 这是捆绑软件的源代码: http : //www.2shared.com/file/H8kNkMrI/SH_27.html

This is the source code that I'm trying to write: 这是我要编写的源代码:

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;
    }                      
}

When I try to compile the code with Netbeans this error appears: 当我尝试使用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]

Do you have any idea what I'm missing? 你知道我想念什么吗?


Update : Bundle plugin is unable to see javax.annotation and javax.activation classes while trying to compute OSGi manifest of my bundle and decide what to package in ther jar. 更新 :捆绑插件在尝试计算我的捆绑软件的OSGi清单并决定将其打包在jar中时,无法看到javax.annotation和javax.activation类。 I have to fix the pom.xml. 我必须修复pom.xml。 This is the source code of the OSGI bundle. 这是OSGI捆绑软件的源代码。

How I must repair the POM file? 我该如何修复POM文件?


Update 2 : This is the full error stack from Netbeans: 更新2 :这是Netbeans的完整错误堆栈:

http://pastebin.com/R2hnRHVW http://pastebin.com/R2hnRHVW

And this is the POM file: 这是POM文件:

http://pastebin.com/Tc1gJiwU http://pastebin.com/Tc1gJiwU

Would you help me to fix the POM file? 您能帮我修复POM文件吗?

Not sure how you run the framework, for felix it might help if you specify javax.activation (and other packages you need) in bootdelegation packages; 不确定如何运行框架,对于felix,如果在bootdelegation软件包中指定javax.activation(以及其他所需的软件包),则可能会有所帮助; Use org.osgi.framework.bootdelegation in framework.properties. 在framework.properties中使用org.osgi.framework.bootdelegation。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM