users@glassfish.java.net

Re: Creating a JNDI for MySQL ?

From: <glassfish_at_javadesktop.org>
Date: Thu, 18 Oct 2007 14:55:40 PDT

Hello,

My First Method in my WS returns a String.
That works fine through the 'Test'.

My Second fetched all projects from my db called 'smallcompany'.
Using test, I get error.
The error in my browser is like this:
[i]Caused by: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b58c-fcs (08/21/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: com.mysql.jdbc.Driver
Error Code: 0
        at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:305)
        at oracle.toplink.essentials.jndi.JNDIConnector.connect(JNDIConnector.java:150)
        at oracle.toplink.essentials.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:184)
        at oracle.toplink.essentials.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:582)
        at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:280)
        at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:229)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:93)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:126)
        at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:99)
        at com.sun.enterprise.util.EntityManagerWrapper._getDelegate(EntityManagerWrapper.java:326)
        at com.sun.enterprise.util.EntityManagerWrapper.createNamedQuery(EntityManagerWrapper.java:724)
        at ws.ProjectManagerWs.getProjects(ProjectManagerWs.java:26)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
        at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
        at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
        at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3986)
        at com.sun.ejb.containers.WebServiceInvocationHandler.invoke(WebServiceInvocationHandler.java:189)
        ... 64 more
Caused by: java.sql.SQLException: Error in allocating a connection. Cause: [b]com.mysql.jdbc.Driver[/b]
        at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:115)
        at oracle.toplink.essentials.jndi.JNDIConnector.connect(JNDIConnector.java:145)
        ... 83 more
|#][/i]

The error in my server.log ends with this:
[i]Caused by: java.sql.SQLException: Error in allocating a connection. Cause: com.mysql.jdbc.Driver
        at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:115)
        at oracle.toplink.essentials.jndi.JNDIConnector.connect(JNDIConnector.java:145)
        ... 83 more
|#][/i]

I am choosing 'com.mysql.jdbc.Driver' due to the fact that this was the driver I used in my JBoss 'mysql-ds.xml' file, I used the same driver in my resource.xml which km helped me with.

the orignal file has the following datasource:
datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
which I changed in my file to the :

my whole resource file is like this:
[i]<resources>
    <jdbc-connection-pool
        name="mysql-pool"
        datasource-classname="[b]com.mysql.jdbc.Driver[/b]"
        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]

I will try to re-read the resource file with the org. datasource ....


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

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