This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JBoss/WildFly and the fly likes Deploying EJB using MySql as a datasource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Deploying EJB using MySql as a datasource" Watch "Deploying EJB using MySql as a datasource" New topic
Author

Deploying EJB using MySql as a datasource

Mary Taylor
Ranch Hand

Joined: Sep 11, 2000
Posts: 319
JBoss is giving the following two errors when deploying an Entity Bean using MySql as the data source. I can send any additional configuration files you wish to see. I do have an application.xml file in the location where JBoss indicates the file is missing.
In reference to the first error, I did a search within the configuration files to find where JBoss might be requesting the "30.mysql-ds.xml" file and found no file calling for such a file. There is a "mysql-ds.xml" file in the location where JBoss says it is looking for the "30.mysql-ds.xml" file.
Here are the log file errors from JBoss. Thank you for any assistance. I have been working on this diligently for two grad school assignments but am stymied with the projects due next Monday. I've researched JBoss and MySql issues for a week now. Appreciate any direction.
Regards
Betty
JBoss jboss-3.2.1_tomcat-4.1.24
MySql 4.-.13-nt
jdk1.4.1_04
MyEclipse 3.0
2:56:52,964 ERROR [MainDeployer] Could not make local copy for
file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/deploy/mysql-ds.xml
java.io.FileNotFoundException: C:\jboss-3.2.1_tomcat-4.1.24\server\default\tmp\deploy\server\default\deploy\mysql-ds.xml\30.mysql-ds.xml (The system cannot find the path specified)
2004-03-04 23:24:48,073 ERROR [org.jboss.deployment.scanner.URLDeploymentScanner] Failed to deploy: org.jboss.deployment.scanner.URLDeploymentScanner$DeployedURL@1ffaef8{ url=file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/deploy/MSCO676Lab3.ear/, deployedLastModified=0 }
org.jboss.deployment.DeploymentException: exception in init of file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/deploy/MSCO676Lab3.ear/; - nested throwable: (org.jboss.deployment.DeploymentException: No META-INF/application.xml found)
Here is the mysql-ds.xml:
<datasources>
<local-tx-datasource>
<jndi-name>MySqlDS</jndi-name>
<connection-url>jdbc:mysql//localhost:3306/addressList</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name></user-name>
<password></password>
</local-tx-datasource>
</datasources>
Here is the application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">
<application>
<display-name>MSCO676Lab3</display-name>
<module id="myeclipse.1075431673085">
<web>
<web-uri>MSCO676Lab3Web.war</web-uri>
<context-root>/MSCO676Lab3Web</context-root>
</web>
</module>
<module id="myeclipse.1075431673846">
<ejb>MSCO676Lab3EJB.jar</ejb>
</module>
</application>

Here is my login-conf.xml also:
<?xml version='1.0'?>
<!DOCTYPE policy PUBLIC
"-//JBoss//DTD JBOSS Security Config 3.0//EN"
"http://www.jboss.org/j2ee/dtd/security_config.dtd">
<!-- The XML based JAAS login configuration read by the
org.jboss.security.auth.login.XMLLoginConfig mbean. Add
an application-policy element for each security domain.
The outline of the application-policy is:
<application-policy name="security-domain-name">
<authentication>
<login-module code="login.module1.class.name" flag="control_flag">
<module-option name = "option1-name">option1-value</module-option>
<module-option name = "option2-name">option2-value</module-option>
...
</login-module>
<login-module code="login.module2.class.name" flag="control_flag">
...
</login-module>
...
</authentication>
</application-policy>
$Revision: 1.6.2.1 $
-->
<policy>
<!-- Used by clients within the application server VM such as
mbeans and servlets that access EJBs.
-->
<application-policy name = "client-login">
<authentication>
<login-module code = "org.jboss.security.ClientLoginModule"
flag = "required">
</login-module>
</authentication>
</application-policy>
<!-- Security domain for JBossMQ -->
<application-policy name = "jbossmq">
<authentication>
<login-module code = "org.jboss.mq.sm.file.DynamicLoginModule"
flag = "required">
<module-option name = "unauthenticatedIdentity">guest</module-option>
<module-option name = "sm.objectname">jboss.mq:service=StateManager</module-option>
</login-module>
</authentication>
</application-policy>
<!-- Security domains for testing new jca framework -->
<application-policy name = "HsqlDbRealm">
<authentication>
<login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule"
flag = "required">
<module-option name = "principal">sa</module-option>
<module-option name = "userName">sa</module-option>
<module-option name = "password"></module-option>
<module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=DefaultDS</module-option>
</login-module>
</authentication>
</application-policy>
<application-policy name = "FirebirdDBRealm">
<authentication>
<login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule"
flag = "required">
<module-option name = "principal">sysdba</module-option>
<module-option name = "userName">sysdba</module-option>
<module-option name = "password">masterkey</module-option>
<module-option name = "managedConnectionFactoryName">jboss.jca:service=XaTxCM,name=FirebirdDS</module-option>
</login-module>
</authentication>
</application-policy>
<application-policy name = "JmsXARealm">
<authentication>
<login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule"
flag = "required">
<module-option name = "principal">guest</module-option>
<module-option name = "userName">guest</module-option>
<module-option name = "password">guest</module-option>
<module-option name = "managedConnectionFactoryName">jboss.jca:service=TxCM,name=JmsXA</module-option>
</login-module>
</authentication>
</application-policy>
<!-- A template configuration for the jmx-console web application. This
defaults to the UsersRolesLoginModule the same as other and should be
changed to a stronger authentication mechanism as required.
-->
<application-policy name = "jmx-console">
<authentication>
<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
flag = "required" />
</authentication>
</application-policy>
<!-- The default login configuration used by any security domain that
does not have a application-policy entry with a matching name
-->
<application-policy name = "other">
<!-- A simple server login module, which can be used when the number
of users is relatively small. It uses two properties files:
users.properties, which holds users (key) and their password (value).
roles.properties, which holds users (key) and a comma-separated list of their roles (value).
The unauthenticatedIdentity property defines the name of the principal that will be used when a null username and password are presented as is the case for an unuathenticated web client or MDB. If you want to allow such users to be authenticated add the property, e.g.,
unauthenticatedIdentity="nobody"
-->
<authentication>
<login-module code = "org.jboss.security.auth.spi.UsersRolesLoginModule"
flag = "required" />
</authentication>
</application-policy>
</policy>
I read that I can use the getConnection(user,pswd) for login without defining a security domain in the login-config.xml, but that if I did define one, it would take precedence. As you can see, I have not done so.
Thanks to anyone who can read through all this and assist.
[ March 05, 2004: Message edited by: Betty Schwartz ]
[ March 05, 2004: Message edited by: Betty Schwartz ]
[ March 05, 2004: Message edited by: Betty Schwartz ]
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Moving to the JBoss forum...
Mary Taylor
Ranch Hand

Joined: Sep 11, 2000
Posts: 319
If I do need to create an entry in login-conf.xml,I would appreciate some clarification on the entries. The module-opion name of "principal" - how is that created in the database? I assume the username and password are those I use in my getConnection request. I guess I don't understand the connection between the login-conf and my application. My next class is a database admin class; but, meanwhile, I'm a bit rusty and have been looking on the web but not finding information aout the simple things sometimes.
A message at http://junlu.com/msg/36941.html indicates I do not have to have a login-conf.xml entry for MySql, but some seem to think I cannot accomplish the deployment without one. As always there are many paths to go down.
Thanks again,
Betty
Rashmi Banthia
Ranch Hand

Joined: Dec 22, 2003
Posts: 79
Betty,
I also have similar configuration. Here is what I did :
Modified login-config.xml, standardjbosscmp-jdbc.xml and mysql_db-service.xml (listed below only the modification) :
<!-- login-config.xml -----changes only ----->
<application-policy name="MySqlDbRealm">
<authentication>
<login-module code="org.jboss.resource.security.ConfiguredIdentityLoginModule" flag="required">
<module-option name="principal">rashmi</module-option>
<module-option name="userName">rashmi</module-option>
<module-option name="password">rashmi</module-option>
<module-option name="managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=MySqlDS</module-option>
</login-module>
</authentication>
</application-policy>
<!---standardjbosscmp-jdbc.xml -----changes only --->
<jbosscmp-jdbc>
<defaults>
<datasource>java:/MySqlDS</datasource>
<datasource-mapping>mySQL</datasource-mapping>

<create-table>false</create-table>

<remove-table>false</remove-table>
<read-only>false</read-only>
<time-out>300</time-out>
<pk-constraint>true</pk-constraint>
<fk-constraint>false</fk-constraint>
<row-locking>false</row-locking>
<preferred-relation-mapping>foreign-key</preferred-relation-mapping>
<read-ahead>
<strategy>on-load</strategy>
<page-size>1000</page-size>
<eager-load-group>*</eager-load-group>
</read-ahead>
<list-cache-max>1000</list-cache-max>
</defaults>
<enterprise-beans>

<entity>
<ejb-name>EmployeeEJB</ejb-name>
<table-name>Employee</table-name>
<home>com.dataentry.EmployeeHome</home>
<remote>com.dataentry.Employee</remote>
<ejb-class>com.dataentry.EmployeeBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
<reentrant>False</reentrant>
<abstract-schema-name>Employee</abstract-schema-name>
<cmp-version>2.x</cmp-version>
<cmp-field><field-name>emp_id</field-name> </cmp-field>
<cmp-field> <field-name>ssn</field-name> </cmp-field>
<cmp-field> <field-name>firstname</field-name> </cmp-field>
<cmp-field> <field-name>lastname</field-name> </cmp-field>
<cmp-field> <field-name>streetaddress</field-name> </cmp-field>
<cmp-field> <field-name>city</field-name> </cmp-field>
<cmp-field> <field-name>state</field-name> </cmp-field>
<cmp-field> <field-name>zip</field-name> </cmp-field>
<cmp-field> <field-name>comments</field-name> s</cmp-field>
<primkey-field>emp_id</primkey-field>
</entity>
</enterprise-beans>
<!--- mysql_db-service.xml -----changes only ---->
<!--embedded mbean-->
<mbean code="org.jboss.resource.connectionmanager.RARDeployment" name="jboss.jca:service=LocalTxDS,name=MySqlDS">
<attribute name="JndiName">MySqlDS</attribute>
<attribute name="ManagedConnectionFactoryProperties">
<properties>
<config-property name="ConnectionURL" type="java.lang.String">jdbc:mysql://localhost:3306/learnejb</config-property>
<config-property name="DriverClass" type="java.lang.String">org.gjt.mm.mysql.Driver</config-property>
<!--set these only if you want only default logins, not through JAAS -->
<config-property name="UserName" type="java.lang.String">rashmi</config-property>
<config-property name="Password" type="java.lang.String">rashmi</config-property>
</properties>
</attribute>
Hope it helps.
Regards,
Rashmi
 
 
subject: Deploying EJB using MySql as a datasource