users@glassfish.java.net

Re: Creating a JNDI for MySQL ?

From: <glassfish_at_javadesktop.org>
Date: Thu, 18 Oct 2007 08:36:36 PDT

Hi Km and Sivakumar Thyag,

Did follow the advice given by you, km.
I configured the resource file as this::

[i]<resources>
    <jdbc-connection-pool
        name="mysql-pool"
        datasource-classname="com.mysql.jdbc.Driver"
        res-type="javax.sql.DataSource">
        <property name="user" value="root"/>
        <property name="password" value="root"/>
        <property name="url" value="jdbc:mysql://localhost:3306/smallcompany"/>
    </jdbc-connection-pool>

    <jdbc-resource
        enabled="true"
        jndi-name="jdbc/company"
        object-type="user"
        pool-name="mysql-pool"/>
</resources> [/i]

The only thing that differs is that the jndi-name is =>
 jndi-name="jdbc/company" instead of my "company" name in the mysql-ds.xml.
So I did the following change in my '~/META-INF/persistence.xml' file
 <jta-data-source>jdbc/company</jta-data-source>

My Glassfish is running; running it through Eclipse.

then I did the following:
C:\app\mysql-resurs>%glassfish_home%\bin\asadmin add-resources resources.xml
 =========================
Added Resource Type: jdbc-connection-pool
 =========================
Added Resource Type: jdbc-resource
Command add-resources executed successfully.

So it seems to have worked out.

When deploying my file ProjectManagerWs which is like this:
@Stateless()
@WebService()
public class ProjectManagerWs {

    @PersistenceContext(unitName = "company")
    private EntityManager em;
    @WebMethod
    public String version() {
        return "ProjectManager version 0.1";
    }
}

I get the following :

[#|2007-10-18T17:16:42.173+0200|SEVERE|sun-appserver9.1|javax.enterprise.system.core.classloading|_ThreadID=10;_ThreadName=main;_RequestID=0f2b1292-3c45-4224-9fa2-60ee4746aba6;|LDR5013: Naming exception while creating EJB container:
javax.naming.NameAlreadyBoundException: Use rebind to override

Do you have any Idea ?

regards, i
[Message sent by forum member 'inkimar' (inkimar)]

http://forums.java.net/jive/thread.jspa?messageID=240964