我在JBoss Fuse下开发了一个bundle,它将一些数据保存到DB中。由于异常,我的DAO很难将连接池初始化为Oracle DB:
引起:org.apache.commons.dbcp.SQLNestedException:无法加载 JDBC驱动程序类'oracle.jdbc.driver.OracleDriver'
在 org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1429)
在 org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
在 org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
在 bank.dao.CorrelationInfoDaoImpl.insertCorellationInfo(CorrelationInfoDaoImpl.java:25)
... 28更多
引起:java.lang.ClassNotFoundException: io.fabric8.fabric-jolokia找不到oracle.jdbc.driver.OracleDriver [98]
既不
<DynamicImport-Package>oracle.jdbc.driver.OracleDriver</DynamicImport-Package>
,也没有工件wrap:mvn:com.oracle.jdbc/ojdbc7/12.1.0.2
包含,也没有蓝图描述符中的bean声明
<bean id="dictDS-driver-class-name" class="oracle.jdbc.driver.OracleDriver"/>
无济于事。任何人都可以提出一个想法,如何解决它?
这是pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>bank</groupId>
<artifactId>AdpFMOutConcurrent</artifactId>
<packaging>bundle</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven-bundle-plugin.version>3.2.0</maven-bundle-plugin.version>
<maven-resources-plugin.version>3.0.1</maven-resources-plugin.version>
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
<camel-maven-plugin-version>2.15.1.redhat-621084</camel-maven-plugin-version>
<fabric8-maven-plugin-version>1.2.0.redhat-621084</fabric8-maven-plugin-version>
<jboss.fuse.bom.version>6.2.1.redhat-084</jboss.fuse.bom.version>
<datamodel.version>1.0-SNAPSHOT</datamodel.version>
<ojdbc7.version>12.1.0.2</ojdbc7.version>
<junit.version>4.12</junit.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.fuse.bom</groupId>
<artifactId>jboss-fuse-parent</artifactId>
<version>${jboss.fuse.bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Custom -->
<dependency>
<groupId>bank</groupId>
<artifactId>DataModel</artifactId>
<version>${datamodel.version}</version>
</dependency>
<!-- Camel -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-blueprint</artifactId>
</dependency>
<!-- The ActiveMQ client with connection pooling -->
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-client</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-camel</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pool</artifactId>
</dependency>
<!-- DB -->
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc7</artifactId>
<version>${ojdbc7.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jdbc</artifactId>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<!-- Testing -->
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>${basedir}/target/generated-sources/resources</directory>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven-resources-plugin.version}</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${maven-bundle-plugin.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<Private-Package>bank.*</Private-Package>
<Import-Package>*</Import-Package>
<DynamicImport-Package>oracle.jdbc.driver.OracleDriver</DynamicImport-Package>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-maven-plugin</artifactId>
<version>${camel-maven-plugin-version}</version>
<configuration>
<useBlueprint>true</useBlueprint>
</configuration>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${fabric8-maven-plugin-version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-xsd-files</id>
<phase>initialize</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>bank</groupId>
<artifactId>DataModel</artifactId>
<version>${project.version}</version>
<type>bundle</type>
</artifactItem>
</artifactItems>
<includes>
ASBOFMOut/*.xsd,
GBOCommon/*.xsd,
ASBOFMDataModel/*.xsd
</includes>
<outputDirectory>${basedir}/target/generated-sources/resources/model</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!-- JAXB xjc plugin that invokes the xjc compiler to compile XML schema into Java classes.-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- The schema directory or xsd files. -->
<sources>
<source>${basedir}/target/generated-sources/resources/model</source>
</sources>
<xjbSources>
<xjbSource>${basedir}/src/main/resources/jaxbBinding.xjb</xjbSource>
</xjbSources>
<xjcSourceExcludeFilters>
<filter implementation="org.codehaus.mojo.jaxb2.shared.filters.pattern.PatternFileFilter">
<patterns>
<pattern>\.svn.*</pattern>
</patterns>
</filter>
</xjcSourceExcludeFilters>
<outputDirectory>${basedir}/target/generated-sources/jaxb</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
这是蓝图描述符:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd">
<cm:property-placeholder id="adpfmoutconcurrent" persistent-id="adpfmoutconcurrent">
<cm:default-properties>
<cm:property name="broker.url" value="discovery:(fabric:public)"/>
<cm:property name="broker.username" value="admin"/>
<cm:property name="broker.password" value="admin"/>
<cm:property name="max.connections" value="5"/>
<cm:property name="concurrent.consumers" value="10"/>
<cm:property name="max.concurrent.consumers" value="15"/>
<cm:property name="persistence.driver" value="oracle.jdbc.driver.OracleDriver"/>
<cm:property name="persistence.url" value="jdbc:oracle:thin:@10.10.3.42:1521:ESBDB"/>
<cm:property name="persistence.username" value="esb_db_dev3"/>
<cm:property name="persistence.password" value="esb_db_dev3"/>
</cm:default-properties>
</cm:property-placeholder>
<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${broker.url}"/>
<property name="userName" value="${broker.username}"/>
<property name="password" value="${broker.password}"/>
</bean>
<bean id="pooledJmsConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory">
<property name="maxConnections" value="${max.connections}"/>
<property name="connectionFactory" ref="jmsConnectionFactory"/>
</bean>
<bean id="jmsCamelConfig" class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="pooledJmsConnectionFactory"/>
<property name="transacted" value="false"/>
<property name="concurrentConsumers" value="${concurrent.consumers}"/>
<property name="maxConcurrentConsumers" value="${max.concurrent.consumers}"/>
</bean>
<bean id="publicamq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="configuration" ref="jmsCamelConfig"/>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${persistence.driver}"/>
<property name="url" value="${persistence.url}"/>
<property name="username" value="${persistence.username}"/>
<property name="password" value="${persistence.password}"/>
<property name="minIdle" value="5"/>
<property name="validationQuery" value="select 1 from dual"/>
</bean>
<bean id="correlationInfoDao" class="bank.dao.CorrelationInfoDaoImpl">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="correlationInfoPersister" class="bank.processor.CorrelationInfoPersister">
<property name="correlationInfoDao" ref="correlationInfoDao"/>
</bean>
<camelContext id="adpfmoutconcurrent-context" xmlns="http://camel.apache.org/schema/blueprint">
<package>bank.route</package>
<dataFormats>
<jaxb id="asbofmout" prettyPrint="true" contextPath="bank.asbofmout"/>
</dataFormats>
</camelContext>
</blueprint>
答案 0 :(得分:0)
你应该使用
<DynamicImport-Package>oracle.jdbc.driver</DynamicImport-Package>
使用包名但不使用类名
顺便说一下,here
描述了有关此类问题的更多解释