| Beginner's Problem / strange behavior [message #1016966] |
Fri, 08 March 2013 06:32  |
Daniel Flassak Messages: 3 Registered: March 2013 |
Junior Member |
|
|
I am just switching from Hibernate to EclipseLink and am facing a strange problem.
Here's my persistence.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns:xsi="removed because i am not allowed to post links"
xsi:schemaLocation="removed because i am not allowed to post links"
version="2.0" xmlns="removed because i am not allowed to post links">
<persistence-unit name="it-status" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/ampel" />
<property name="javax.persistence.jdbc.user" value="ampel" />
<property name="javax.persistence.jdbc.password" value="ampel" />
<property name="eclipselink.jdbc.connections.initial" value="1" />
<property name="eclipselink.jdbc.connections.min" value="16" />
<property name="eclipselink.jdbc.connections.max" value="16" />
<property name="eclipselink.logging.level" value="FINE" />
<property name="eclipselink.logging.thread" value="false" />
<property name="eclipselink.logging.session" value="false" />
<property name="eclipselink.logging.exceptions" value="false" />
<property name="eclipselink.logging.timestamp" value="false" />
</properties>
</persistence-unit>
</persistence>
However, it detects HSQLPlatform:
[EL Fine]: Detected database platform: org.eclipse.persistence.platform.database.HSQLPlatform
[EL Config]: Connection(6204974)--connecting(DatabaseLogin(
platform=>HSQLPlatform
user name=> "ampel"
connector=>JNDIConnector datasource name=>null
))
[EL Config]: Connection(6015989)--Connected: jdbc:hsqldb:file:data/hsqldb/hsqldb
User: SA
Database: HSQL Database Engine Version: 2.2.8
Driver: HSQL Database Engine Driver Version: 2.2.8
[EL Config]: Connection(11238785)--connecting(DatabaseLogin(
platform=>HSQLPlatform
user name=> "ampel"
connector=>JNDIConnector datasource name=>null
))
[EL Config]: Connection(15159299)--Connected: jdbc:hsqldb:file:data/hsqldb/hsqldb
User: SA
Database: HSQL Database Engine Version: 2.2.8
Driver: HSQL Database Engine Driver Version: 2.2.8
Even if i force the usage of the MySQL platform with , it still connects to a HSQL Database:
[EL Config]: Connection(22270740)--connecting(DatabaseLogin(
platform=>MySQLPlatform
user name=> "ampel"
connector=>JNDIConnector datasource name=>null
))
[EL Config]: Connection(25635634)--Connected: jdbc:hsqldb:file:data/hsqldb/hsqldb
User: SA
Database: HSQL Database Engine Version: 2.2.8
Driver: HSQL Database Engine Driver Version: 2.2.8
[EL Config]: Connection(19199473)--connecting(DatabaseLogin(
platform=>MySQLPlatform
user name=> "ampel"
connector=>JNDIConnector datasource name=>null
))
[EL Config]: Connection(3869646)--Connected: jdbc:hsqldb:file:data/hsqldb/hsqldb
User: SA
Database: HSQL Database Engine Version: 2.2.8
Driver: HSQL Database Engine Driver Version: 2.2.8
It also doesn't seem to care or even try to make a MySQL connection, so it doesn't matter if the mysql-connector jar is in WEB-INF/lib or not.
What's strange about this is that it correctly reads the user name from the persistence.xml, which means that the javax.persistence.jdbc.* properties are being read.
However, I get no Error/Warning whatsoever. It just doesn't even try to use MySQL.
I'm using this in a Vaadin application on TomEE 1.5.1 and I have been stuck here for three straight days now.
Does anyone have an idea what I am doing wrong?
|
|
|
|
| Re: Beginner's Problem / strange behavior [message #1017045 is a reply to message #1017042] |
Fri, 08 March 2013 13:16   |
Daniel Flassak Messages: 3 Registered: March 2013 |
Junior Member |
|
|
I just let JPAcontainer handle everything:
JPAContainer<Problem> problemContainer = JPAContainerFactory.make(Problem.class, "it-status");
But I also tried this, and it doesn't make a difference:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("it-status");
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
Problem p = new Problem();
p.setTitle("foo");
p.setDescription("bar");
em.persist(p);
em.getTransaction().commit();
Edit: Hibernate works just fine with the same persistence.xml and code. But I would really like to use Eclipselink because it is recommended over Hibernate by the Vaadin guys and others.
[Updated on: Fri, 08 March 2013 13:18] Report message to a moderator
|
|
|
|
|
| Re: Beginner's Problem / strange behavior [message #1039760 is a reply to message #1021093] |
Fri, 12 April 2013 10:49   |
Daniel Flassak Messages: 3 Registered: March 2013 |
Junior Member |
|
|
OK. So for testing this again, I have set up a vanilla Eclipse/Tomcat/Project/everything.
The [EL Config] logging does not occur on initial app deployment.
The first two [EL Config] lines in the log after I choose "Debug on Server" show this:
[EL Config]: Connection(11615255)--connecting(DatabaseLogin(
platform=>HSQLPlatform
user name=> "ampel"
connector=>JNDIConnector datasource name=>null
))
[EL Config]: Connection(580142)--Connected: jdbc:hsqldb:file:data/hsqldb/hsqldb
User: SA
Database: HSQL Database Engine Version: 2.2.8
Driver: HSQL Database Engine Driver Version: 2.2.8
))
Which means that is is correctly reading javax.persistence.jdbc.user from the persistence.xml, but still ignoring javax.persistence.jdbc.url from the very same file.
I am not setting the datasource element and I am using EclipseLink 2.4.1
[Updated on: Fri, 12 April 2013 10:56] Report message to a moderator
|
|
|
| Re: Beginner's Problem / strange behavior [message #1039892 is a reply to message #1039760] |
Fri, 12 April 2013 15:15  |
Chris Delahunt Messages: 863 Registered: July 2009 |
Senior Member |
|
|
|
If you set the logging level to FINEST, it will log what the property value is when it is set on the Session, which occurs in the deployment phase right before login, just after it reads and logs the javax.persistence.transactionType property. If it is not the value it should be, then something is injecting a property somehow or the wrong persistence.xml is being picked up - logging should also show where the persistence.xml being read in is located.
|
|
|
Powered by
FUDForum. Page generated in 0.07384 seconds