ClassNotFoundException:使用服务组合时找不到com.mysql.jdbc.Driver [英] ClassNotFoundException: com.mysql.jdbc.Driver not found while using service mix

查看:141
本文介绍了ClassNotFoundException:使用服务组合时找不到com.mysql.jdbc.Driver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将servicemix 4.4.1与maven 3.0.4一起使用.我对servicemix/java世界非常陌生-我的主要知识是c#/php.

I am using servicemix 4.4.1 with maven 3.0.4. I am very new to servicemix/java world - my main knowledge is c# / php.

我已将以下内容添加到我的一条路线中:

I have added the below to one of my routes:

<bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
  <property name="driverClass" value="com.mysql.jdbc.Driver"/>
  <property name="url" value="jdbc:mysql://10.10.10.29/ServiceMix"/>
  <property name="username" value="somet"/>
  <property name="password" value="somet"/>
</bean>

如果我随后将路由部署到服务组合,则会得到:

If i then deploy the route to service mix, i get:

ClassNotFoundException: com.mysql.jdbc.Driver not found

通过谷歌搜索,我发现我的POM中缺少某些行,因此我添加了以下内容:

From some googling i found that i was missing some lines from my POM, so i added the following:

<osgi-import-package>
org.apache.servicemix.bundles.commons-dbcp
</osgi-import-package>

AND

<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.commons-dbcp</artifactId>
<version>1.4_3</version>
</dependency>

我还运行了以下内容,以便servicemix了解这些捆绑软件:

I also ran the below so that servicemix knew about the bundles:

osgi:install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-pool/1.5.4_4
osgi:install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-dbcp/1.4_3

但是,现在,当我尝试启动捆绑软件时,我得到了:

However, now when i attempt to start the bundle i get:

Error executing command: Could not start bundle mvn:com.boohoo/boohoo-esb-products-sage-internal/1.0-SNAPSHOT in feature(s) boohoo-esb-products-sage-internal-1.0-SNAPSHOT: Unresolved constraint in bundle boohoo-esb-products-sage-internal [256]: Unable to resolve 256.0: missing requirement [256.0] package; (package=org.apache.servicemix.bundles.commons-dbcp)

我还做了一些谷歌搜索,说可以将清单文件添加到项目中,以便允许动态导入.因此,我在项目的路由中添加了一个名为MANIFEST.MF的新文件,并将以下内容添加到了文件中:

I also did some more googling which said i could add a manifest file to the project so that dynamic imports was allowed. Thus i added a new file called: MANIFEST.MF to the route of the project and added the following to the file:

Fragment-Host:
 org.apache.commons.dbcp 
DynamicImport-Package:
 *

但这也不起作用.我觉得我正在转圈.任何帮助/指针都将很好.

But this has had no effect either. I feel like i am going round in circles. Any help/pointers would be great.

我希望一切都有意义,但如果没有,就这么说,我会尽力加以解释.

I hope everything makes sense, but if not, just say so and i'll try and explain it better.

干杯.

推荐答案

解决了该问题.我将代码更新如下:

Fixed the issue. I updated my code as follows:

 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
  <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
  <property name="url" value="jdbc:mysql://10.10.10.29/ServiceMix"/>
  <property name="username" value="something"/>
  <property name="password" value="something"/>
</bean>

POM:

<osgi-import-package>
  org.apache.commons.dbcp
</osgi-import-package>

<dependency>
  <groupId>org.apache.servicemix.bundles</groupId>
  <artifactId>org.apache.servicemix.bundles.commons-dbcp</artifactId>
  <version>1.4_3</version>
</dependency>

已删除清单文件. 从servicemix卸载了公共池.

Removed the manifest file. Uninstalled commons-pools from servicemix.

这篇关于ClassNotFoundException:使用服务组合时找不到com.mysql.jdbc.Driver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆