'New missing/unsatisfied dependencies' JBoss EAP 6.3.0.GA (AS 7.4.0.Final-redhat-19) 环境中的 c3p0 池错误
'New missing/unsatisfied dependencies' error with c3p0 pooling in JBoss EAP 6.3.0.GA (AS 7.4.0.Final-redhat-19) env
我想通过 Mbean
服务将 c3p0
连接池集成到 JBoss EAP 6.3.0.GA (AS 7.4.0.Final-redhat-19)
中。用谷歌搜索了一些示例并尝试将其集成。
这是我的配置。
将 c3p0
罐子和 module.xml
添加到模块目录 {JBOSS_HOME}/modules/system/layers/base/com/c3p0/main
、module.xml
配置中:
<?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
添加到全局模块(类路径)中:
<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 'name' 属性的变体,但问题似乎出在依赖项中......需要帮助我做错了什么。
任何帮助将不胜感激!
EDIT: Found another approach which is described below.
使用另一个解决方案如何将 c3p0 连接池添加到 JBoss EAP 6.3.0.GA (AS 7.4.0.Final-redhat-19,因为标签在 JBoss 7(正如我从 this 主题中了解到的那样)。我使用了服务存档 (SAR) 方法。
首先,我们需要将 c3p0
模块添加到具有指定 JAR 的 JBoss(不记得是否需要所有 JAR):
<?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"/>
<module name="com.oracle.ojdbc6"/>
<module name="org.hibernate"/>
</dependencies>
</module>
将 c3p0
全局模块添加到 standalone.xml
(如问题部分)。
将数据源添加到 standalone.xml
<subsystem xmlns="urn:jboss:domain:datasources:1.2">
<datasources>
<datasource jta="false" jndi-name="java:/jdbc/myDB" pool-name="myDB" enabled="true" use-ccm="false">
<connection-url>jdbc:oracle:thin:@server.com:1521:sid</connection-url>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<driver>oracle</driver>
<pool>
<min-pool-size>30</min-pool-size>
<max-pool-size>300</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>username</user-name>
<password>password</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<timeout>
<blocking-timeout-millis>120000</blocking-timeout-millis>
<idle-timeout-minutes>5</idle-timeout-minutes>
</timeout>
<statement>
<share-prepared-statements>true</share-prepared-statements>
</statement>
</datasource>
<drivers>
<driver name="oracle" module="com.oracle.ojdbc6">
<datasource-class>oracle.jdbc.driver.OracleDriver</datasource-class>
</driver>
</drivers>
</datasources>
在部署中创建文件夹,例如 c3p0Pool.sar
。创建 META-INF
个文件夹 {JBOSS_HOME}/standalone/deployments/c3p0Pool.sar/META-INF
。在此文件夹中创建内容为 jboss-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="sar.C3P0PoolBinding" name="c3p0:service=c3p0Pool">
<attribute name="JndiName">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="AcquireIncrement">0</attribute>
</mbean>
</server>
创建class和接口(classes名称应该正确命名:ClassName和ClassNameMBean):
package sar;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.NamingException;
import com.mchange.v2.c3p0.jboss.C3P0PooledDataSource;
public class C3P0PoolBinding implements C3P0PoolBindingMBean {
private String JndiName;
private String JdbcUrl;
private String DriverClass;
private String User;
private String Password;
private int MaxPoolSize;
private int AcquireIncrement;
private C3P0PooledDataSource c3p0;
public C3P0PoolBinding() {}
public String getJndiName() {
return this.JndiName;
}
public void setJndiName(String parameter) throws NamingException {
this.JndiName = parameter;
}
public String getJdbcUrl() {
return this.JdbcUrl;
}
public void setJdbcUrl(String jdbcUrl) throws NamingException {
this.JdbcUrl = jdbcUrl;
}
public String getDriverClass() {
return this.DriverClass;
}
public void setDriverClass(String driverClass) throws NamingException {
this.DriverClass = driverClass;
}
public String getUser() {
return this.User;
}
public void setUser(String user) throws NamingException {
this.User = user;
}
public String getPassword() {
return this.Password;
}
public void setPassword(String password) throws NamingException {
this.Password = password;
}
public int getMaxPoolSize() {
return this.MaxPoolSize;
}
public void setMaxPoolSize(int maxPoolSize) throws NamingException {
this.MaxPoolSize = maxPoolSize;
}
public int getAcquireIncrement() {
return this.AcquireIncrement;
}
public void setAcquireIncrement(int acquireIncrement) throws NamingException {
this.AcquireIncrement = acquireIncrement;
}
public void start() throws Exception {
Logger.getLogger(C3P0PoolBinding.class.getName()).log(Level.INFO, "Enabling c3p0 connection Pool");
try {
c3p0 = new C3P0PooledDataSource();
c3p0.setJndiName(JndiName);
c3p0.setJdbcUrl(JdbcUrl);
c3p0.setDriverClass(DriverClass);
c3p0.setUser(User);
c3p0.setPassword(Password);
c3p0.setMaxPoolSize(MaxPoolSize);
c3p0.setAcquireIncrement(AcquireIncrement);
c3p0.start();
} catch (NamingException ex) {
ex.printStackTrace();
}
}
public void stop() throws Exception {
Logger.getLogger(C3P0PoolBinding.class.getName()).log(Level.INFO, "Stopping c3p0 connection Pool");
c3p0.destroy();
}
}
接口:
package sar;
import javax.naming.NamingException;
public interface C3P0PoolBindingMBean {
public String getJndiName();
public void setJndiName(String JndiName) throws NamingException;
public String getJdbcUrl();
public void setJdbcUrl(String jdbcUrl) throws NamingException;
public String getDriverClass();
public void setDriverClass(String driverClass) throws NamingException;
public String getUser();
public void setUser(String user) throws NamingException;
public String getPassword();
public void setPassword(String password) throws NamingException;
public int getMaxPoolSize();
public void setMaxPoolSize(int maxPoolSize) throws NamingException;
public int getAcquireIncrement();
public void setAcquireIncrement(int acquireIncrement) throws NamingException;
}
最后,使用这些 classes 创建 JAR 文件并将其放置到 {JBOSS_HOME}/standalone/deployments/c3p0Pool.sar/c3p0Jar.jar
现在 c3p0 池应该按预期工作。
我想通过 Mbean
服务将 c3p0
连接池集成到 JBoss EAP 6.3.0.GA (AS 7.4.0.Final-redhat-19)
中。用谷歌搜索了一些示例并尝试将其集成。
这是我的配置。
将 c3p0
罐子和 module.xml
添加到模块目录 {JBOSS_HOME}/modules/system/layers/base/com/c3p0/main
、module.xml
配置中:
<?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
添加到全局模块(类路径)中:
<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 'name' 属性的变体,但问题似乎出在依赖项中......需要帮助我做错了什么。 任何帮助将不胜感激!
EDIT: Found another approach which is described below.
使用另一个解决方案如何将 c3p0 连接池添加到 JBoss EAP 6.3.0.GA (AS 7.4.0.Final-redhat-19,因为标签在 JBoss 7(正如我从 this 主题中了解到的那样)。我使用了服务存档 (SAR) 方法。
首先,我们需要将 c3p0
模块添加到具有指定 JAR 的 JBoss(不记得是否需要所有 JAR):
<?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"/>
<module name="com.oracle.ojdbc6"/>
<module name="org.hibernate"/>
</dependencies>
</module>
将 c3p0
全局模块添加到 standalone.xml
(如问题部分)。
将数据源添加到 standalone.xml
<subsystem xmlns="urn:jboss:domain:datasources:1.2">
<datasources>
<datasource jta="false" jndi-name="java:/jdbc/myDB" pool-name="myDB" enabled="true" use-ccm="false">
<connection-url>jdbc:oracle:thin:@server.com:1521:sid</connection-url>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<driver>oracle</driver>
<pool>
<min-pool-size>30</min-pool-size>
<max-pool-size>300</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>username</user-name>
<password>password</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<timeout>
<blocking-timeout-millis>120000</blocking-timeout-millis>
<idle-timeout-minutes>5</idle-timeout-minutes>
</timeout>
<statement>
<share-prepared-statements>true</share-prepared-statements>
</statement>
</datasource>
<drivers>
<driver name="oracle" module="com.oracle.ojdbc6">
<datasource-class>oracle.jdbc.driver.OracleDriver</datasource-class>
</driver>
</drivers>
</datasources>
在部署中创建文件夹,例如 c3p0Pool.sar
。创建 META-INF
个文件夹 {JBOSS_HOME}/standalone/deployments/c3p0Pool.sar/META-INF
。在此文件夹中创建内容为 jboss-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="sar.C3P0PoolBinding" name="c3p0:service=c3p0Pool">
<attribute name="JndiName">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="AcquireIncrement">0</attribute>
</mbean>
</server>
创建class和接口(classes名称应该正确命名:ClassName和ClassNameMBean):
package sar;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.NamingException;
import com.mchange.v2.c3p0.jboss.C3P0PooledDataSource;
public class C3P0PoolBinding implements C3P0PoolBindingMBean {
private String JndiName;
private String JdbcUrl;
private String DriverClass;
private String User;
private String Password;
private int MaxPoolSize;
private int AcquireIncrement;
private C3P0PooledDataSource c3p0;
public C3P0PoolBinding() {}
public String getJndiName() {
return this.JndiName;
}
public void setJndiName(String parameter) throws NamingException {
this.JndiName = parameter;
}
public String getJdbcUrl() {
return this.JdbcUrl;
}
public void setJdbcUrl(String jdbcUrl) throws NamingException {
this.JdbcUrl = jdbcUrl;
}
public String getDriverClass() {
return this.DriverClass;
}
public void setDriverClass(String driverClass) throws NamingException {
this.DriverClass = driverClass;
}
public String getUser() {
return this.User;
}
public void setUser(String user) throws NamingException {
this.User = user;
}
public String getPassword() {
return this.Password;
}
public void setPassword(String password) throws NamingException {
this.Password = password;
}
public int getMaxPoolSize() {
return this.MaxPoolSize;
}
public void setMaxPoolSize(int maxPoolSize) throws NamingException {
this.MaxPoolSize = maxPoolSize;
}
public int getAcquireIncrement() {
return this.AcquireIncrement;
}
public void setAcquireIncrement(int acquireIncrement) throws NamingException {
this.AcquireIncrement = acquireIncrement;
}
public void start() throws Exception {
Logger.getLogger(C3P0PoolBinding.class.getName()).log(Level.INFO, "Enabling c3p0 connection Pool");
try {
c3p0 = new C3P0PooledDataSource();
c3p0.setJndiName(JndiName);
c3p0.setJdbcUrl(JdbcUrl);
c3p0.setDriverClass(DriverClass);
c3p0.setUser(User);
c3p0.setPassword(Password);
c3p0.setMaxPoolSize(MaxPoolSize);
c3p0.setAcquireIncrement(AcquireIncrement);
c3p0.start();
} catch (NamingException ex) {
ex.printStackTrace();
}
}
public void stop() throws Exception {
Logger.getLogger(C3P0PoolBinding.class.getName()).log(Level.INFO, "Stopping c3p0 connection Pool");
c3p0.destroy();
}
}
接口:
package sar;
import javax.naming.NamingException;
public interface C3P0PoolBindingMBean {
public String getJndiName();
public void setJndiName(String JndiName) throws NamingException;
public String getJdbcUrl();
public void setJdbcUrl(String jdbcUrl) throws NamingException;
public String getDriverClass();
public void setDriverClass(String driverClass) throws NamingException;
public String getUser();
public void setUser(String user) throws NamingException;
public String getPassword();
public void setPassword(String password) throws NamingException;
public int getMaxPoolSize();
public void setMaxPoolSize(int maxPoolSize) throws NamingException;
public int getAcquireIncrement();
public void setAcquireIncrement(int acquireIncrement) throws NamingException;
}
最后,使用这些 classes 创建 JAR 文件并将其放置到 {JBOSS_HOME}/standalone/deployments/c3p0Pool.sar/c3p0Jar.jar
现在 c3p0 池应该按预期工作。