JBOSS not connecting to MySQL
kasturiranganr Aug 13, 2004 11:30 AMHello,
I am trying to implement a simple CMP EJB under JBOSS but
am having a problem connecting to MySQL. Specifically, the
error message I get when I start JBOSS is
org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException: Data source rejected establishment of connection, message from server: "Host 'localhost.localdomain' is not allowed to connect to this MySQL server")
JBOSS binds the LicenseServerDS datasource (that startup msg not shown here) but fails while deploying the 'ProductEJB' (my CMP bean)
Everything is taking place on my local machine.
The steps I followed were
1. Edited mysql-ds.xml and copied it to the
JBOSS_HOME/server/default/deploy directory.
2. Wrote the bean classes/interfaces and the associated XML
descriptors and packaged them into a jar file also in
JBOSS_HOME/server/default/deploy directory.
3. Started JBOSS.
4. Ran into the problem above.
I am pasting below the 4 XML descriptors I use for my application
mysql-ds.xml
----------------------------------------------------------------------------------------------------------------------
<!--
$Id: mysql-ds.xml,v 1.1.2.1 2003/12/12 19:19:56 starksm Exp $
-->
-
<!--
Datasource config for MySQL using 3.0.9 available from:
http://www.mysql.com/downloads/api-jdbc-stable.html
-->
-
<local-tx-datasource>
<jndi-name>LicenseServerDS</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/licenseserver</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
38cdc0f35996e1a9
</local-tx-datasource>
----------------------------------------------------------------------------------------------------------------------
The password above is encrypted. I have also tried with the de-encrypted password.
ejb-jar.xml
----------------------------------------------------------------------------------------------------------------------
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise
JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<ejb-name>ProductEJB</ejb-name>
com.javasrc.licenseserver.ejb.product.ProductHomeRemote
com.javasrc.licenseserver.ejb.product.ProductRemote
<ejb-class>com.javasrc.licenseserver.ejb.product.ProductBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
False
<cmp-version>2.x</cmp-version>
<abstract-schema-name>Product</abstract-schema-name>
<cmp-field><field-name>id</field-name></cmp-field>
<cmp-field><field-name>name</field-name></cmp-field>
<primkey-field>id</primkey-field>
<security-identity><use-caller-identity/></security-identity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<ejb-name>ProductEJB</ejb-name>
<method-name>*</method-name>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
----------------------------------------------------------------------------------------------------------------------
jbosscmp-jdbc.xml
----------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jbosscmp-jdbc PUBLIC
"-//JBoss//DTD JBOSSCMP-JDBC 3.0//EN"
"http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_0.dtd">
<jbosscmp-jdbc>
java:/LicenseServerDS
<datasource-mapping>mySQL</datasource-mapping>
<create-table>true</create-table>
<remove-table>true</remove-table>
<enterprise-beans>
<ejb-name>ProductEJB</ejb-name>
<table-name>Product</table-name>
<cmp-field>
<field-name>id</field-name>
<column-name>product_id</column-name>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
<column-name>product_name</column-name>
</cmp-field>
</enterprise-beans>
</jbosscmp-jdbc>
----------------------------------------------------------------------------------------------------------------------
jboss.xml
----------------------------------------------------------------------------------------------------------------------
<?xml version="1.0"?>
<enterprise-beans>
<ejb-name>ProductEJB</ejb-name>
<jndi-name>ProductHomeRemote</jndi-name>
</enterprise-beans>
----------------------------------------------------------------------------------------------------------------------
Could someone help me please?
Thanks,
Sharad