gpt4 book ai didi

java - ActiveMQ 5.8 : Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver'

转载 作者:太空宇宙 更新时间:2023-11-04 07:23:13 24 4
gpt4 key购买 nike

我正在尝试将 ActiveMQ persistenceAdapter 设置为 Oracle 11g (11.2) 数据库。当通过 Tanuki 包装器启动 ActiveMQ 时,我收到 Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver' 异常。我在网上搜索了几个小时,但没有找到任何相关答案。我的类路径是正确的。

我感觉 Tanuki 包装器没有考虑我的类路径自定义。

如果您发现任何错误,请告诉我或者为我提供一个可行的示例

我的设置是:
activemq.xml

<broker xmlns="http://activemq.apache.org/schema/core" brokerName="test1" dataDirectory="/path/to/existing">
...
<persistenceAdapter>
<jdbcPersistenceAdapter dataDirectory="/path/to/existing/activemq-data" dataSource="#oracle-ds"/>
</persistenceAdapter>
...
</broker>

<bean id="oracle-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value=" jdbc:oracle:thin:@db.domain:1521:DEV01 "/>
<property name="username" value="username"/>
<property name="password" value="password"/>
<property name="poolPreparedStatements" value="true"/>
</bean>

<import resource="jetty.xml"/>


wrapper.conf

wrapper.java.classpath.1=%ACTIVEMQ_HOME%/bin/wrapper.jar
wrapper.java.classpath.2=%ACTIVEMQ_HOME%/bin/activemq.jar
wrapper.java.classpath.3=%ACTIVEMQ_HOME%/lib/*
wrapper.java.classpath.4=%ACTIVEMQ_HOME%/lib/optional/ojdbc6.jar

完整堆栈跟踪

2013-09-24 14:07:15,973 | ERROR | Failed to load: class path resource [activemq.xml], reason: Error creating bean with name 'org.apache.activemq.xbean.XBeanBrokerService#0' defined in class path resource [activemq.xml]: Invocation of init method failed; nested exception is java.io.IOException: Cannot create JDBC driver of class 'oracle.jdbc.driver.OracleDriver' for connect URL ' jdbc:oracle:thin:@db.domain:1521:DEV01 ' | org.apache.activemq.xbean.XBeanBrokerFactory | WrapperSimpleAppMainorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.activemq.xbean.XBeanBrokerService#0' defined in class path resource [activemq.xml]: Invocation of init method failed; nested exception is java.io.IOException: Cannot create JDBC driver of class 'oracle.jdbc.driver.OracleDriver' for connect URL ' jdbc:oracle:thin:@db.domain:1521:DEV01 '        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:605)        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925)        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:472)        at org.apache.xbean.spring.context.ResourceXmlApplicationContext.(ResourceXmlApplicationContext.java:64)        at org.apache.xbean.spring.context.ResourceXmlApplicationContext.(ResourceXmlApplicationContext.java:52)        at org.apache.activemq.xbean.XBeanBrokerFactory$1.(XBeanBrokerFactory.java:101)        at org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext(XBeanBrokerFactory.java:101)        at org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBrokerFactory.java:65)        at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:71)        at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:54)        at org.apache.activemq.console.command.StartCommand.startBroker(StartCommand.java:125)       at org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:84)        at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)        at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:150)        at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)        at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:104)        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)        at java.lang.reflect.Method.invoke(Method.java:601)        at org.apache.activemq.console.Main.runTaskClass(Main.java:262)        at org.apache.activemq.console.Main.main(Main.java:115)        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)        at java.lang.reflect.Method.invoke(Method.java:601)        at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)        at java.lang.Thread.run(Thread.java:722)Caused by: java.io.IOException: Cannot create JDBC driver of class 'oracle.jdbc.driver.OracleDriver' for connect URL ' jdbc:oracle:thin:@db.domain:1521:DEV01 '        at org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:45)        at org.apache.activemq.store.jdbc.TransactionContext.getConnection(TransactionContext.java:68)        at org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.loadAdapter(JDBCPersistenceAdapter.java:434)       at org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.createAdapter(JDBCPersistenceAdapter.java:417)        at org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.getAdapter(JDBCPersistenceAdapter.java:366)        at org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.init(JDBCPersistenceAdapter.java:288)        at org.apache.activemq.broker.LockableServiceSupport.preStart(LockableServiceSupport.java:79)        at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:54)        at org.apache.activemq.broker.BrokerService.doStartPersistenceAdapter(BrokerService.java:598)        at org.apache.activemq.broker.BrokerService.startPersistenceAdapter(BrokerService.java:587)        at org.apache.activemq.broker.BrokerService.start(BrokerService.java:552)        at org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:60)        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)        at java.lang.reflect.Method.invoke(Method.java:601)        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1581)        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1522)        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)        ... 34 moreCaused by: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'oracle.jdbc.driver.OracleDriver' for connect URL ' jdbc:oracle:thin:@db.domain:1521:DEV01 '        at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452)        at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)        at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)        at org.apache.activemq.store.jdbc.TransactionContext.getConnection(TransactionContext.java:58)        ... 51 moreCaused by: java.sql.SQLException: No suitable driver        at java.sql.DriverManager.getDriver(DriverManager.java:289)        at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)        ... 54 more

最佳答案

我正在回答我自己的问题:

正如阿列克谢·奥金佐夫(Alexey Odintsov)指出的那样,我犯了一个错字。
要解决此问题,请在 activemq.xml 文件中更改行

<property name="url" value=" jdbc:oracle:thin:@db.domain:1521:DEV01 "/>

通过删除值引号内的前导和尾随空格

<property name="url" value="jdbc:oracle:thin:@db.domain:1521:DEV01"/>

关于java - ActiveMQ 5.8 : Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18981419/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com