0

我在将 JDBC 驱动程序 JTDS 注册到 FUSE 时遇到了一些困难。

路由.xml

  <bean id="myDS" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>
    <property name="url" value="jdbc:jtds:sqlserver://?????;databaseName=?????;tds=8.0;lastupdatecount=true" />
    <property name="username" value="fuser" />
    <property name="password" value="fuser" />
  </bean>

pom.xml

<build>
    <plugins>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>2.3.4</version>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Bundle-SymbolicName>rest.proxy</Bundle-SymbolicName>
            <Require-Bundle>org.apache.cxf.bundle,org.apache.camel.camel-cxf,org.springframework.beans</Require-Bundle>
            <Import-Package>net.sourceforge.jtds.jdbc,*</Import-Package>
          </instructions>
        </configuration>
      </plugin>
    </plugins>
  </build>

运行 Fuse 命令来安装驱动程序;

osgi:install -s wrap:mvn:net.sourceforge/jtds/1.3.1 

osgi:install -s wrap:mvn:jcifs/jcifs/1.3.17 

如果我显示 jtds 的导出,我会得到:

JBossFuse:karaf@root> osgi:headers 278

wrap_mvn_net.sourceforge_jtds_1.3.1 (278) 

Main-Class = net.sourceforge.jtds.jdbc.Driver 
Specification-Title = JDBC 
Tool = Bnd-0.0.357 
Specification-Version = 3.0 
Implementation-Version = 1.3.1 
Generated-By-Ops4j-Pax-From = wrap:mvn:net.sourceforge/jtds/1.3.1 
Created-By = 1.7.0_25 (Oracle Corporation) 
Implementation-Title = jTDS JDBC Driver 
Manifest-Version = 1.0 
Bnd-LastModified = 1381480171800 
Implementation-URL = http://jtds.sourceforge.net
Originally-Created-By = 1.7.0_21-b11 (Oracle Corporation) 
Ant-Version = Apache Ant 1.8.2 


Bundle-Name = wrap_mvn_net.sourceforge_jtds_1.3.1 
Bundle-SymbolicName = wrap_mvn_net.sourceforge_jtds_1.3.1 
Bundle-Version = 0 
Bundle-ManifestVersion = 2 


Import-Package = 
        javax.crypto;resolution:=optional, 
        javax.crypto.spec;resolution:=optional, 
        javax.naming;resolution:=optional, 
        javax.naming.spi;resolution:=optional, 
        javax.net;resolution:=optional, 
        javax.net.ssl;resolution:=optional, 
        javax.sql;resolution:=optional, 
        javax.transaction.xa;resolution:=optional, 
        jcifs;resolution:=optional, 
        jcifs.smb;resolution:=optional, 
        net.sourceforge.jtds.jdbc;resolution:=optional, 
        net.sourceforge.jtds.jdbc.cache;resolution:=optional, 
        net.sourceforge.jtds.jdbcx;resolution:=optional, 
        net.sourceforge.jtds.jdbcx.proxy;resolution:=optional, 
        net.sourceforge.jtds.ssl;resolution:=optional, 
        net.sourceforge.jtds.util;resolution:=optional, 
        org.ietf.jgss;resolution:=optional 
Export-Package = 
        **net.sourceforge.jtds.jdbc**; 
                uses:="net.sourceforge.jtds.util, 
                        net.sourceforge.jtds.jdbc.cache, 
                        jcifs.smb, 
                        jcifs, 
                        javax.net, 
                        net.sourceforge.jtds.ssl, 
                        org.ietf.jgss, 
                        net.sourceforge.jtds.jdbcx, 
                        javax.transaction.xa", 
        net.sourceforge.jtds.jdbc.cache;uses:=net.sourceforge.jtds.jdbc, 
        net.sourceforge.jtds.jdbcx; 
                uses:="javax.naming, 
                        javax.sql, 
                        net.sourceforge.jtds.util, 
                        net.sourceforge.jtds.jdbc, 
                        javax.naming.spi, 
                        javax.transaction.xa, 
                        net.sourceforge.jtds.jdbcx.proxy", 
        net.sourceforge.jtds.jdbcx.proxy;uses:="net.sourceforge.jtds.jdbc,net.sourceforge.jtds.jdbcx", 
        net.sourceforge.jtds.ssl;uses:="javax.net.ssl,javax.net,net.sourceforge.jtds.util", 
        net.sourceforge.jtds.util;uses:="net.sourceforge.jtds.jdbc,javax.crypto.spec,javax.crypto" 

对于 JTDS 要求的 JCIFS

JBossFuse:karaf@root> osgi:headers 283

wrap_mvn_jcifs_jcifs_1.3.17 (283) 


Manifest-Version = 1.0 
Bnd-LastModified = 1381486791455 
Archiver-Version = Plexus Archiver 
Tool = Bnd-0.0.357 
Originally-Created-By = Apache Maven 
Built-By = ajvanerp 
Generated-By-Ops4j-Pax-From = wrap:mvn:jcifs/jcifs/1.3.17 
Build-Jdk = 1.6.0_29 
Created-By = 1.7.0_25 (Oracle Corporation) 


Bundle-Name = wrap_mvn_jcifs_jcifs_1.3.17 
Bundle-SymbolicName = wrap_mvn_jcifs_jcifs_1.3.17 
Bundle-Version = 0 
Bundle-ManifestVersion = 2 


Import-Package = 
        javax.servlet;resolution:=optional, 
        javax.servlet.http;resolution:=optional, 
        jcifs;resolution:=optional, 
        jcifs.dcerpc;resolution:=optional, 
        jcifs.dcerpc.msrpc;resolution:=optional, 
        jcifs.dcerpc.ndr;resolution:=optional, 
        jcifs.http;resolution:=optional, 
        jcifs.https;resolution:=optional, 
        jcifs.netbios;resolution:=optional, 
        jcifs.ntlmssp;resolution:=optional, 
        jcifs.smb;resolution:=optional, 
        jcifs.util;resolution:=optional, 
        jcifs.util.transport;resolution:=optional 
Export-Package = 
        jcifs;uses:="jcifs.util,jcifs.netbios", 
        jcifs.dcerpc;uses:="jcifs.util,jcifs.dcerpc.ndr,jcifs.dcerpc.msrpc,jcifs.smb", 
        jcifs.dcerpc.msrpc;uses:="jcifs.smb,jcifs.dcerpc,jcifs.dcerpc.ndr", 
        jcifs.dcerpc.ndr;uses:=jcifs.util, 
        jcifs.http;uses:="javax.servlet,jcifs.util,jcifs.smb,jcifs,jcifs.netbios,javax.servlet.http,jcifs.ntlmssp", 
        jcifs.https;uses:=jcifs.http, 
        jcifs.netbios;uses:="jcifs.util,jcifs.smb,jcifs", 
        jcifs.ntlmssp;uses:="jcifs,jcifs.util,jcifs.netbios,jcifs.smb", 
        jcifs.smb;uses:="jcifs.util,jcifs,jcifs.ntlmssp,jcifs.dcerpc.msrpc,jcifs.dcerpc.ndr,jcifs.dcerpc,jcifs.util.transport,jcifs.netbios", 
        jcifs.util, 
        jcifs.util.transport;uses:=jcifs.util 

现在,对于我部署的包,我已经列出了导入,(我已经突出显示了 JTDS 的导入,因此,这来自 POM 设置):

JBossFuse:karaf@root> 包:导入 282

System Bundle (0): javax.xml.bind.annotation; version=2.2.1 
Spring Beans (105): org.springframework.beans; version=3.1.3.RELEASE 
Spring Beans (105): org.springframework.beans.annotation; version=3.1.3.RELEASE 
Spring Beans (105): org.springframework.beans.factory; version=3.1.3.RELEASE 
Spring Beans (105): org.springframework.beans.factory.access; version=3.1.3.RELEASE 
Spring Beans (105): org.springframework.beans.factory.access.el; version=3.1.3.RELEASE 
Spring Beans (105): org.springframework.beans.factory.annotation; version=3.1.3.RELEASE 
Spring Beans (105): org.springframework.beans.factory.config; version=3.1.3.RELEASE 
Spring Beans (105): org.springframework.beans.factory.parsing; version=3.1.3.RELEASE 
Spring Beans (105): org.springframework.beans.factory.serviceloader; version=3.1.3.RELEASE 
Spring Beans (105): org.springframework.beans.factory.support; version=3.1.3.RELEASE 
Spring Beans (105): org.springframework.beans.factory.wiring; version=3.1.3.RELEASE 
Spring Beans (105): org.springframework.beans.factory.xml; version=3.1.3.RELEASE 
Spring Beans (105): org.springframework.beans.propertyeditors; version=3.1.3.RELEASE 
Spring Beans (105): org.springframework.beans.support; version=3.1.3.RELEASE 
activemq-osgi (114): org.apache.activemq.camel.component; version=5.8.0.redhat-60024 
camel-core (130): org.apache.camel; version=2.10.0.redhat-60024 
Apache ServiceMix :: Specs :: JSR-311 API 1.1.1 (145): javax.ws.rs; version=1.1.1 
camel-cxf (194): org.apache.camel.component.cxf; version=2.10.0.redhat-60024 
camel-cxf (194): org.apache.camel.component.cxf.blueprint; version=2.10.0.redhat-60024 
camel-cxf (194): org.apache.camel.component.cxf.converter; version=2.10.0.redhat-60024 
camel-cxf (194): org.apache.camel.component.cxf.cxfbean; version=2.10.0.redhat-60024 
camel-cxf (194): org.apache.camel.component.cxf.feature; version=2.10.0.redhat-60024 
camel-cxf (194): org.apache.camel.component.cxf.interceptors; version=2.10.0.redhat-60024 
camel-cxf (194): org.apache.camel.component.cxf.jaxrs; version=2.10.0.redhat-60024 
camel-cxf (194): org.apache.camel.component.cxf.spring; version=2.10.0.redhat-60024 
camel-cxf (194): org.apache.camel.component.cxf.util; version=2.10.0.redhat-60024 
Spring JDBC (244): org.springframework.jdbc.datasource; version=3.1.3.RELEASE 
camel-sql (245): org.apache.camel.component.sql; version=2.10.0.redhat-60024 
**wrap_mvn_net.sourceforge_jtds_1.3.1 (278): net.sourceforge.jtds.jdbc; version=0.0.0** 

我的包部署良好: [ 282] [Active ] [ ] [Started] [ 60] rest.proxy (0.0.1.SNAPSHOT)

但是当我点击骆驼(JAX-RS消费者)暴露的其余代理时,它必须进行数据库查找。我收到此错误:

原因:java.sql.SQLException:找不到适合jdbc:jtds:sqlserver://?????;databaseName=?????;tds=8.0;lastupdatecount=true 的驱动程序

现在,我不是 OSGI 方面的专家,过去使用过它一段时间。我看不出我做错了什么明显的事情。

我已经解决了一些较早的错误,并通过确保 JAR 导出正确的包并将 Import 包放在我的 Bundle 中来修复它们。

非常感谢任何帮助。

4

1 回答 1

1

您可能会发现直接在 spring bean 中实例化 JTDS 数据源更容易。此处提供了一个快速示例http://fusesource.com/forums/thread.jspa?threadID=1682

绝对可以运行 JTDS 1.2x 和 bonecp,这对于连接池很有用

于 2013-10-12T00:25:15.893 回答