Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Beginner's Problem / strange behavior(cannot seem to use MySQL)
Beginner's Problem / strange behavior [message #1016966] Fri, 08 March 2013 11:32 Go to next message
Daniel Flassak is currently offline Daniel FlassakFriend
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 #1017042 is a reply to message #1016966] Fri, 08 March 2013 18:04 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
This is strange. It looks as if the container is injecting a datasource into the EntityManager which would override the javax.persistence properties set. How are you obtaining your EntityManager and EntityManagerFactory in the application? Could there be a different persistence unit that is loaded by the container with these settings?

Best Regards,
Chris
Re: Beginner's Problem / strange behavior [message #1017045 is a reply to message #1017042] Fri, 08 March 2013 18:16 Go to previous messageGo to next message
Daniel Flassak is currently offline Daniel FlassakFriend
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 18:18]

Report message to a moderator

Re: Beginner's Problem / strange behavior [message #1019462 is a reply to message #1017045] Fri, 15 March 2013 18:39 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Does the [EL Config] logging showing EclipseLink connecting to HSQL occur when you first call createEntityManagerFactory and createEntityManager or is it occurring on initial app deployment?

Regards,
Chris
Re: Beginner's Problem / strange behavior [message #1021093 is a reply to message #1019462] Tue, 19 March 2013 14:09 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

What version of EclipseLink are you using? If you are using a very old version it may not support "javax.persistence.jdbc.url", try instead "eclipselink.jdbc.url".

Also ensure you don't have another old persistence.xml on your classpath, and are not setting the <datasource> element.


James : Wiki : Book : Blog : Twitter
Re: Beginner's Problem / strange behavior [message #1039760 is a reply to message #1021093] Fri, 12 April 2013 14:49 Go to previous messageGo to next message
Daniel Flassak is currently offline Daniel FlassakFriend
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 14:56]

Report message to a moderator

Re: Beginner's Problem / strange behavior [message #1039892 is a reply to message #1039760] Fri, 12 April 2013 19:15 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
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.
Previous Topic:em.merge() creates 2 insert statements
Next Topic:Nested classes in JSon and removing unnecessary levels
Goto Forum:
  


Current Time: Wed Apr 24 21:17:54 GMT 2024

Powered by FUDForum. Page generated in 0.03495 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top