我想将c3p0
连接池集成到JBoss EAP 6.3.0.GA (AS 7.4.0.Final-redhat-19)
到Mbean
服务中。用Google搜索一些示例并尝试将其集成。
这是我的配置。
已将c3p0
个jar和module.xml
添加到模块目录{JBOSS_HOME}/modules/system/layers/base/com/c3p0/main
,module.xml
config:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.c3p0">
<resources>
<resource-root path="c3p0-0.9.5.1.jar"/>
<resource-root path="c3p0-oracle-thin-extras-0.9.5.1.jar"/>
<resource-root path="mchange-commons-java-0.2.10.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
在standalone.xml
中将c3p0
添加到全局模块(classpath)中:
<subsystem xmlns="urn:jboss:domain:ee:1.2">
<global-modules>
<module name="com.c3p0" slot="main"/>
</global-modules>
</subsystem>
将服务文件添加到{JBOSS_HOME}/standalone/deployments/c3p0-service.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<server xmlns="urn:jboss:service:7.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:service:7.0 jboss-service_7_0.xsd">
<mbean code="com.mchange.v2.c3p0.jboss.C3P0PooledDataSource"
name="jboss.jca:service=DataSourceBinding,name=jdbc/myDB">
<attribute name="JndiName">java:jdbc/myDB</attribute>
<attribute name="JdbcUrl">jdbc:oracle:thin:@server.com:1521:sid</attribute>
<attribute name="DriverClass">oracle.jdbc.driver.OracleDriver</attribute>
<attribute name="User">username</attribute>
<attribute name="Password">password</attribute>
<attribute name="MaxPoolSize">20</attribute>
<attribute name="AcquireRetryAttempts">0</attribute>
<depends>jboss:service=Naming</depends>
</mbean>
</server>
将数据源配置与standalone.xml
分开放入同一目录中的{JBOSS_HOME}/standalone/deployments/c3p0-ds.xml
,ojdbc6.jar
。
<datasources xmlns="http://www.jboss.org/ironjacamar/schema">
<datasource jta="false" jndi-name="java:/jdbc/myDB" pool-name="myDB" enabled="true" use-ccm="false" use-java-context="true">
<connection-url>jdbc:oracle:thin:@server.com:1521:sid</connection-url>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<driver>ojdbc6.jar</driver>
<security>
<user-name>username</user-name>
<password>password</password>
</security>
<pool>
<min-pool-size>30</min-pool-size>
<max-pool-size>300</max-pool-size>
<prefill>true</prefill>
</pool>
<timeout>
<blocking-timeout-millis>120000</blocking-timeout-millis>
<idle-timeout-minutes>5</idle-timeout-minutes>
</timeout>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
</datasources>
web.xml
<resource-ref>
<description>
</description>
<res-ref-name>jdbc/myDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
jboss-web.xml
<resource-ref>
<res-ref-name>jdbc/myDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<jndi-name>java:/jdbc/myDB</jndi-name>
</resource-ref>
在部署结束时,我收到错误:
New missing/unsatisfied dependencies:
service jboss.mbean.service.jboss:service=Naming.create (missing) dependents: [service jboss.mbean.service."jboss.jca:service=DataSourceBinding,name=jdbc/myDB".create]
service jboss.mbean.service.jboss:service=Naming.start (missing) dependents: [service jboss.mbean.service."jboss.jca:service=DataSourceBinding,name=jdbc/myDB".start]
我尝试了很多mbean&#39; name&#39;属性,但似乎问题是在依赖...需要帮助我做错了。 任何帮助将不胜感激!
编辑:找到另一种方法,如下所述。