This content has been marked as final.
Show 1 reply
-
1. Re: Dtabase connection Error(Mysql)
pepelara May 24, 2008 4:22 AM (in response to badhikary81)I have set up MySQL as default DataSource (DefaultDS). You can try it.
I think this is not the question because I guess you are on a BMP Ejb.
Anyway, what version are you using? I am using 4.2.2 GA and I have no
any jboss-ds.xml. Can you tell me if it is a BMP and the version of your JBoss.
By the way, I am observing your code,
private CustomerFacadeRemote lookupCustomerFacadeBean() {
try {
return ((ejb.CustomerFacadeRemoteHome) getServiceLocator().getRemoteHome("java:comp/env/CustomerFacadeBean", ejb.CustomerFacadeRemoteHome.class)).create();
Try to simplify. This is my client to call to the EJB,Properties properties = new Properties(); properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); properties.put(Context.PROVIDER_URL, "localhost:1099"); try { // Get an initial context InitialContext jndiContext = new InitialContext(properties); System.out.println("Got context"); // Get a reference to the Bean Object ref = jndiContext.lookup("BMPBooks"); System.out.println("Got reference"); // Get a reference from this to the Bean's Home interface BooksHomeRemote home = (BooksHomeRemote) PortableRemoteObject.narrow(ref, BooksHomeRemote.class);
And now I can create the bean (home.create(...))
I give you the descriptors,The ejb-jar.xml, <?xml version="1.0" encoding="UTF-8"?> <ejb-jar id="ejb-jar_ID" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"> <description>Your first EJB application </description> <display-name>Bookstore Application</display-name> <enterprise-beans> <entity> <ejb-name>BMPBooks</ejb-name> <home>es.deusto.ejb.BooksHomeRemote</home> <remote>es.deusto.ejb.BooksRemote</remote> <ejb-class>es.deusto.ejb.BooksBean</ejb-class> <persistence-type>Bean</persistence-type> <prim-key-class>java.lang.Integer</prim-key-class> <reentrant>false</reentrant> <env-entry> <env-entry-name>dbUrl</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>jdbc:mysql://localhost:3306/myDB</env-entry-value> </env-entry> <env-entry> <env-entry-name>dbUserName</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>myDbUser</env-entry-value> </env-entry> <env-entry> <env-entry-name>dbPassword</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>myDbPassword</env-entry-value> </env-entry> </entity> </enterprise-beans> </ejb-jar>
And the application.xml, <?xml version="1.0" encoding="UTF-8"?> <application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"> <display-name>MyBookstore</display-name> <description>Application description</description> <module> <ejb>bookstore-ejb.jar</ejb> </module> <module> <java>bookstore-client.jar</java> </module> </application>
I hope it help you
Regarding,
Jose Alvarez de Lara