problem with persistence unit [message #509047] |
Thu, 21 January 2010 04:38  |
Eclipse User |
|
|
|
Hi all,
I am newbie with Eclipse, and am trying to set up a JPA Project with EclipseLink in order to add persistence to a set of classes. The backend database is a MySQL db and have all necessary drivers installed (MySQLConnector). I believe I have something misunderstood or missed while setting the persistence.xml, context.xml, server.xml and web.xml.
I have followed the indications for such a setup in the link in the "Using JTA Datasource" variant.
http://wiki.eclipse.org/EclipseLink/Examples/JPA/Tomcat_Web_ Tutorial#Direct_connection_.28RESOURCE_LOCAL.29_Persistence. xml
But can't get it to work. I am working with Eclipse, Apache Tomcat 6.0 and MySQL, and the error returned is more or less like this:
(Eclipse Persistence Services - 1.1.2.v20090612-r4475): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Unable to acquire a connection from driver [null], user [null] and URL [null]. Verify that you have set the expected driver class and URL. Check your login, persistence.xml or sessions.xml resource. The jdbc.driver property should be set to a class that is compatible with your database platform
Here are the involved snippets for each of the above mentioned files.
Many thanks in advance. Any hint will help.
(server.xml)
<GobalNamingResources>
(...)
<Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory " name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
<Resource
name="jdbc/SistemaIncidencias"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="root"
password=""
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/SistemaIncidencias"
/>
(...)
</GlobalNamingResources>
(context.xml)
<Resource auth="Container"
driverClassName="com.mysql.jdbc.Driver"
maxActive="20"
maxIdle="10"
maxWait="-1"
name="jdbc/SistemaIncidencias"
password=""
type="javax.sql.DataSource"
url="jdbc:mysql://localhost:3306/SistemaIncidencias"
username="root"/>
(web.xml)
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/SistemaIncidencias</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
|
|
|
Re: problem with persistence unit [message #509174 is a reply to message #509047] |
Thu, 21 January 2010 10:16  |
Eclipse User |
|
|
|
uf, after seeking quite a bit a reached a solution. I am not sure wether the problem was of the versions I am using, but the EntityManagerFactory dindn't get through until I changed de jta-datasource from
jdbc/SistemaIncidencias
to
java:/comp/env/jdbc/SistemaIncidencias
which means it had to do with absolute naming issues.
In all examples I had seen it was relative. I didn't expect to have any results with this modification, since the resource was declared everywhere according to the EclipseLink/Tomcat guide referenced in the previous message.
I saw many ppl read it, though didn't answer anything. May it be I am posting at the wrong forum?
Anyway I hope this solution helps anyone.
Regards,
Carlos.
|
|
|
Powered by
FUDForum. Page generated in 0.05241 seconds