0

I am doing a project on Eclipse Kepler using JPA 2.1, EclipseLink 2.5, Struts 1.3 and deployed on Tomcat 7.0. I create a project named JPADataSource. Under these conditions, my project works fine. While, when I add DataSources (MySQL) to the project, it does not work anymore. When I try to run the code, I get this error:

javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'jdbc:mysql://localhost:3306/playlist?autoReconnect=true'

I set everything in my code. This is my context.xml (placed in /JPADataSource/WebContent/META-INF/):

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/JPADataSource">
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
  <ResourceLink
    global="jdbc/playlist"
    name="jdbc/playlist"
    type="javax.sql.DataSource">
  </ResourceLink>    
</Context>

This is my persistance.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <persistence-unit name="JPADataSource" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <non-jta-data-source>java:comp/env/jdbc/playlist</non-jta-data-source>  
        <class>model.Singer</class>
        <class>model.Song</class>
        <class>model.User</class>
        <class>model.UserPlaylist</class>
    </persistence-unit>
</persistence>

And, at last, this is what I inserted under <GlobalNamingResources> in my server.xml (placed in /Server/Tomcat v7.0 Server at localhost-config/):

<Resource auth="Container" driverClass="com.mysql.jdbc.Driver" maxActive="100" maxIdle="30" maxWait="10000" name="jdbc/playlist" password="root" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/playlist?autoReconnect=true" username="root"/>

What am I doing wrong? Or, what am I missing/misplacing?

Any help is apreciated.

2

1 Answer 1

1

use "driverClassName" attribute instead of "driverClass". I hope it will resolve your query.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.