[jboss-user] [JNDI/Naming/Network] - Re: Dtabase connection Error(Mysql)

pepelara do-not-reply at jboss.com
Sat May 24 04:22:04 EDT 2008


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

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4153147#4153147

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4153147



More information about the jboss-user mailing list