I am trying to use JBoss 4.0.3RC1 with MySQL 4.0.24 with Connector/J 3.1.8a and have not been successful so far. I have not been able to find a good source of documentation on this so I have tried to piece it together from multiple sources.
One must put a mysql-ds.xml file in <JBOSS_HOME>\server\default\deploy. Here is mine. <?xml version="1.0" encoding="UTF-8"?> <!-- $Id: mysql-ds.xml,v 1.3.2.1 2004/12/01 11:46:00 schrouf 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>MySqlDS</jndi-name> <connection-url>jdbc:mysql://localhost:3306/mysql</connection-url> <driver-class>com.mysql.jdbc.Driver</driver-class> <user-name>root</user-name> <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name> <!-- sql to call when connection is created <new-connection-sql>some arbitrary sql</new-connection-sql> --> <!-- sql to call on an existing pooled connection when it is obtained from pool <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql> --> <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) --> <type-mapping>mySQL</type-mapping> </local-tx-datasource> Then in the .ear file inside the .par file inside a folder called META-INF you must have a persistence.xml file. Here is mine. <?xml version="1.0" encoding="UTF-8"?> <entity-manager> person <jta-data-source>java:/MySqlDS</jta-data-source> pdb.PersonBean </entity-manager> I also copied the mysql-connector-java-3.1.8-bin.jar from my Connector/J distribution into <JBOSS_HOME>/server/default/lib directory. This is a Session Bean which tries to get an Entity Manager but always gets null; package pdb; import java.util.*; import javax.ejb.*; import javax.persistence.*; @Stateless public class FormBean implements FormInterface { private String firstName; private String lastName; private Hashtable<String, String> errors; // EntityManagerFactory emf = Persistence.createEntityManagerFactory("person"); // EntityManager em = emf.createEntityManager(); @PersistenceContext(unitName="person") protected EntityManager em; public boolean validate() throws EMNullException { boolean allOK=true; if(firstName.equals("")) { errors.put("firstName","Please enter your first name"); firstName=""; allOK=false; } if(lastName.equals("")) { errors.put("lastName","Please enter your last name"); lastName=""; allOK=false; } PersonBean person = new PersonBean(firstName, lastName); if(em != null) { em.persist( person ); } else { throw new EMNullException (); } return allOK; } public String getErrorMsg(String s) { String errorMsg=(String)errors.get(s.trim()); return (errorMsg == null) ? "":errorMsg; } public FormBean() { firstName = ""; lastName = ""; errors = new Hashtable<String, String>(); } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public void setFirstName( String fname) { firstName = fname; } public void setLastName( String lname ) { lastName = lname; } } Any help is greatly appreciated. Also when I deploy my .ear file, this is one of the messages displayed in the server startup window 13:53:25,750 INFO [JaccHelper] pdb.FormBean has no @SecurityDomain - skipping JACC configuration I don't know if it matters. Thanks, Mike Price View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3884573#3884573 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3884573 ------------------------------------------------------- This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual core and dual graphics technology at this free one hour event hosted by HP, AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar _______________________________________________ JBoss-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jboss-user
